batch

print time in batch file (milliseconds)

How do I print the time (in ms) in a Windows batch file? I want to measure the time that passes between lines in my batch file, but Windows's "time /T" does not print milliseconds. Is there a tiny 3rd party command line utility that does this perhaps? echo %time% won't help because it's evaluated just once and thus prints the same tim...

Batch files: Get value out of string

Hi, I receive a file that contains the following: \direcotry1\directory2\directory3\file1 \direcotry1\file2 \direcotry1\directory2\directory3\directory4\file3 \direcotry1\file4 \direcotry1\directory2\file5 file6 The amount of files in the file and the amount of directories are variable. What I need is the filename (file1, file2, fil...

write batch file to copy a text file from windows system to unix system.

I need to copy the result of the bleow script to a describe location of a unix system. the script is @echo off setlocal enableextensions enabledelayedexpansion set Counter=0 set FILEPATH=C:\VPM-WNC-MANUAL-MIGRATION for /f "usebackq tokens=2,5,6 delims= " %%a in (`findstr /c:"Cod " %FILEPATH%\INPUT\INPUT.txt`) do ( set x=%%b set...

svn revision number

I am trying to get the revision number of a project and save it into a variable. I know I can get the revision number by svnversion command but I'm not sure how I can store it. I am using regular windows command prompt. Basically I'm trying to do something like : set svnVersion= %svnversion% but I'm not sure how?? ...

Quick swap of windows shell environment variables..

Not being a windows VBS writer (but user of Windows shells) I use multiple different versions of third-party code which require me to set windows shell environment variables, specifically these are Java related Looking at the following question I began to ponder what I would need to do to quickly change shell environment variables with...

Discover from a batch file where is Java installed?

I want to set the JAVA_HOME variable from a batch script ...

"start" does not work in bat file when used as filetype handler in Firefox

I have a batch (bat / cmd) file which should act as a filetype handler for jpeg files in Firefox, I just want it to copy the file to another folder, and then open the file in the Picasa Viewer. When I run it from the command line, even if I'm running it from another folder, it works fine, and opens Picasa Viewer. However, when setting it...

How can I count how many calls of a cmd file?

How can I count how many calls of a cmd file? I'm struggling with something like this but it didn't work: @IF NOT EXIST Calls.log echo. > Calls.log @for %%i in (Calls.log) do set size=%%~zi @IF %size% EQU 0 ( @ECHO 1 > Calls.log ) ELSE ( @set /p v=<Calls.log @set /A v+=1 @echo %v% > Calls.log ) ...

How to automate a process with the sqlite3.exe command line tool?

I'm trying to bulk load a lot of data ( 5.5 million rows ) into an SQLite database file. Loading via INSERTs seems to be far too slow, so I'm trying to use the sqlite3 command line tool and the .import command. It works perfectly if I enter the commands by hand, but I can't for the life of me work out how to automate it from a script ( ...

Simple way to backup event log on Windows Server

Is it possibile to create a simple way to backup the event log, with such as a batch file or a simple app ? I need to make it working on a customer's site, where the reference is an non-expert user. Thanks ...

Batch file for opening most recent Malwarebytes' Anti-Malware Log

In Vista, I want to run a batch script to open the most recent file, based either on last modified date, or the date in the filename. It's for Malwarebytes' Anti-Malware logs in the %username&/appdata/roaming/Malwarebytes/Malwarebytes' Anti-Malware/Logs folder. Log files are in this format here mbam-log-2009-03-21 (00-20-21).txt ...

How can I extract a full path from the PATH environment variable?

I want to extract a full path from the PATH environment variable with native cmd tools. Consider the following PATH content: C:\Program Files\Windows Resource Kits\Tools\;C:\Perl\site\bin;C:\Perl\bin;C:\WI NDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;c:\Program Files\Microsoft SQ L Server\90\Tools\binn\;C:\WINDOWS\system32\...

How do I extend this batch command?

I came across this piece of batch code. It should find the path to every single .exe file if you enter it. @Set Which=%~$PATH:1 @if "%Which%"=="" ( echo %1 not found in path ) else ( echo %Which% ) For instance, if you save this code in the file which.bat and then go to its directory in DOS, you can write which notepad.exe The resu...

Windows batch file starting directory when 'run as admin'

I have a batch file which is in a directory and must be run from there as well because it updates files within this directory. This works perfectly fine, except when the user runs the batch file as administrator (required on Vista). Then the starting directory is C:\Windows\System32. Is there any way to still be able to know from which d...

Parallel execution of shell processes

Is there a tool available to execute several process in parallel in a Windows batch file? I have found some interesting tools for Linux (parallel and PPSS), however, I would need a tool for Windows platforms. Bonus: It would be great if the tool also allowed to distribute processes in an easy way among several machines, running the pro...

batch file equivalent for this code

HI i want to implement this C code in batch file int i; scanf("%d", &i); for(int j = 0;j<i;j++) { scanf("%d",&j); printf("%d",j); } I would run the c program using > redirection in DOS so that the printed output comes to me in a file. I want to do the same thing in my batch file where i could write something like echo %variable...

Renaming files the same way again and again

I had a program work on some images of mine and it returned them to my directory. funny thing, they're now all png images instead of gif. At first i thought it was simple renaming, but I tested with php using createimagefrompng(), which will throw an error if the image is not a valid png file. No errors were returned. Wheter or not thi...

How to add external jars in batch file in Java

I have a java batch file consisting of 4 execution steps written for analyzing any Java application. In one of the steps, I'm adding few libs in classpath that are needed for my core application to run. If any of Java applications that I'm analyzing need specific jars, then how do I add them in the classpath mentioned in the batch file. ...

Batch File input validation - Make sure user entered an integer

I'm experimenting with a DOS batch file to perform a simple operation which requires the user to enter a non-negative integer. I'm using simple batch-file techniques to get user input: @ECHO OFF SET /P UserInput=Please Enter a Number: The user can enter any text they want here, so I would like to add some routine to make sure what the...

Batch rename issue when dealing with special chracters in the filename

I have several hundred *.mp3 files in c:\files. There are all imaginable filenames in there like milad.mp3 (good behaving) hey you.mp3 (space in filename) systemofadown.mp3 (long filename) howdy(1).mp3 (parentheses in filename) and any combination of the last three conditions. I want to rename the files to 001-test.mp3, 002-mp3, ... ...