batch-file

How can I make a batch file to act like a simple grep using Perl?

I already know the obvious answer to this question: "just download <insert favorite windows grep or grep-like tool here>". However, I work in an environment with strict controls by the local IT staff as to what we're allowed to have on our computers. Suffice it to say: I have access to Perl on Windows XP. Here's a quick Perl script I ...

What does %~d0 mean in a Windows batch file?

I'm looking at a batch file which defines the following variables: set _SCRIPT_DRIVE=%~d0 set set _SCRIPT_PATH=%~p0 What do %~d0 or %~p0 actually mean? Is there a set of well-known values for things like current directory, drive, parameters to a script? Are there any other similar shortcuts I could use? ...

Windows console command to open multiple pages in Internet Explorer 7

How do I open multiple pages in Internet Explorer 7 with a single DOS command? Is a batch file the only way to do this? Thanks! ...

Command line .cmd/.bat script, how to get directory of running script

How can you get the directory of the script that was run and use it within the .cmd file? ...

Is it possible to modify a registry entry via a .bat/.cmd script?

Is it possible to modify a registry value (whether string or DWORD) via a .bat/.cmd script? ...

.cmd and .bat file converting return code to an error message

I'm trying to automate a program I made with a test suite via a .cmd file. I can get the program that I ran's return code via %errorlevel%. My program has certain return codes for each type of error. For example: 1 - means failed for such and such a reason 2 - means failed for some other reason ... echo FAILED: Test case failed,...

How can you echo a newline in batch files?

How can you you insert a newline from your batch file output. I want to do something like: > echo hello\nworld Which would output: hello world ...

Test automation using batch files:

I have the following layout for my test suite: TestSuite1.cmd: Run my program Check its return result If the return result is not 0, convert the error to textual output and abort the script. If it succeeds, write out success. In my single .cmd file, I call my program about 10 times with different input. The problem is that the pro...

How do I implement quicksort using a batch file?

While normally it's good to always choose the right language for the job, it can sometimes be instructive to try and do something in a language which is wildly inappropriate. It can help you understand the problem better. Maybe you don't have to solve it the way you thought you did. It can help you understand the language better. May...

How to check if directory exists in %PATH%?

How does one check if a directory is already present in the PATH environment variable? Here's a start. All I've managed to do with the code below, though, is echo the first directory in %PATH%. Since this is a FOR loop you'd think it would enumerate all the directories in %PATH%, but it only gets the first one. Is there a better way of...

Upgrading DOS Batch files for Windows

Has anyone had any recent requirements for programming automated DOS Batch style tasks on a Windows box? I've got some automation to do and I'd rather not sit and write a pile of .BAT files in Notepad if there is a better way of automating these tasks: mainly moving of files under certain date and time conditions, as well as triggering ...

How do I add a multline REG_SZ string to the registry from the command line?

As part of a build setup on a windows machine I need to add a registry entry and I'd like to do it from a simple batch file. The entry is for a third party app so the format is fixed. The entry takes the form of a REG_SZ string but needs to contain newlines ie. 0xOA characters as separators. I've hit a few problems. First attempt use...

I need help executing a bat file from asp.net 2.0

I have an web application using asp.net 2.0 and vb.net I wrote a bat file to use GPG to encryt a file and call it whithin asp.net shell(pathname & filename). when I double click on the bat file from cmd windows it works fine but when I call it in the application everything command that I pass is executed perfectly except the gpg command....

How do you loop through each line in a text file using a windows batch file?

I would like to know how to loop through each line in a text file using a Windows batch file and process each line of text in succession. ...

How to check if a process is running via a batch script

How can I check if an application is running from a batch (well cmd) file? I need to not launch another instance if a program is already running. (I can't change the app to make it single instance only.) Also the application could be running as any user. ...

Sleeping in a DOS batch file

When writing a batch file to automate something on a Windows box, I've needed to pause its execution for several seconds (usually in a test/wait loop, waiting for a process to start). At the time, the best solution I could find uses ping (I kid you not) to achieve the desired effect. I've found a better write-up of it here, which describ...

How can I wrap a call to an .exe (with arguments) with another .exe?

I have a Windows executable (say program.exe) and I want to provide users with 2 launchers that will pass different arguments to it. program.exe -a program.exe -b I can easily do this with 2 batch files, but I would rather provide users with 2 .exe files as they are more likely to be used correctly without editing. Is there an easy w...

How to do something to each file in a directory with a batch script

How do you iterate over each file in a directory with a .bat or .cmd file? For simplicity please provide an answer that just echo's the filename or file path. ...

string symbol manipulation in batch files?

Is there a way to take substrings of a string with .bat/.cmd files? For example given the string "hello.txt" is there a way to strip the .txt? EDIT: Also is there a more general way to do this, not under the assumption that it is a file name or file path? ...

Best free resource for learning advanced batch-file usage?

What are the best free resources for learning advanced batch-file usage? ...