batch

Make windows batch file not close upon program exit

It's all in the title. When the program is over, I want it to say "Press any key to continue..." so I can scroll thru the output. ...

Batch files - number of command line arguments

Just converting some shell scripts into batch files and there is one thing I can't seem to find...and that is a simple count of the number of command line arguments. eg. if you have: myapp foo bar In Shell: $# -> 2 $* -> foo bar $0 -> myapp $1 -> foo $2 -> bar In batch ?? -> 2 <---- what command?! %* -> foo bar %0 -> myapp %1...

Automate an OS check, three installers, and two registry appends

I need to create a single installer that I can distribute to machines running one of Windows XP or Vista. The installer needs to do the following: 1) Check if the OS is XP SP3 or Vista. If it's vanilla XP or SP1, run an MSI. This will install Remote Desktop 6.1. 2) Run an executable. This is the installation file for a VPN client a...

How to traverse folder tree/subtrees in a windows batch file?

In a windows batch file, is there a way to traverse a folder/subfolders hierarchy doing some action on each file? ...

CMD/BAT - Help determining date 36 days ago.

Each night I need to do work on a folder 36 days old from the current date. I have a system that writes files to a daily structure like below. I need to keep 35days worth on the local disk and so each night I need to archive off the 36th day. Here is the kicker... There are approx 2 million files per day, so I cannot efficiently scan ...

Windows batch script to copy and modify files containing redirect characters

We are trying to convert a bash shell script into a Windows batch script. We ship these scripts with our software product, and we cannot assume that the customer will have, or will be able to download, sed/awk/cygwin or any other non-standard tools. Therefore, the script must work with whatever tools come out-of-the-box with Windows. ...

Need assistance padding numerical month and day with leading 0

I am working within a batch file and need to pad a single digit with a leading 0 if under 10. I have the values in environmental variables. They are month and day, I need to pad to match file structure I am working against. I am using vbscript to return a date that comes back in the following format "7/16/2009". Need it to look like ...

What is the simplest built in way in windows to copy and rename files where the rename involves appending some before the extension

I have a directory (source) with a bunch of files and these two dlls file1.dll file2.dll I want to copy these to destination but on the copy have them renamed file1_a.dll file2_a.dll Basically append _a to every dll copied I need a very basic way to generate this script with a batch file Can't use perl because it's not b...

Batch: Do what ThinApp does

Hello, i want my batch file to do something like VMWARE's ThinApp Setup Capture does. So, this is what it basically needs to do: first run a total computer scan at any files, folders, register keys etc, and make a total list of them. after the user wants, it will do everything again and check for the differences between those two lists...

Copy to all folders batch file?

i want to copy a file (example: a.jpg) to all folders in a directory. i need something like copy a.jpg */a.jpg do you have a batch file that does something like that? (ps. i use windows) ...

How to change TestNG dataProvider order

Hi, I am running hundreds of tests against a large publishing system and would like to paralellize the tests using TestNG. However, I cannot find any easy way of doing this. Each test case instanciates an instance of this publisher, send some messages, wait for those messages to be published, then dump out the contents of the publish qu...

How do I escape ampersands in batch files?

How do I escape ampersands in a batch file (or from the Windows command line) in order to use the start command to open web pages with ampersands in the URL? Double quotes will not work with start; this starts a new command line window instead. Update 1: Wael Dalloul's solution works. In addition, if there are URL encoded character...

How do I transform the working directory into a 8.3 short file name using batch?

I'm writing a build script, and if the directory the user's building the script contains spaces, everything falls apart. To go around that, I thought of using 8.3 filenames so that drive:\Documents and setttings\whatever becomes drive:\Docume~1\whatever . The current directory can be found by querying the environment variable %CD%. How ...

How do you specify a Java file.encoding value consistent with the underlying Windows code page?

I have a Java application that receives data over a socket using an InputStreamReader. It reports "Cp1252" from its getEncoding method: /* java.net. */ Socket Sock = ...; InputStreamReader is = new InputStreamReader(Sock.getInputStream()); System.out.println("Character encoding = " + is.getEncoding()); // Prints "Character encoding = Cp...

Batch file FOR/f expansion

I have a file (directories.txt) with directory names, each on a single line and I like to expand the line C:\Documents and Settings\%USERNAME%\My Documents In my script to the real user name running the script. However the echo comes out exactly the same as the line and %USERNAME% does not expand. FOR /f "tokens=*" %%X IN (directorie...

CMD: file extensions recognition?

I want to have my batch file to recognise the extension of the file the user types in in the following situation: The user has to type in a folder OR a .zip/.rar file. if its a folder, it should use GOTO :folder if its a .zip/.rar, it should use GOTO :ziprar (if it is possible without 3rd party software, than dont going to say about i...

Batch file for opening one of a list of URLs

I have a list of websites. I want a batch file which will open only first website in the list when i execute the bat file for first time and when i execute the batch file for second time it will open only the second website in the list and when i execute it for third time it will open only third website in the list and so on. Someone sug...

CMD: Search for program and variable directory

Hello, i want to search for a program, like this: cd "C:\" for /f "delims=" %%f in ('dir /b /s myprogram.exe') do ( ) First problem: i want to let it search trough all hard drives (like 'cd My Computer' or something like that?) After that, it should make a variable of the directory in which that program is. How to do that in batch/c...

CMD: Batch as default program to open extension

Hello, i want to let my batch file CMD set itself as the default opener for a certain extension. Can anyone give me a code for this??? ...

Can a Batch script know if it's called from PowerShell?

Is there any way a batch script can know if it's called from PowerShell (without extra parameters feeded)? Need something like.. if (%THIS_BATCH_CALLED_FROM_POWERSHELL%) ... warn the user or drop back to powershell to execute the proper instructions... Question related with this question - virtualenv-in-powershell. ...