batch files are simple text files executed in a command to achieve a particular task or a set of tasks

learn more… | top users | synonyms

26
votes
2answers
45k views

How to sleep in a batch file?

How to pause execution for a while in a Windows batch file between a command and the next one?
16
votes
13answers
43k views

How to get a list of drive letters on a system through a windows shell (bat, cmd)?

How do I get a list of drive letters and their associated labels on a windows system through a bat file?
12
votes
5answers
4k views

Command line - batch file calling another batch file

I have a batch file which calls another batch file that exists in PATH directory (basically calling an executable with additional switches.) : bar.bat: foo.bat file1.txt foo.bat file2.txt etc. In ...
11
votes
8answers
31k views

Better way to wait a few seconds in a bat file? [duplicate]

Possible Duplicate: How to sleep in a batch file? Here's a haxxorish way to pause for a second in a batch file: PING 400.500.600.700 > NUL I've googled but I'm not sure there are any ...
11
votes
7answers
5k views

I would like to start multiple computers at once, What software do I use?

I have turned on Wake On Lan on all of the BIOSes in the PCs and I have a simple batch file that runs a free command wolcmd.exe Wake on Lan Command Line The syntax is as follows: wolcmd [mac ...
11
votes
5answers
3k views

What's the difference between .cmd and .bat files?

Just curious. "Cool" people in our company always use *.cmd while no one was able to explain the difference to me.
10
votes
8answers
82k views

How to create a service running a .bat file on Windows 2008 Server?

I've created the service using sc create myService binpath=myservice.bat But when I start it, it fails with the following error message: [SC] StartService FAILED 1053: The service did not ...
10
votes
6answers
385 views

50 workstations, 1 .bat file on a network server, will it work?

I have a .bat file to perform maintenance on machines. I put the .bat file on a network attached server for all workstations to access it. If I were to use the windows scheduler to make that .bat ...
10
votes
8answers
18k views

Elevating UAC via .bat file?

Pretty straightforward one that I'm having trouble finding an answer to. serverfault previously helped me with finding a way to automate Windows updates without using WSUS. It's working ...
8
votes
6answers
28k views

Batch file to uninstall all Sun Java versions?

I'm setting up a system to keep Java in our office up to date. Everyone has all different versions of Java, many of them old and insecure, and some dating back as far as 1.4. I have a System Center ...
7
votes
7answers
13k views

“Delete Files Older Than” Batch Script

So in the work of doing backups, I need a batch script that would allow me to delete files in a specified directory, that are older than lets say, 3 days. This script will be set as a scheduled task ...
6
votes
4answers
25k views

How do you wait for an exe to complete in batch file?

I'm trying to create a script to execute an exe on shutdown in order to install sp1. my script goes something like (not actual bat script). If installed GOTO END Install.exe END: My problem is ...
6
votes
6answers
16k views

Delete temporary files from batch script in xp

I'm looking for a good batch script that would quickly find & clean all the known safe temporary folders/files from Windows (as many variants as possible) machines (e.g. the windows temp folder, ...
6
votes
5answers
2k views

Do Windows batch files have a %* construction?

In a batch file, do I have to do (e.g.) the following? @echo off call other.bat %1 %2 %3 %4 %5 %6 %7 %8 %9
6
votes
2answers
2k views

Mass delete mapped & local printers

Is there any way to mass remove all local and network mapped printers from all workstations on a domain via group policy or a batch file? I need to remove local Windows 7 printers such as Fax, ...
6
votes
4answers
2k views

Checking parameters in a DOS batch file

We have a batch file that takes parameters. We then read the value of the parameter using %1 for the first parameter. Question is: How can we check that %1 has a value?
6
votes
2answers
5k views

Scheduled Tasks w/ GUI issue

Are there issues running Scheduled Tasks in Windows 2003 when the task has a GUI? I have one that worked fine in Windows 2000 but won't run on Windows 2003. Details: I have a .bat job that ran every ...
5
votes
3answers
510 views

Backup with Mercurial and Robocopy?

The Problem We would like to backup our critical files from several network shares to a removable hard drive. We want to automate the backup so we don't have to remember to run it. It needs to ...
5
votes
4answers
4k views

Correct technique to find application in 32 and 64 bit versions of Vista/Windows 7 from CMD.EXE

BACKGROUND I have an existing CMD script that works fine. It launches an app from PROGRAM FILES like so "%PROGRAMFILES%\MyApp\app.exe" PROBLEM it works fine on 32-bit versions of Windows (Vista, ...
5
votes
9answers
3k views

What scripting language do you use for your logon scripts in your Windows enviroment?

I wonder what scripting languages is most used as logon scripts these days. Is people still hacking away in batch-file files or vbscripts, or do you use PowerShell or something completely different? ...
4
votes
4answers
2k views

How to pipe program output to the screen AND to a file under Windows

I have a command which I need to inspect in real time (i.e. see its output in the command prompt MyProgram.exe) and to have a log file for later inspection (MyProgram.exe > log.txt) How can I make a ...
4
votes
3answers
10k views

How to compress files in Windows in batch file?

I can compress files or folders in Windows from GUI by right clicking and selecting "Send to .. Compressed (zip) file..". Is it possible to do same in batch file?
4
votes
3answers
302 views

Run a batch file on remote servers

I have a batch file which stops a service and deletes a file from d:\ drive. I want to execute this on 20 servers. Is there a quicker way than manually logging on each server, copying and running ...
4
votes
4answers
5k views

Windows 2003 batch file Sleep/Wait function [duplicate]

Possible Duplicate: How to sleep in a batch file? I have a batch file that runs as a secheduled task in windows server 2003. This batch file purely calls around 20 other batchfiles one ...
4
votes
1answer
4k views

How to delete scheduled task from command line without confirmation? (schtasks delete)

I can create a task from command line like this: schtasks /create /tn SomeTask /tr "do.bat arg1 arg2" /sc ONCE /st 00:00:00 /sd 01/01/1991 and now I need to delete it. However the command needs to ...
4
votes
3answers
1k views

How do you remap a share to a different drive?

I want to write a start up script to take an mapped drive, change the drive letter, then put a different share on the original drive. How can this be done?
4
votes
2answers
1k views

Windows Server 2008 - Calling FTP from .CMD - Pass a parameter to an FTP file?

I am calling the following from a .cmd file: ftp -d -s:D:\backup\web-daily.txt The web-daily.txt file is an ftp input file with similar contents to this: open <server> <login> ...
4
votes
4answers
5k views

How a batch file runs on a remote machine started by PSEXEC

I am having an issue running a Batch file on a remote machine suing PSEXEC. The file runs but does not run like it does when run through remote desktop. The batch runs a file which is a 32 bit ...
4
votes
0answers
151 views

Windows Task Scheduler cannot access EFS encrypted folder despite running as a user with access

I have a batch file set to run via Task Scheduler in Windows Server 2008 R2. The batch file is being used to rotate and compress MySQL logs, and the folder containing these logs is encrypted using ...
3
votes
9answers
5k views

what is good way to protect batch file?

I have batch scripts that are scheduled to run daily. Some of the scripts have password in them. I'd like to protect the batch from being read or opened by those not authorized to open or read them. ...
3
votes
2answers
10k views

How to uninstall software using batch file

I want to uninstall a software by calling a bat file. It must be automatically, without entering any parameters during the uninstallation. How to make the bat file which would be able to uninstall ...
3
votes
2answers
3k views

How can I move files into an zip archive from a batfile?

I think the header explain the question. I want to do inside a bat-file: zip /a /m myfile.log myarchive.zip where I just invented the zip comand and the options: /a add file /m Move file It is ...
3
votes
3answers
5k views

Line Break in Batch File

I have a simple batch file (forbat.bat), with the following content: FOR /F "tokens=4 delims=," %%G IN ("deposit,$4500,123.4,12-AUG-09") DO @echo Date paid %%G When I run this batch file, I can get ...
3
votes
1answer
657 views

Move directory in DOS (batch file) without knowing full directory name

In Bash I can move a directory without know the full directory name like so: mv gradle-*/ gradle/ How do I do this in cmd (i.e. batch file, not powershell). The move command doesn't seem to allow ...
3
votes
2answers
6k views

Can I change Internet Explorer security settings using a script?

Is it possible to change Internet Explorer security settings using a .bat or .vbs file? Basically, I need to change IE7 and IE8 security settings for the local intranet. The settings I want to ...
3
votes
5answers
1k views

How to get an EC2 Windows machine's instance-id into a batch variable

I have a batch file that I'd like to run on startup of an EC2 Windows AMI. The program I'd like to run from that batch file takes the instance-id of the EC2 machine as a parameter. What is the ...
3
votes
2answers
140 views

Stopping a scheduled task with WMIC

I need to find some method for disabling a scheduled task on a remote machine and waiting until that task has stopped executing if it happens to be running at the moment. I'd like to do this through ...
3
votes
1answer
715 views

how i can pass a file directory (path) as parameter?

how i can pass a file directory (path) as parameter to batch file in windows operating system bash file in unix operating system
3
votes
1answer
2k views

Windows Server 2008 - Windows Server Backup - Email Alerts

I would like to create a script that emails me when a scheduled daily backup runs. I'd prefer the email to indicate success or failure. I understand that this is not an easy thing to do with Windows ...
3
votes
3answers
5k views

Windows Server 2008 CMD Task Schedule not running

I have a BAT/CMD file that when run from the command prompt runs completely. When I run it through the Task Scheduler it partially runs. Here is a copy of the file cd\sqlbackup ren Apps_Backup*.* ...
3
votes
2answers
10k views

How can I edit local security policy from a batch file?

I am trying to write a utility as a batch file that, among other things, adds a user to the "Deny logon locally" local security policy. This batch file will be used on hundreds of independent ...
3
votes
2answers
515 views

Windows Batch folder size

I need a command (like "dir") that lists all directories with their size. I need just a 1 level deepness but with the total size of a directory. For example >dirsize c:/mainfolder subfolder1 ...
2
votes
3answers
658 views

Using a for loop in Microsoft cmd.exe, how can I process only the files with a certain extension?

I have a the folder c:\test\ and two files in it a.txt and b.txtv. I would like to process just the files with extension equal to .txt. If I write this commands cd c:\test for %f in (*.txt) do echo ...
2
votes
2answers
384 views

Batch Command Question

I want to make a batch file that designated as a folder name date of a previous day.How can I do? Here is my batch file. Set Tarih1=%date:.=% d:\ cd \ Yeni Klasör md %date:.=% cd %date:.=% ...
2
votes
8answers
5k views

finding user's documents folder in .bat script

What is the best way to find a user's Documents folder on XP and Vista from a batch script? Is it safe to assume that it's %USERPROFILE%\Documents?
2
votes
4answers
12k views

run bat file at startup

How do I run a bat file at startup in Windows 2008?
2
votes
4answers
239 views

possible efficient ways of transferring files from one server to another

what are the possible good and efficient ways of transferring files from one server to another? In this case it will be from windows server 2003 to windows server 2008 r2. I am thinking Powershell ...
2
votes
3answers
461 views

Can I copy a file from the Web to a local machine at the command line?

Is it possible to copy a file at a HTTP:// URL to a local directory in a BAT or CMD file?
2
votes
4answers
4k views

Remote installing programs by scripts or batch files

Firstly, I can't use Group Policy as our team doesn't manage that. The company is a massive FTSE company with a team for every aspect of IT you can think of. Our team needs a way of installing ...
2
votes
4answers
6k views

How to create a yesterday date in a batch

copy \\server01\E$\LogFiles\IVR\bcR\??120428.* \\LBC\workgroup\cs\ftp\Team\bcR\ copy \\server02\E$\LogFiles\IVR\bcR\??120428.* \\LBC\workgroup\cs\ftp\Team\bcR\ copy ...