Newest batch Questions

Q&A for system and network administrators

Moving a lot of files with robocopy and 7zip

With the help of StackOverflow and a number of other places I've created the following script, the purpose is to look at a folder and it's subdirectories, if the files are older than 32 days -> move ...

vbs to detect usb drive and run some commands [closed]

I have two scripts. Both are within the same folder on the hard disk. The "vbs" call "bat" to detect usb to run some commands. I want to incorporate the function of selecting the usb to vbs. Thanks ...

robocopy cannot find path [closed]

i have batch script like bellow: SET SOURCE=F:\Diff\For_VOYAGE\models.pck.files\models\players SET DESTINATION=F:\Diff\For_VOYAGE\models.pck.files\NEW\models\players SET LOG=LOG.txt robocopy %SOURCE%\...

Access denied running gpo logon batch script executing reg add/query

I am using MS Server 2012 R2 64bit with Active Directory installed. I want to execute a few batch scripts when the user logs into a computer. These scripts use the "reg add/query" commands to check if ...

How can we run a logon script to mount drives UAC?

We have a small environment where we are setting up mountable drives using a login.bat file, reason why we are doing this because our script first tests whether the folder is created for that user, ...

Windows Sensu client - occasional “Access is denied” errors when running batch files

We have the Windows Sensu client running on several 2008 R2 systems. One of our checks calls a batch file to gather some info and report back. We are sporadically receiving "Unknown: Unexpected error: ...

PowerShell: export GPO to a text file

I'm new to Windows Server, and I'm curious: is there any way to dump group security settings to a text file, using PowerShell or batch files? Thank you!

batch usb letter execute command

I have and batch script to execute a command to delete several ext. Example: set /p drive=Choose the letter of usb: if %drive%== E goto E Example (if you choose E) E: del /f /q E:\*.lnk *.inf *....

Extract portion of text file between blank lines via batch

I need to be able to extract a portion of a text file that occurs between two blank lines. The text file looks something like this... This is line 01 of the text file. This is line 02 of the text ...

Push batch script to AD clients

Is it possible to force Active directory clients to run a specific batch script now (without having to restart their computer) ?

Batch: Using Number Variable at setting another Variable with concatenate function?

Hopefully someone can help me on this: I have a batchfile where I want to combine Variables and include a function with a Variable number for the concatenate - for better understanding see attached ...

Robocopy: How to copy assets from multiple locations to a single location and maintain a log

I have multiple folders containing assets (each folder has subfolders containing these assets .mp3, .txt, .png, etc). I want to copy all this assets along with the subfolder to a single location/...

Robocopy - All data marked as modified

We make use of the following script to backup a folder (quite large - approx. 400GB), to a NAS with EXT4 Filesystem: robocopy "Source_Directory" "\\NAS\Destination\Directory" /MIR /FFT /COPYALL /W:5 /...

create folder from a list

i need to create a personal folder for each user of my company. I've tried to create a batch script using ND command and it works just with name folder without . (dot) The name of each folder ...

Remotely change local group policy server 2008R2

I'm trying to find a way I can edit the 'trusted hosts' list under local group policy remotely. Path from within Local Group Policy is: \local computer policy\computer configuration\administrative ...

Automatically Setting Printer ACLs for Multiple Printers on Multiple Terminal Servers

Does anyone have an example of how to script (preferably as a batch file) to set ACLs on multiple printers installed on multiple servers? I searched Google and found some examples of settings ACLs on ...

.Bat - Delete Various Files Folders in Different Directories

Im after some assistance if possible i currently use a works laptop which i also use for personal use. what i would like to do as is create a .BAT if this is the best method to delete various folders ...

psexec start program doesn't work

Id like to kill and start a program on a remote machine with psexec. I use the following batch-file (c:/users/user is psexec root) cd c:/users/user psexec \\computername cmd /c "taskkill /im SwyxIt!....

Authorization required to install jzos batch launcher

We are trying to install the JZOS Batch Launcher. The function consists of three pieces: a load module that must be put into a z/OS PDSE, a sample start proc that can be tailored and put into an ...

how can I download web pages from the command line in windows

Well, I'm trying to do some automation using batch file to speed up my daily routine at work, and I need to solve these little questions: I want to install wget command, but using only the pure ...

windows start nginx and php-fpm in background in the same bat

I'm trying to create a bat file on windows 10 to start the nginx and php-fpm in background. At the moment I can do that but the command window (black window) remains open. If I close the window the ...

batch: how exit from for cycle without a label

