batch-file

Creating a .bat file

Hi, I am trying to execute a command CSRUN.exe with certain parameters from command prompt. I am able to do this using command prompt. Everytime instead of invoking this from the command prompt, i thought of writing a batch file, where in a single click will help me and also i forward this to someone who wants to execute. Following i...

Iterating arrays in a batch file

I am writing a batch file (I asked a question on SU) to iterate over terminal servers searching for a specific user. So, I got the basic start of what I'm trying to do. Enter a user name Iterate terminal servers Display servers where user is found (they can be found on multiple servers now and again depending on how the connection is l...

How to execute programs in the same directory as the windows batch file?

I have in the same folder a .bat and a .exe file. I couldn't call the .exe file from the .bat unless I put the full absolute path to it. Is there a way to don't specify the path? ...

How can I write a null ASCII character (nul) to a file with a Windows batch script?

I'm attempting to write an ASCII null character (nul) to a file from a Windows batch script without success. I initially tried using echo like this: echo <Alt+2+5+6> which seems like it should work (typing <Alt+2+5+6> in the command window does write a null character - or ^@ as it appears), but echo then outputs: More? and hangs un...

Flow control in a batch file

Reference Iterating arrays in a batch file I have the following: for /f "tokens=1" %%Q in ('query termserver') do ( if not ERRORLEVEL ( echo Checking %%Q for /f "tokens=1" %%U in ('query user %UserID% /server:%%Q') do (echo %%Q) ) ) When running query termserver from the command line, the first two lines are: ...

Is It possible to set environment variable and echo it in a single line batch script?

set A=2 && echo %A% This does not echo A as 2 in windows. Is there any way to do it? A=2 ; echo $A works in bash. I want a similar behavior on windows ...

Windows batch file: choosing a file from a directory based on directory name

I don't do windows batch programming, nor do I need to go that far down the rabbit hole. I have directory structures as such: dir1000000/file.txt dir2000000_1/file.txt dir2000000_2/file.txt I need to select the file.txt from the path with the lexicographically greatest value, i.e. dir2000000_2/file.txt. How do I go about doing this? ...

Continous Build Integration with SourceSafe and Batch Files

I want to create a continuous build integration system for .NET using just Windows batch files and Visual Source Safe. I've come up with the following batch file so far - set ssdir=\\xxxx\vss cd d:\mydir "C:\Program Files\Microsoft Visual SourceSafe\ss.exe" diff "$/sourcedir" -R -Q > diffout.txt This will spit out a file containg l...

Connect to SQL Server from batch script

Hi, I am supplying a batch script to create a DSN connection in the user computer before they start to use my application. I am using this in a .bat file. ODBCConf ConfigSysDSN "SQL Server" "DSN=CONNAME|SERVER=PCNAME\INSTANCENAME But I want to make sure they will be able to connect to the database, considering the fact that proper dr...

Stopping and Starting Apache Using PHP (!)

Hello all, I have two problems which are related. 1) I have a batch file that contains this: net stop wampapache net start wampapache Which tries to stop and start my wamp server. When I double click the stop.bat file with the above it works successfully. When I try to run that from my PHP script, it stops the server but doesn't sta...

feeding input to a java process from a batch file

If I have a simple java program that processes lines of text from standard input, then I can run it with the following script: @Echo off java Test < file.txt pause exit The script redirects lines of input from file.txt into the java program. Is there a way that I can avoid having to use a separate file? Or is this the easiest way? T...

Batch to move files in a folder to another folder?

Hello People, I want to create a batch file that moves all the files in this directory to its father directory. Like for example if I have a directory " Something " that contains files : ...New Folder/Something And I want to move the files in " Something " to New folder. Is there such a command? Thanks a bunch :) ...

setting mvc wildcard fix in iis 5.1 through batch commands

http://www.ee99ee.com/blog/2009/02/08/how-to-get-aspnet-mvc-working-under-iis-51-on-windows-xp/ Can the following be put into batch commands? If not, is there an alternative where the configuration can be set through an executable without the user having to configure through IIS? ...

Syntax for writing a loop inside the batch file

I am trying to write a small batch file for a task I do regularly. I have never used the for before and this is the first time I am trying this. This is what I have come with so far: for /f %i in ('ct find . -ver lbtype(%1) -print') do ct lsvt -g %i Basically it tries find all the files with a given cleracase label and then display t...

How to check the existence of a windows service in batch file

How can I check the existence of a windows service in a batch file? The user is inputing a service name and I want to check that the service does exist before continuing with my script. ...

String replacement in batch file

We can replace strings in a batch file using the following command set str="jump over the chair" set str=%str:chair=table% These lines work fine and change the string "jump over the chair" to "jump over the table". Now I want to replace the word "chair" in the string with some variable and I don't know how to do it. set word=table se...

Batch file from UNC path: %~dp0 takes a long time to resolve

When I try to use "%~dp0" in batch files stored on remote servers, sometimes it takes a good 45 seconds for the path to resolve! I have a fast connection and doing other things with these remote servers is quick. Is this normal? Is there any way around it? Any help would be greatly appreciated. ...

How to correctly load 32-bit DLL dependencies when running a program from a batch file

I have written a tool that references Microsoft.TeamFoundation.VersionControl.Client.dll, which is a 32-bit DLL. When I build my tool on 64-bit Windows, I set Visual Studio to specifically target X86 in order to force it to a 32-bit build. Targetting X86 instead of All-CPU's prevents me from getting a BadImageFormatException, as long a...

How does tomcat set its executable file as a windows service?

Firstly, I am not at all familiar with windows batch file programing. Recently I am curious about how tomcat sets itself as a windows service using a batch file. I downloaded the service.bat file from tomcat 6. However, I still don't understand some part of it. I guess this is the line that the batch actually register the exe file to th...

Batch File Not Executing completely

I have made a simple batch file for backing up my repository changes and rebuildig, but it always stops executing after the backup command is run. Have anyone here ever seen this happen before? ...