batch-file

How do I test the current drive letter in a batch file?

I'm trying to write a batch file that takes the drive letter the batch file is being run from, and uses it an an IF statement. If the letter is M: for example, it will jump to the label :mSection. Is this even possible? Thanks ...

Batch file fails to set environment variable within conditional statement

Why does the following Windows Batch File output Foo followedby Bar, rather than Baz? @echo off setlocal set _=Foo echo %_% set _=Bar if 1==1 ( set _=Baz echo %_% ) The output on my system (Microsoft Windows XP [Version 5.1.2600]) is: Foo Bar If I remove the conditional statement, the expected output of Foo and Baz is obse...

MSbuild Publish to a specific directory using batch file

Follwing is the batch file for doing a publish to a publish directory @echo off start /b C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe /target:publish /p:SolutionDir="C:\cc\ttr\code\Com.IT.sln" /p:PublishDir="C:\cc\ttr\code\deploy\" /p:Configuration=Debug It is not publishing it. ANy idea why? ...

windows batch programming: how to get the error level of commands in a pipe

Batch files return the error code of the last command by default. Is it somehow possible to return the error code of a former command. Most notably is it possible to return the error code of a command in a pipe? For example, this one-line batch script foo.exe returns the error code of foo. But this one: foo.exe | tee output.txt a...

How can I run a program or batch file on the client side?

How can I run a batch file on the client side? An exe file? Just to open pre-installed program in client side? [Edit] Regarding ActiveX, I tried var activeXObj = new ActiveXObject("Shell.Application"); activeXObj.ShellExecute("C:\\WINDOWS\\NOTEPAD.EXE", "", "", "open", "1"); but this doesn't work. Any suggestions? ...

Honoring exit codes from batch files invoked by msbuild

I have a batch file that is using the exit command to return an exit code. This batch file may, in some cases, be invoked interactively from a commandline, or in other cases, may be run as part of an MSBuild project, using the Exec task. If I use exit %errorlevel% within my batch file this works well and MSBuild sees the error code, h...

How to get the exit status of a Java program in Windows batch file

Analogous to the $? in Linux, is there a way to get the exit status of a program in a Windows batch file (.bat)? Say for example the program has a System.exit(0) upon successful execution, and a System.exit(1) upon a failure, how do I trap these exit values in a .bat file? ...

Testing for file attribute in batch file

Hi, I'm writing a batch file and I need to know if a file is read only. How can I do that ? I know how to get them using the %~a modifier but I don't know what to do with this output. It gives something like -ra------. How can I parse this in batch file ? ...

Visual Studio External Tools Argument problem

Visual studio 2005: I am moving from post build event to using the external tools menu with a batch file. Previously I had cd "$(ProjectDir).." for /f "tokens=2,3,4 delims=/ " %%a in ('date /t') do set bdate=%%c.%%a.%%b pkzipc -add -overwrite -dir=current "Z:\Technology\VisualStudio2005\Project Zips\$(ProjectName)_%bdate%_%username%.z...

How can I use VB.NET to execute a batch file on another computer?

In vb.net 2008 I want to execute a batch file that resides on another computer. There is no error, but nothing happens. Here is the code: Dim pStart As New System.Diagnostics.Process Dim startInfo As New System.Diagnostics.ProcessStartInfo(serverpath & "\file.bat") startInfo.RedirectStandardOutput = True startInfo.WindowStyle = Process...

Changing a batch file when its running

I am running a long running batch file. I now realize that I have to add some more commands at the end of the batch file (no changes to exisiting content, just some extra commands). Is it possible to do this, given that most batch files are read incrementally and executed one by one? Or does the system read the entire contents of the fil...

mercurial windows batch file for pulling changes to multiple repositories

Hi all, I am a mercurial user on windows and I am trying to write a batch file to check for incoming changes to a number of repositories stored in a common folder (i.e. there could be 10 or so small mercurial repos under a main folder). I have the following batch file that successfully iterates through the multiple repositories and runs ...

Need Help Reading User Environment Variables into a Batch File

Hi I Have An App Thats In C# That Sets User Environment Variables PCManufacturer PCModel I Need To Be Able To Read The Values From Them Varibles In A Batch File How Do I Do This? I Have Tried %PCManufacturer% & %PCModel% But They Didn't Work!! ...

what is the sleakest way to proccess multiple files

I am trying to start a program by dragging multiple files on to the .exe and then have the exe send the files to diffrent folders based on rules and logic in the program itself. the problem i am running into is that i do this via a console application there is a limitation on how much information can be sent to the exe at a time. On...

How do I run Command line commands from code

I need to do 2 things: run a batch file (works fine), and run a command (does not work). The method for the command throws the exception 'file not found'. If I open a cmd window, and type the command, it works perfectly. private static void Rescan() { //System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.Proce...

Django Shell shortcut in Windows

I'm trying to write a bat file so I can quickly launch into the Interactive Shell for one of my Django projects. Basically I need to write a python script that can launch "manage.py shell" and then be able to print from mysite.myapp.models import * The problem is manage.py shell cannot take additional arguments and launching into "mana...

XCOPY exclude list ignored after first exclusion

Hey, I have a batch file I've created which uses xcopy to copy a dir, and child dirs, and merge them into one file. (ie. all my modulised development css stylesheets merged into one production stylesheet). Everything is good, apart from the fact that when I reference the excludelist.txt, it only excludes the first line, and not the sub...

How to get an EC2 Windows machine's instance-id into a batch variable

I have a batch file that I'd like to run on startup of an EC2 Windows AMI. The program I'd like to run from that batch file takes the instance-id of the EC2 machine as a parameter. What is the simplest way to get that Instance ID passed as an argument to that program? From Amazon's Documentation on the subject, I see that you're suppo...

using < and > with batch files (FIND command)

I need to find a string having < str > inside it using windows cmd.exe find command, how can I do this? Isn't < a reserved character? ...

using FIND command to find two string from one line with cmd.exe..

How to detect the following string from file safely with FIND (cmd.exe default commands), while the name minnie can be anything? its just that FROM: line has [email protected] on it. From: "Minnie" <[email protected]> it should not be mixed to this TO line : To: <[email protected]> e.g. this batch file row does not work properly : find "[email protected]" abc.t...