Text file containing a sequence of commands or program invocations.

learn more… | top users | synonyms (1)

84
votes
5answers
6k views

How can I remove a forkbomb from the Startup folder?

I have an older laptop running Windows Vista, from about 2005, and I was fooling around with it. In a moment of sheer stupidity, I created a Batch file and put the following code in it: %0|%0 I ran ...
74
votes
9answers
190k views

How to run a batch file without launching a “command window”?

On Windows XP, can I run a batch (.bat or .cmd) file, via a shortcut, without a "black window"?
46
votes
7answers
124k views

How to check if a directory exists in Windows?

I would like to translate this Linux/Bash script to Windows shell: if test -d myDirName; then echo "ok"; else mkdir myDirName; fi It tests if a directory exists, and if it doesn't it creates it.
46
votes
3answers
69k views

How does the Windows RENAME command interpret wildcards?

How does the Windows RENAME (REN) command interpret wildcards? The built in HELP facility is of no help - it doesn't address wildcards at all. The Microsoft technet XP online help isn't much better. ...
30
votes
5answers
440k views

How can I check a system's current NTP configuration?

I need to verify the current NTP configuration on some Windows systems. Ideally, I'd like to be able to do this via command line instead of navigating through configuration screens. (I'm working on ...
27
votes
6answers
175k views

In Windows 7, how to change proxy settings from command line?

How do I change proxy settings from command line in Windows 7? I'm not talking about just the http_proxy. I need to set system-wide proxy settings (the ones in Internet properties setting). How ...
27
votes
4answers
84k views

Remove USB device from command line

I'm constructing a backup script for Windows 7, and the last action I want it to perform is to safely "remove" the USB drive that it is backing up to. I am under the impression that plugging the drive ...
27
votes
5answers
63k views

How do I delete directory trees via batch file on Windows 7?

I want to delete the whole content of a specified folder on Windows 7 via batch file. My problem is, that 'del' or 'erase' only deletes the files, not the folders and 'rmdir' or 'rd' always deletes ...
23
votes
7answers
64k views

Delete all files from a folder and its sub folders

I want to remove all files from a folder structure, so I'm left with an empty folder structure. Can this be achieved in either batch or VBScript scripting? I have tried a very basic batch command, ...
22
votes
9answers
114k views

Is it possible to automatically run a batch file as administrator

I am wondering whether it is possible to automatically open a batch file as admin when you double-click on the batch file, because the commands need to be run with administrative rights. Note: I ...
22
votes
2answers
16k views

How to create batch file that delete all the folders named `bin` or `obj` recursively?

I have the need of deleting all bin & obj folders in a folder on my PC. So, I'm thinking of a batch file to do that but I'm not famaliar with batching file in Windows. Please help. [Edit] After ...
16
votes
3answers
7k views

How to extract a complete list of extension types within a directory?

Within a directory, and recursively within it's sub-directories, meaning every directory within a directory is processed, how do I compile a complete list of unique extensions within the directory? ...
16
votes
2answers
419 views

CMD window will not close if folder is closed during execution of bat file

I have a Server 2012 R2 Standard 64 Bit virtual machine that is acting strangely. Bat files work fine and the CMD window closes normally; but if the folder containing the bat file is closed during ...
15
votes
5answers
28k views

How to delete files from a folder using a list of file names in windows?

i have a folder with 2K+ files in it, i need to delete around 200, i have a txt file with all the file names i need removed ordered in a list, how do i remove the specific files from the folder using ...
15
votes
4answers
9k views

How can I eject a CD via the cmd?

I have been trying to eject the cd drive with the use of the cmd. However, I am stumped. Searching on the internet, I only found this answer: eject D: and a similiar answer eject D: /I Both of ...
15
votes
4answers
43k views

How can I perform a ping every X minutes and check the response time?

