Newest 'batch-file' Questions

Q&A for system and network administrators

Batch file fails to run all lines when called from task manager

I have a .bat file that consists of 450 lines of: start [executable] [params] Presently all the lines are perfectly identical. If I run the bat file manually, I end up with 450 instances of the ...

Start/Stop services using bat file in Windows server 2012

In our old 2003 server, we were able to start and stop services by using a bat file(with net stop and net start commands). When ever the services stops(MQ listner services), we force start an autosys ...

Launch AD for alt domain batch stopped working after win10 upgrade

I have a simple batch script that I have been using to launch the AD Users and Computers modules for domains other than the one my current session is logged in to. I've been using this for longer ...

how to Install java run-time /jre on a custom path using a Batch script?

Im trying to create a bat file to make an unattended installation with sccm. I downloaded jre-7u55-windows-i586.exe from http://www.oracle.com/technetwork/java/javase/downloads/java-archive-...

Running a Batch File from Task Scheduler With User credentials automatic fetch from directory

I'm trying to run a batch file on Windows 7 from the Task Scheduler. I can run the batch file fine if I run it from the command prompt and by storing user credentials in Task schedular. However, User'...

Setting IP that i have pinged to be a variable

I am having great difficulty with a batch file i am working with. With the update i received below, i use nslookup to return the IP of the address. Is it possible to extract the IP returned with the ...

Trigger a batch file when a user choose “Switch User” in windows

I save log in/out details of all the users to a text file through a .bat file, which is executed by Task Scheduler (on workstation-lock/unlock)/ gpedit.msc (on user logout/login). I want to run the ...

Is there any way to add an HTTP Header to every IE request on a computer?

I would like to add a custom HTTP Header to every Internet Explorer request on a computer (or every browser request). I don't know if this is possible whatsoever, if you have heard of anyway to ...

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 ...

Is there a way to run a script file that searches for files BUT excludes hidden files and folder?

I need to search some windows servers for files created after a certain date. I have set something up with forfiles but would like to speed up the process and reduce file size of the output file by ...

Batch file error when executed from Task Manager

I'm new to windows batch scripting, but I was able to get something working that I needed. It works when executing it manually, but when Task Manager executes the script, it doesn't complete. The Last ...

Windows: 'Query User' command reporting idle time inaccurately (false positives)

I'm working with ten other sysadmins that sometimes forget to log out of servers (or even lock them). For two days or more, I've been trying to come up with a 'script' that'll check each server we ...

How can I sleep in a windows batch file within a non-interactive session?

I have a batch script that is executed outside of an interactive command prompt. I want to sleep for 30 seconds between two commands in it? I've read in some responses to similar questions that ...

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\...

Run Bat file in Administrator Mode in Windows Server 2008

runas.exe /profile /user:administrator "C:\temp\SQLSP3.bat" will run the SQLSP3.bat file in Administrative Prompt and it is asking Adminstrator password in Windows Server 2008. SQLSP3.bat file has ...

Running a Batch File from Task Scheduler Without User being logged In

I'm trying to run a batch file on Windows 7 from the Task Scheduler. I can run the batch file fine if I run it from the command prompt. If I run it from the Task Scheduler to only run when the user ...

DSADD in batch file - syntax incorrect! Same command in command works fine

Really stumped here and I'm sure the answer is simple. Simply put, I'm creating a bunch of AD accounts based on input from a spreadsheet. I've been able to concatenate the fields into a DSADD command ...

Copy folders to network directory

I'd like to copy C:\users from every client's computer to a network share \\. Reason being we need to take backups of this folder and its contents prior to maintenance. Is it possible to achieve this ...

Clearing Application Even Logs of specific application

Is it possible to clear event logs of specific application (specific "Source" in Windows Event Log Viewer) via batch file? Thanks.

WMIC Command works, but doesn't work in powershell script

#Get Data Rate wmic "/OUTPUT:'C:\Users\user\Documents\DATE RATE\Data_Rate-ts8"+".txt" nic where 'NetEnabled = True' 'get Name,MacAddress,Speed'" Running this in the console directly works. That is ...

How to auto-run batch file as specific user (not scheduled task, not a duplicate)

I am an enterprise admin (Sr. Network Engineer), but my team does not manage Active Directory, so I am a little unfamiliar with policies and what is required to do what I am trying to achieve, and ...

