Questions tagged [batch-file]

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

batch files are text files containing commands executed in sequence to achieve a particular task or a set of tasks. They can be very simple, or can contain complex logic.

442 questions
186
votes
5 answers

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?
Massimo
  • 68,714
  • 56
  • 196
  • 319
62
votes
7 answers

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 that when it runs, it starts the installer, then…
Kravlin
  • 735
  • 1
  • 6
  • 9
43
votes
3 answers

Change current directory to the batch file directory

I have a bat file on windows that execute a procdump operation. The issue with the batch file is that I need to cd to the batch file directory first before executing the job, or else the script won't work. How to change to the current batch file…
Graviton
  • 2,775
  • 12
  • 41
  • 62
41
votes
5 answers

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.
Artem Tikhomirov
  • 732
  • 3
  • 9
  • 15
29
votes
14 answers

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?
Chris Magnuson
  • 3,701
  • 9
  • 40
  • 45
23
votes
10 answers

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 respond to the start or control request in a timely…
abyx
  • 393
  • 1
  • 3
  • 11
23
votes
1 answer

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 be confirmed and I don't know how to do that from…
18
votes
5 answers

Is it safe to write batch files with Unix line endings?

I think I ran across a bug in a batch file because it was written with unix line endings. Is this a known problem with cmd.exe running batch files in windows?
cmcginty
  • 1,263
  • 15
  • 24
17
votes
2 answers

call batch file and run using its own path/directory

I have a batch files that calls other batch files like this: e:\foo\master.bat has the content: call e:\bar\run1.bat and e:\bar\run1.bat has the content app1.exe the problem is that when I run the master.bat app1.exe will not be executed, because…
Omu
  • 327
  • 2
  • 6
  • 19
17
votes
3 answers

Store output of Windows command in batch file

I need to store the output of a command line in a variable. How can I do this?
Mohammad AL-Rawabdeh
  • 1,592
  • 12
  • 30
  • 54
17
votes
2 answers

don't show batch file command when execute it?

when i execute batch file on cmd screen the command in the batch appear on the screen example :- batch file :- @echo off. command1 command2 when i execute it on cmd the following appear on screen :- c:\user > command1 c:\user >command2 i dont to…
Mohammad AL-Rawabdeh
  • 1,592
  • 12
  • 30
  • 54
15
votes
8 answers

Better way to wait a few seconds in a bat file?

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 better ones.. any ideas? :)
Srekel
  • 359
  • 2
  • 3
  • 7
15
votes
3 answers

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 computers (not on a domain and aren't even on the same…
Stephen Jennings
  • 1,383
  • 3
  • 23
  • 30
14
votes
1 answer

Is MSIZAP still useful, or is it obsolete?

I update flash using MSI files installed by group policy. However, with every update, about a third of the workstations fail to update (Windows Vista and Windows 7 32/64-bit editions). In the event logs, this message appears: "Adobe Flash Player 11…
Force Flow
  • 1,155
  • 5
  • 23
  • 45
13
votes
5 answers

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 foo.bat: foo.exe -t -s %1 bar.bat executes the…
Dani
  • 1,216
  • 1
  • 13
  • 20
1
2 3
29 30