I am currently working in a big company and we have serious latency issues. This is happening in a process control system, and is unacceptable (Open a valve sometimes take 2 minutes before command ...
14
votes
6answers
9k views

How can I open a console application with a given window size?

The application I want to start is MongoDB. If I would start it normally, it looks like this: I don't like the amount of line breaks and I have a lot of screen space, so I would like to utilize ...
13
votes
1answer
9k views

how to escape pipe symbol | in bat scripts?

I need to echo commad usage like this in batch script named command.bat command.bat on|off I cant use echo %0 on|off I know I can use echo "%0 on|off" but it puts quotes along Is there any ...
12
votes
2answers
15k views

How can I permanently append an entry into the system's PATH variable, via command line?

What I need to do: Append a folder to the %PATH% environment variable at the SYSTEM level. Make the change permanent. How I need to do it: Using the command prompt, or another method by which ...
11
votes
5answers
2k views

How can I create a list of named folders in Windows automatically?

So, I am studying an online course which has hundreds of sub lectures. I need to download the source code for each lecture in a corresponding sub-folder. With over 120 lectures, creating a sub-folder ...
11
votes
6answers
12k views

Temporarily change directory for single batch-file command

In shell-scripting if I need to run a command from a directory I can us a subshell to ensure I return to the original context: (cd temporary/new/directory ; command) # now I am still in original ...
11
votes
3answers
5k views

How can I tell which “explorer.exe” process is the main one?

I have a batch file that changes a few registry files, and then restarts explorer.exe so that they take effect. I'm using the commands taskkill /f /im explorer.exe explorer.exe This of course ...
10
votes
5answers
11k views

Moving hidden files/folders with the command-line or batch-file

Question Does anyone know of a way to move files and folders that have the hidden, system, or read-only attribute set from the command-line or a batch file? (No, stripping the attributes first is not ...
10
votes
5answers
45k views

How do I echo a TAB char on a command prompt

On a windows batch file, what is the proper way to echo a TAB? echo A<TAB>B<TAB>C I know I can type the TAB char between entries, but most editors will display it as a sequence of ...
8
votes
1answer
952 views

Batch file opens Default Browser instead of Firefox

I have a login script that runs for every user. The first check sees if the username matches our Test-Taking User (exam). If so, launches Firefox to the exam homepage and stops. The commands ...
8
votes
5answers
34k views

Sleeping a computer via batch file in Windows 7

I want to make a batch file that will sleep my computer after a period of time. The closest thing I have found is placing it in standby, but seems to work differently than the sleep button on my ...
8
votes
1answer
14k views

Batch convert *.avi files using ffmpeg

I am trying to convert 20+ .avi files in a batch using ffmpeg. I've got the following @echo off. for file in *.avi do ffmpeg -i "$file" -s 640x480 -vcodec msmpeg4v2 "'basename "$file" ...
8
votes
3answers
3k views

Configure a Windows shortcut to prompt for input

I swear I remember some way in Windows-past to set up a desktop shortcut that would prompt for input and pass that into the command it's running. Specifically, I want to run a batch file that takes a ...
8
votes
2answers
5k views

Can I set PowerShell as 'default' in Windows 7?

I would like, by default, for PowerShell to be launched instead of Command when, say, running a batch file, or when I "Open Command Window Here", etc. Any suggestions?
7
votes
3answers
15k views

Ping every IP address in a text file?

Let´s say I have here a text file with some computer names (each line == 1 name): computerA computerB computerC ... Is it possible to create a batch file that is pinging all of these computers? And ...
7
votes
2answers
4k views

Wildcard Services restart

Currently, we have setup a .BAT file which lists all services to start / stop them eg. SC start SERVICE SC start SERVICE SC stop SERVICE SC stop SERVICE We add new services all the time and the ...
7
votes
3answers
9k views

How to sign a Windows batch (.bat) file?

I'm running Windows 7 and when I try to run a batch file, it says, "The publisher could not be verified. Are you sure you want to run this software?" So when I try to sign it with my code signing ...
7
votes
3answers
16k views

What does the percent sign (% and %%) in a batch file argument mean?

I think I'm missing something because I can't seem to find what this means. Example: for /D %%A in (*) do "\7za.exe" u -t7z -m9=LZMA2 "%%A.7z" "%%A" That line was supposed to use a command line ...
7
votes
1answer
17k views

Launch a shortcut using batch file

Here's the problem. I have a shortcut on roughly 260 computers located in the same folder as below; "c:\documents and settings\all users\desktop\Remote agent 1234.lnk" The only thing that changes ...
7
votes
3answers
3k views

Batch real time wait for a file

I have some batch scripts which wait for files. The wait loop is done with the typical IF EXISTS loop: :waitloop IF EXISTS file.zip GOTO waitloopend sleep.exe 60 goto waitloop : waitloopend I am ...
6
votes
4answers
9k views

Loading and unloading ISO files in Windows 8

I saw on one site that the new Windows 8 could load ISO images without the help of other programs. Is Windows 8 creating a new drive for every ISO? Or does it have one virtual drive to load all ISOs ...
6
votes
2answers
33k views

Windows batch file if else usage

Sorry I am new to this stuff. I'd like to run in a certain sequence the same bat file with different parameters. I wrote a very simple batch file: @echo off REM Note: to see all command line usage ...
6
votes
5answers
24k views

How to replace a single character in Windows filenames using a batch file?

I have a Windows Server 2003 server that has a whole bunch of filenames that need renaming. Basically, I just need all - (hyphens) replaced with _ (underscores), no matter where they are in the ...
6
votes
3answers
13k views

how can I make my .bat file continue after an error

I have a .bat file in windows that does three things cmd1 arg1 arg2 cmd2 arg3 cmd3 arg4 arg5 arg6 Sometimes cmd1 can fail and that's fine, I would like to carry on and execute cmd2 and cmd3. But ...
6
votes
1answer
30k views

How to write into a Log file from the batch file?

I have a batch file that triggers process in Access database. I'd like to write into a log file (just some *.txt file saved in the same folder) time when before the process started and after it was ...
6
votes
5answers
36k views

Batch file with commands to run as administrator and standard user

I'm trying writing a batch file that needs to run some commands using a local admin account (start/stop a service) and some commands using the logged in user (copy files from the user directory) and ...
6
votes
2answers
3k views

Disable close button on DOS program in Windows 7

At my company we have stores that run some old DOS software. Before Windows 7 you could run these programs in full-screen and now you cannot. I know there are work-arounds to get in full-screen ...
6
votes
1answer
100 views

something strange about Win-XP's command shell

I wrote the following command in windows XP's command shell and something strange happened: C:\Folder1> copy sample.txt : Because of my typing mistake, I wrote ":" instead of "D:" ... but it ...
5
votes
6answers
1k views

Command to find network interface for IP

With ipconfig I can show the list of network adapters and their settings, e.g. the IP address. I'm looking for a reverse command that displays the name of the network adapter for a given IP address. ...
5
votes
3answers
2k views

Why does “start winword” work but just “winword” doesn't?

Assume Microsoft Office is installed. Consider the following batch file: REM the following line successfully launches Microsoft Word start winword REM none of the following commands work to launch ...
5
votes
4answers
25k views

bat file to disable ethernet adaptor and then reenable it after windows log in

When I log into Windows 7 I need to wait 10 seconds and then disable the Local Area Connection (ethernet adaptor) and then reenable it. I have looked through the suggested answer: Enable/disable ...
5
votes
3answers
317 views

Start up computer in the morning

We are requested by management to shutdown all systems when we leave in the afternoon, any system left on is consequently shutdown by the cleaner (pulls the powercord i guess). What I hate though is ...
5
votes
2answers
5k views

How to run a windows .bat script with wine from command line?

I'm trying to run a batch script from my mac terminal using wine (in order to provide arguments to a windows executable and piping output). so far I've tried executing wine runme.bat but ...
5
votes
3answers
2k views

Why does my batch script not run all lines?

I want to create a batch script that will run axis wsdl2java.bat for multiple WSDLs. When I create a batch script with just this code: wsdl2java.bat wsdl2java.bat it would run wsdl2java.bat only ...
5
votes
1answer
7k views

Connect to VPN using command line results in error 691

I've wrote a simple batch file to connect to a specific VPN connection using RASDIAL rasdial MyVPNConnection but it always returned the error 691 Access denied because username and/or ...