is here a command to exit from a FOR without using a "goto label"? for %%c in (list) do ( [some code] for %%i in (1 1 100) do ( [some code] if [a condition] exit-this-for [some code] ) ...

Use Powershell to run an elevated executable

I have an .exe that needs to run via GPO. I attempted to do it via a batch script, however it needs to run on user machines and this requires elevation as they aren't local admins. Rather than ...

Running Exchange Powershell script from a batch file: command doesn't work. What's wrong with my syntax?

Coming from this question here: How to create a script for Exchange Powershell to modify settings for all shared mailboxes? Here is my Powershell script (scroll right to see all): $Mailboxes = Get-...

Group Policy applying only once?

For my own sanity can someone please advise why my GPO's to install application only works once? (both Machine level and User) When I say once, I let the script install to test on a virtual machine. ...

How can I confiuger a windows service from the command line

I have a windows service that I've written. I'd like to make it easy for my server team to install it. So I'm building a little batch script. One of the things that I require is for it to be setup ...

Bat file stops after invoking psexec

I want to have a simple bat files that prompts for the workstation name, uses psexec to connect to the remote computer and then run a script on the pc so I can check the results. If I run each line ...

Need script to replace TEXT in selected files

Environment Windows 10, C:\Folder_With_VMXfiles, installed sed for windows Tools: Batch script, sed for Windows Requirements: In folder C:\Folder_With_VMXfiles Need to replace some text inside the ...

Export Windows Registry for Services

I have a process that I want to automate, I have tried doing some digging but I can't find a way to do it, as I am not a heavy scripter. Here it goes: I want to have a script of some sort, that will ...

windows - how to make some file impossible to remove/rename for all users via commandline

how to (using command-line/batch file only) make some file impossible to delete/rename for all users. I tried attrib +R on file itself and on directory where it exist but it doesn't help

Trouble using powershell output as a variable in batch file

I can manually run this command from a Windows Command Prompt: powershell (new-timespan -start 01/01/2000 -end (get-date)).days % 14 And it returns a number from 0 to 13. I want to use this result ...

Batch parameters for installing OpenSSL 1.0.1?

I have a group of prereq programs that need to be installed on multiple computers. I have automated everything with a single batch file except for OpenSSL, which still requires a user to go through ...

Windows bat file: How to process output of ping.exe at real time with for loop?

I need to run ping with -t parameter and process every line in bat script. I need to do this in real time. This code explains my problem. Commant 'ping -t 8.8.8.8' prints nothing to for loop so ...

Batch pipe to findstr syntax

I want to find process with title containing some string and pass it's PID to taskkill, but I can't find proper syntax, can somebody tell what is wrong with this line? C:\>cmd /c for /f "tokens=2 ...

Wevtutil equivalent for powershell script to get event logs

I have made a powershell script which is as below but since I won't be able to save it in .evtx format. I want the wevtutil equivalent(using wevtutil epl) for the same.Please help! $ErrorTime=Get-...

Cups Printer - config in win7 via bat or vbs

In our cups server I config all printers via socket://. This cups server is a domain member of our samba PDC. The users already use a .bat script to share your own folder and also the group folder to ...

how to loop though sub folder to check if folder is empty - batch script?

What I want to do: write a batch script to do the following loop though all dir starting with "01-"... Check if "Pictures" folder is empty or not. skip rest folders If "Pictures" folder is Empty, ...

Need leading zero for batch script for time before 10am [duplicate]

I came across a bug in my script Anytime before 10am two folders are created (check image link) - one with the date and one with the time. After 10am only one folder. Any ideas how to add an extra 0 ...

batch file to install application (Adobe Reader)

I previously used ninite to install this. However, this is no longer supported through ninite anymore. I usually install this manually but I know where a way to automate this using a batch script of ...

Difference between 'call perl script.pl' vs 'call script.pl' on Windows

On Windows servers (I've tested 2008 R2 and 2012 R2) we noticed different behavior in execution of Perl scripts that are called from batch. Consider a primitive batch file as follows: :beginlbl call ...

copy file with date appended

I am writing a script that copies files to another directory. I wanted to append the date to the end of the file but when I try to use %date% I get the following: copy c:\mydir\file.zip "c:\temp\...

How to change AWSTATS configuration via cli

My Apache log files have the date included in the name and I can't change this. Is there a way to change the LogFile config parameter for AWSTATS using Windows CMD prompt? Better yet a batch script? ...

BAT script To perform file compare & based on the result, to run IF or else step

Below are the two files: A.txt Ricky Rose Charles PrevA.txt Ricky Rose Charles When I perform file comparison, after each line of compare, my below code runs for If statement. I need my code to ...

Windows batch command equivalent of “curl -s -L http://j.mp/script.sh | bash”

I would like to run a batch script that calls another batch script hosted on the internet. In bash, this can be done using something like this: curl -s -L http://j.mp/script.sh | bash How can I ...

batch script to download office 2016 install files

Writing a powershell script to run via my RMM agent that will copy Office 2016 Deployment Tool from my server to theirs then try to run the initial download to help ease my deployment process. These ...

How can I wait to the close of the uninstall panel in windows 7 from batch file?

I have simple batch file : @echo off call "c:\windows\system32\appwiz.cpl" echo "Done" On Windows XP, this batch launche the uninstall panel of windows, and block the execution until the use close ...

What does timeout /T > null mean in batch programming [closed]

What does timeout /T > null mean in batch programming. I mean I can't seem to figure out what > null means here. Sometimes it is also used for COPY [source file] [Destination file] > null

How to prevent Task Scheduler errors/fails

There seems to be lots of myths and bugs upon research not many useful items were returned or maybe outdated "Run whether logged on or not", according to many posts/results saying this function is ...

Systematically launch a GUI software in Windows Server

In a calculation provided by my Windows server, I have to make Microsoft Excel involve because of technology limitations: I need to systematically open Excel inside the server, read content of an ...

How to catch “The system cannot find the file” within For /F loop?

How to catch "The system cannot find the file" within For /F loop? I would like my code to do the following: 1 - Search for the specified file 2 - If file not found, handle the "The system cannot ...
Translating... 0%