batch-file

Make an environment variable survive ENDLOCAL

I have a batch file that computes a variable via a series of intermediate variables: @echo off setlocal set base=compute directory set pkg=compute sub-directory set scripts=%base%\%pkg%\Scripts endlocal %scripts%\activate.bat The script on the last line isn't called, because it comes after endlocal, which clobbers the scripts envir...

how to ensure that VSVARS32.BAT batch file have permanent effect?

If I need to use microsoft C# compiler from the normal command prompt, it says right here how and it says right here how I set the environment variable (by running VSVARS32.BAT). I execute it and after that I can run "csc" (the compiler). However the effect seems to disappear when I close the command line window that run VSVARS32.BAT Is...

MySQL batch file update

One of my clients has an issue with his MySQL database. To solve the issue I need to just run a simple update on a table. I will need to send that to my client via a batch file. How do I run a MySQL update on a table via a batch file? ...

How can I escape an exclamation mark ! in cmd scripts?

When I have setlocal ENABLEDELAYEDEXPANSION set in a cmd script is there any way I can escape a ! that I want to use as a parameter to a command? @echo off setlocal ENABLEDELAYEDEXPANSION echo I want to go out with a bang! echo I still want to go out with a bang^! ...

Mercurial/extdiff not changing to temp dir (as I THINK it's supposed to)...

Using Windows, Mercurial, and the extdiff extension (for Mercurial). I was trying to set up extdiff to use WinDiff as an external diff tool, but I think I've narrowed the problem down enough to say that the trouble is before I'm even getting that far. From what I understand of extdiff, it merely calls your cmd.winmerge program, and pas...

Why can't I test the return code in Windows 7?

I have a very complicated program that is failing, and I've simplified it to this test set with a batch file and C program. My C program uses ExitProcess to pass back the errorlevel to a batch file. Sometimes on Windows 7 (Microsoft Windows [Version 6.1.7600]), the errorlevel is not being interpreted correctly. I think this should run ...

Running rake from batch file

When I run rake from within a batch file (.bat) it will exit immediately after the rake script has completed and will not execute any commands after it. e.g. for the following, it will execute rake but not change directories rake cd .. Anyone know how to stop this behaviour? ...

Command Prompt and batch files

Hey all, I'm trying to copy a number of files from a directory. I want to include the file path from the base of this particular directory tree, however, I only have a list of the file names to go by. Is there a way to copy either: a list of files with their directories appended to the beginning in a .txt file a copy of the folders in...

Batch File help needed for PsList/PsKill when a process is over a specific age (elapsed time)

I'd like to request some help in creating a Batch file to run on a windows server which will monitor processes which sometimes get "stuck" and linger after they should be killed. Specifcally, I can see the "age" of a process in the Elapsed Time column of the PsList command http://technet.microsoft.com/en-us/sysinternals/bb896682.aspx N...

How to check if a service is running via batch file and start it, if it is not running?

Hi folks, I want to write a batch file that performs the following operation: Check if a Service is running ** If is it running, quit the batch ** If it is not running, start the service The code samples I googled so far turned out not to be working, so I decided not to post them. Starting a service is done by: net start "SERVI...

Run BAT file from Adobe AIR?

To package an .air file into a native installer you have to use a batch program called adt. The command on Windows will look something like this: C:\Users\jisaacks>"C:\Program Files (x86)\Adobe\Adobe Flash Builder 4\sdks\4.1.0\bin\adt" -package -target native "D:\DEV\Flex4\Workspaces\AIR Native Packager\AIRNIP\AIRNIP.exe" ...

Why doesn't lint tell me the line number and nature of the parse error?

I'm calling php lint from a Windows batch file, like so: @echo off for %%f in (*.php) do php -l %%f When a file contains a syntax error, it only outputs Errors parsing xxx.php. Is there any way to get it to tell me what the nature of the error is, and what line it's on? Maybe another switch? ...

Why doesn't prompt for input in a batch file allow for a DASH character?

I have this simple little batch file program that I wrote but it fails if I enter a database name that contains a "-" character. Im not exactly sure why but I wish I could figure out a way around this? :: open DB batch file @echo off :: starts Sql Server Management Studio Express 2005 :: and opens it to a specific database with query ...

Open and Wait untill IE is closed in batch file

Hi, I want to open IE from a batch file and wait untill it is closed before going to the next line of the batch file. How to do this? BTW iexplore command seems to be not working in Windows 7 command line. Any idea why? Thanks... ...

svn post-commit hook fails to run with psexec

Below is the script in my SVN post-hook fails to execute on every commit into SVN and hangs c:\PsTools\Psexec.exe \192.168.1.64 -u SERVER1\Administrator -p PASSWORD c:\mybatchfiles\checkin.bat This is to run a batch file on the remote machine (SERVER1) which is located on SERVER1 at c:\mybatchfiles\ But I am able to run the same abov...

run/invoke windows batch script from sh or bash script

Hello, I have a sh/bash script that needs to call a batch file with parameters (parameters are file names and are given in DOS/Windows format). Basically I have: script.sh #!/bin/sh declare var1=$1 declare var2=$2 dosomething var1 var2 ... <invoke batch script> var1 var2 ... dosomethingelse I'm using GNU bash, version 3.1.0(3)-releas...

How to create .bat file to run c# code?

What I need is that: I have a c# code and I want to build it in order to create a .bat file on desktop. So when I run this .bat file from desktop, it should execute the c# code. Is there a way to change the settings or properties of c# project before compiling in order to create a .bat file that should run this c# code? ...

Find and Replace in a text file using a batch file

Hello all, I am trying to create a simple batch file that will replace a line in a text file with a different line, but keep every other line in the file the same. I found a script somewhere on the internet which I modified slightly and came up with the following code. However, for some reason this code is not echoing any lines ending...

How to create a batch file from .exe file?

Greetings, I want to know simply how to create a batch file from .exe file? Thank you..... ...

Delete sub directories older than 30 days

Hi, I'm trying to create a batch script that will delete all sub directories which are older than 30 days. I'm really new to batch scripting so I'm just hoping that someone can help me out on this. I was able to find a script that delete all sub directories in specified location. @for /f "tokens=*" %%a in ('dir /s /b "C:/temp/test" 2^...