bat

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. ...

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...

How to get the date from a file in a bat file?

I'm writing a bat script and I have to save the date from a file to a variable. How can I do that? I will use the variable to check wether the file is older than N days, so it would be nice to save the date in a format that would allow me to do such test. ...

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...

Can someone explain this bat code?

for /f %%i in ('dir /b Client\Javascript\*_min.js') do ( set n=%%~ni set t=!n:~0,-4! cp Client\Javascript\%%i build\Client\Javascript\!t!.js ) What does %%~ni,~n:~0,-4!,%%i,!t! mean? I'm totally missed up. ...

Calling a web service from a script or batch file

We have a financial product that has built in scheduling capabilities to run over night batches. This product can also use web services to kick off each batch as required. I want to know if it is possible to call the web services from a .bat file or another type of batch/script file. If this is possible then we can call the batch file ...

Manipulating time in a batch file

Hi guys; I was wonderin' if someone would be able to help with this lil' batch file here. I'm trying to check when the last successful Windows Update was . Here is the code here .. @ECHO OFF SETLOCAL SET RegKey=HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion SET RegKey=%RegKey%\WindowsUpdate\Auto Update\Results\Install FOR /F "skip=1 tok...

Create a directory based on this month and move dirs to it

I am contemplating writing a program that will move some newly created dirs to another that puts them into date-stamped folders; either by week-month-year or month-year. I can probably write/debug/test this in java in 1.5 hours, BUT I would like to know if anyone else has had to deal with this, and perhaps has done it with a windows bat...

write to batch file to read text in a file and copy to other text file

I want read a text file on client workstation and copy that text to a text file with that workstation no. this process I need to do for 500+ workstations. I am having a NOde licence server and I updated its version so now I need to update clients also . after updating the client one file created at c:\ I need to read that file and copy ...

how to direct output into a txt file in bat script in windows

hi, all in linux, let say i want to start tomcat, and want to direct all the console log into a text file, i can do write a bash script: ./startup.sh > output.txt but in windows, can we do the similar stuff using .bat script. how can i write this bat script??? (i know the proper way should ask the application to do the log, but the ...

How to check a file every 1 minute in a windows bat script?

I want to write a bat script to check a text file (log). If the log is over 10M, I want to delete some portion of the file, only keep the last 500 lines, and delete all the old content. So there are two issues: how can I check the file every 1 minute, and how can I delete only a portion of the content? ...

Write batch file to read a number from a text file and execute the command with that number

I have a text file and a .bat file. Int the text file I have a list of workstation numbers like: CG002681 CG002526 CG002527 CG002528 CG002529 CG002530 .... so I need to read this text file and i need to excute the command as shown below. copy "\\cg002009\c$\Documents and Settings\All Users\Application Data\abc\LM\I4S.INI" c:\asd\mul....

BAT file to read and copy bottom 16 lines from a text file to another one?

I need to copy the bottom 16 lines from a text file to another text file. I need to do this procedure for all clients. At the client's location the text file will be common but the bottom 16 lines is important for confirmation of package installation. ...

Passing a shortcut to a batch script

My bat script accepts a filepath as a parameter, which allows me to drag-and-drop a file onto it from Explorer. Unfortunately when I drop a shortcut onto it, I simply get the filepath of the .lnk file itself, rather than the file that it refers to. Is there any way to derive the underlying filepath? I am looking for a native capability ...

Help on getting started with powershell - rewrite an old BAT + SQL file

Hi, I'm totally new to powershell, and I need some help to get started. What I need is to write a small script that backup a SQL database, but every time with different name (to keep the last 4-5 versions only). Right now I have a BAT, which just launch osql with a sql script, as below REM BAT file starts here "C:\Program Files\Microsof...

How do I get each comp result ?

I would like to check diffs and when files are not same,stop compare files. Compare any files C:/UML/reports/* and C:/UML/Test/*. In this two directory has same file names and also aim is to want to compare same file by name. I try to that by below code in .bat file. diff.bat @echo off for %%i in (C:\UML\reports\*) do comp %%i C:\UML...

Why has my PHP system() command stopped returning output to my scripts ... i used to work!

I have a PHP script that calls a .bat file using system(). The output is written to the screen and I derive some values from parsing this output. This is running on windows 2003 IIS server. PHP v5.2.0 Specifically I am using this script to launch an Amazon EC2 instance and assign an IP address to it. It has worked great for me so far bu...

read XLS file through batch script

This works:- for /F "tokens=4 delims= skip=1" %%x in (myfile.txt) DO echo %%x But not this:- for /F "tokens=4 delims= skip=1" %%x in (myfile.xls) DO echo %%x How can i read xls without converting to tab saperated? XLS = Excel file ...

.bat file can not execute on windows server 2003

Hello, I want to execute the batch file on server but the problem is that it can not execute. Even it is not giving any error. What should I do? this is my code try { ProcessStartInfo info = new ProcessStartInfo(AppPath + @"bin\execute.bat"); info.UseShellExecute = false; info.RedirectStandardInput = true; i...

CMD: Bat to Exe Converter - Temp directory problem

Hello, i am using 'Bat to Exe Converter' to convert my batch files to exe format. Now, i am running into some problems. Whenever i convert something, and i set 'Working Directory' to 'Current Directory', and i start my exe in echo on mode, this is what i end up with to check if there is a specific file in the directory of my exe: the ...