batch

How to force the build to be out of date, when a text file is modified?

The Scenario My project has a post-build phase set up to run a batch file, which reads a text file "version.txt". The batch file uses the information in version.txt to inject the DLL with a version block using this tool. The version.txt is included in my project to make it easy to modify. It looks a bit like this: @set #Description="Ta...

For loop ignoring directories with a space in them?

Currently, my simple batch script looks like this: @echo off for /D /r C:\myprojects\AIS\ %%G in (_svn) do rd /S /Q %%G pause Unfortunately, this skips any directories with a space character in them, such as a directory called "My Projects". How do I get around this and make sure I traverse that directory as well? ...

batch file - use of variable

@echo off set filename = cd GWConfig_TDS-mtpe3003 set filename = VCU17_CCU6\applications\VCU17APP GOTO CHECKFILE :CHECKFILE echo reached IF EXIST %filename% ( echo exists ) ELSE ( echo Doesnot exist ) ///////////////////////////////////////////////// Here output shows : reached Doesnot echo "exists" or "Doesnot exist" Is ther...

SQL Server batch problem with error handling

I have a problem regarding SQL batches in SQL Server. Assume I execute a SqlCommand using the following code: private void Example(SqlConnection connection, SqlTransaction transaction) { using (SqlCommand cmd = new SqlCommand("select * from T1; EXECUTE('update T2 set 1=2')", connection, transaction)) { SqlDataReader ...

Build .SQL File with Batch file not working

I have a folder C:\Scripts. In that folder I have 2 sub folders, Procedures and another Views. In the Procedures folder I have 2 files proc1.sql proc2.sql in the Views table I have 2 files view1.sql view2.sql I am trying to combine these files into one .sql file with the following batch file Copy Procedures\*.sql proc.sql Copy Vie...

windows cmd connection to remote mysql dbf

is there a way of how to connect to mysql dbf on a remote server and run sql queries using windows command line? ...

Backing up a folder for the last 7 days with a DOS batch file

I'm trying to make a script that will make a copy of a folder (in Windows) every day for the last 7 days. On the 8th day I want it to take the oldest copy and overwrite it and so on and so forth so at any one time I'll have a 7 day "history" of the folder. Now I've done that previously in Linux simply by telling a daily bash script to c...

Simple example of batch file and windows scheduler

I need to create a batch file which will copy web log files from a web server to a local desktop box on daily frequency. I'm a web developer, but I'd like to take a stab at learning the process for creating a batch file and I think using the windows scheduler should get me where I need to go. In any case, I'm just looking for a jumping...

How can I make a batch file to run the same cloc command with one click?

To run the command: cloc-1.08.exe wizardry Obviously I don't want to go into DOS every time I want to do a line count. ...

Deleting a dll using a batch file

Am having a batch file used to update certain files. However when i try to delete a file from a specified folder i am getting error "Invalid syntax, directory". The command is below del /Q %INSTDIR%\xyz.dll The %INSTDIR% is taken from registry and is correctly processing any copy commands. But am getting error for del command. Please h...

Variables in effective windows batch file for deployment?

I've played around quite a bit now, and can't seem to get variables to work in a batch file, when executing commands. So, can anyone tell me if this is possible, and what is wrong with these lines of code: set THE_DB = myAwesomeDb set OUTPUT_FILE = .\db\mydb.sql mysqldump -u root --opt %THE_DB% > %OUTPUT_FILE% ...

Problem controlling windows service through an aspx page

Hi, I've an .net 3.5 aspx page which executes a batch file. The batch file starts and stops a locally running .net Windows WCF service. When i run this page in a test environment, it works fine.But it does not in other environments. So, looks like the IIS does not have enough privileges to control this service in those envs. How do i ...

Redirect calls to move/copy inside a batch file to own application

I have a complicated batch file (under windows), let's call it BigMess.bat. It makes a lot of actions that I would like to monitor (especially the copy/move actions). I wouldn't like to touch the BigMess.bat. Is it possible to redirect the calls to move/copy to my own application or another batch file? I tried putting a move.bat file b...

How can I reliably validate existence of a directory via WinXP batch script?

Howdy, I'm writing a batch script that will run on a Windows XP machine. This script needs to be able to reliably validate that a directory, passed as a command-line parameter, does in fact exist. Assuming my script is named script.bat, it needs to support the following as legal command-line parameters: C:\> script.bat C: C:\> script.b...

Emulate keystroke in other window

This may be a cardinal programming sin, but what's the easiest and quickest way via executable or batch file to bring focus to Window X and hit keystroke Y? This won't be reused, and X and Y can be hard-coded if necessary. edit: on a Windows machine ...

Getting a batch file's full path

I'd like to create a batch file that uses (e.g. prints) its full path: c:\tmp\foo> nice.bat I am c:\tmp\foo\nice.bat ...

Batch not equals

According to this, !==! is the not-equal string operator. Trying it, I get: C:\> if "asdf" !==! "fdas" echo asdf !==! was unexpected at this time. What am I doing wrong? ...

In a batch file, is it possible to replace this use of SED and TR with a for loop ?

the batch file: @echo. @set curdrive=%~d0 @path | %curdrive%\utils\sed -e "s/PATH=//" | %curdrive%\utils\tr ; \n @echo. Sample output (one path element on each line): C:\cheeso\bin C:\Perl\bin c:\utils C:\Windows\system32 C:\Windows C:\Windows\System32\Wbem c:\Program Files\Microsoft SQL Server\90\Tools\binn\ c:\.net3.5 c:\.net2.0 c...

How to store the result of a command expression in a variable using bat scripts?

I have the command below to count all directories that that follow the pattern 20?????? : 'dir /b "20??????" | find /c "2"' For example, if I have the following directories, the command would return 6: 20090901 20090902 20090903 20090904 20090905 20090906 How can I store the result of this command (6 in the forementioned example) i...

Batch file encoding

I would like to deal with filename containing strange characters, like french é. Everything is working fine in the shell : C:\somedir\>ren -hélice hélice Know if I put this line in a .bat file, I obtain the following result : C:\somedir\>ren -hÚlice hÚlice See ? é have been replaced by Ú The same is true for command output. If I ...