create a .bat to map users to a shared folder but it maps them to their desired folder inside by username

I created a shared folder on my NAS box that has a folder for each user in it and it mimics their user name. I'm looking to write a .bat that will map the user folders inside to each user by user name....

Install Application using a batch file [closed]

I work at a company and I have to write a script that silently installs applications to thousands of users. I know how to do that but the only problem is this specific application has certain things ...

How to parse WMIC output in a batch file and compare to an array?

I’m writing a batch script to pull SCCM site codes from SCCM clients. I’d like to pull the clients site code and compare that to an array of site codes. If there is a match then I’ll uninstall the ...

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 ...

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 ...

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 ...

Run Log-on Script with Admin Rights

I created a batch logon script that checks and removes old versions of a specific piece of software and installs the newest version. Both the install and uninstall process use an .EXE file. The script ...

wait until completing WMIC process call create cmd.exe to run bat

I'm running a bat file located on a remote server. The command is: wmic /node:[server name] process call create "cmd.exe /c [bat file location]. I would like the command to wait until the batch file ...

Windows Server 2012 r2 Task Scheduler access denied (0x80070005) but bat works on command line

I got the following Problem. On our Windows Server 2012 r2 is a task scheduled which calls a bat file, which in return calls vb scripts. Those scripts just download 5 pictures and stores them into a ...

Rename files to add date modified to filename with Windows CMD or simple .TXT

I am attempting to rename a large batch of files to incorporate the dates in the "Date Modified" column from File Explorer into each filename in YYYYMMDD format. I was able to generate a report from ...

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, ...

Clearing Out SCCM Cache On Client Machine Automatically

I would like to run a script that clears out the SCCM cache on a client computer automatically. To do this, I have written a simple batch file: if exist %Windir%\ccmcache ( RMDIR %Windir%\...

disable scheduled task while running

We have an automated build to our Test server (Windows). Two console applications are part of the build. Those console applications are run every minute or so via a scheduled task. Often at the ...

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

Batch file to autorun when computer is inactive

As the title says, I want a batch file to autorun when the computer (mouse, keyboard, etc ...) are stopped (inactive) for at least 3 minutes. Help?

Start /wait in batch file stops waiting after ~5 minutes

I need to copy some large sets of files from one server to another (DICOM imagesets). I've written a batch file to automate the process. The batch file reads a text file with a list of cases to copy ...

WMIC Output “C Drive” in a batch File [migrated]

I'd like to create a batch file using wmic. WMIC should automatically read my COMPUTERNAME WMIC single line command is : wmic /output:c:\COMPUTERNAME_os.list os get /format:list wmic /output:c:\...

Scheduled tasks

Overview:- I need to download a csv file every 10 mins from an intranet site. This is done using a batch file. To ensure that it happens with out any delay, i have set up multiple tasks using Windows ...

Windows findstr with AND condition

Hi i searched few older posts but didnt find exact solution. so posting new question. I need a single a windows command to search two words using AND condition. Will findstr works for combination of ...

Win2012r2 Services Recovery Tab documenation refuses to launch

Services Recovery Tab Help will not launch. [ On the "Recovery" tab in Windows Services.msc, clicking on "Help me set up recovery actions" results in "An internal error occurred (...

Check for file by wildcard and store as variable in batch file [closed]

I am looking for a way to check a specified folder for a file. I will not have the complete file name, so I will have to use wildcards. After finding the file, I want to store the filename as a ...

Displaying dirsize in batch file windows server 2012 R2

I'm trying to display the dirsize with a batch file but so far no luck. DU, dirsize gives me a not recognized as an internal or external command error. This is my batch file so far, it displays all ...

How would I write a batch script that would restart a windows service across multiple servers? [closed]

Very new to batch scripts. I know how to stop and start a service, but I'm not certain how I would make the script perform the stop/start across multiple servers.

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 /...

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 ...

Batch file IF %time% not working

I'm trying to make a batch file to shutdown PCs if they're used out of the allowed times. It'll be triggered on boot, but because you can't have 'if and' triggers in Windows Task Scheduler it was ...

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? ...

How to run cmd from PowerCLI Invoke-VMScript starting with an open console

I'm trying to run a exe file in a remote machine from PowerCLI which is launching couple of cmd's. With this command: $executeCommand = "call D:\MyFile.exe Arg1 Arg2"; Invoke-VMScript -VM $vmName -...
Translating... 0%