batch-file

passing variable to a batch file when called using "call" function.

i want to call a batch file from another batch file and also want to pass a variable to it. lets say i want to call b.bat from a.bat. my b.bat copies files. so while calling it from a.bat , i want to pass the path of the destination folder to b.bat. well to b more clear, the destination path will b entered by user, so it will b stored in...

Batch program to display files with complete directory

Hi, I want to store the URL of all files with same extension in specific directory to one Log file. IS there any batch command available for this. Exapmle I want to copy all files with *.TXT extension into one log file with its directory extension(URL) ...

How to change the text color of comments line in a batch file

I have a batch file as follows: myfile.bat :: This is a sample batch file @echo off echo change directory to d: <---How to change color of only this line (comments lines) CD d:\ ... ...

How to get full path of a given path

I have a variable define as: set filePath=".\file.txt" I'm writing a windows batch file. Need to convert the path stored in variable 'filePath' to its fullpath (physical path). How can I get the full path of this path? Please help! ...

Batch File - REN command's ErrorLevel returns 0 even on failure

This is related to my earlier question. ren "C:\Temp\%%A" "%%A" if errorlevel 0 ( "C:\Program Files\7-Zip\cmdline\7za.exe" a -tzip -mx9 "C:\temp\Zip\%%A.zip" "C:\temp\%%A" Move "C:\temp\%%A" "C:\Temp\Archive" ) In the above, the IF evaluates to true always, even if REN command fails. The idea is...

Running python batch file that has a path with SPACE character

The batch file is something like this, I put the python in some directory that has SPACE character in its path. C:\"Documents and Settings"\Administrator\Desktop\bracket\python\python C:\\"Documents and Settings"\\Administrator\\Desktop\\bracket\\[10,20]\\brackettest.py When I run this one, I get this error. C:\Documents and Set...

Writing a script with the cmd prompt.

I'm trying to make a script that will place a list (in a .csv file) of processes that are running that take up more than 10 mb of RAM and shows the time + date the script was run. My teacher did this during his lecture but I can't remember how he did it. Just trying to figure out how to be better at IT. So my question is, can anyone hel...

dos commands in batch file

I need to create a batch file that goes to a directory and execute a series of executables start cd c:\temp\ command1 command2 the above doesn't work, it only starts in c:\temp, but ignores rest. ...

Windows Batch Scripting Issue - Quoting Variables containing spaces

So here's my issue: I want to use %cd% so a user can execute a script anywhere they want to place it, but if %cd% contains spaces, then it will fail (regardless of quotes). If I hardcode the path, it will function with quotes, but if it is a variable, it will fail. Fails: (if %cd% contains spaces) "%cd%\Testing.bat" Works: "C:\Program...

How to make a Windows batch file exit when a file exists in the file structure?

Hi, I want to make something like this... :LoopBegin if ???? goto End some other work goes here* gotoLoopBegin :End The "????" part should be a check that a file exists with the name "exit.txt" for example. If such a file exists in the current folder, I want the batch file to just exit. Is there a way to do this? Thanks ...

Passing a Batch File an Argument Containing a Quote Containing a Space

Hi, On many occasions I have dealt with passing batch files arguments with spaces, quotes, percents, and slashes and all sorts of combinations of them. Usually I managed to figure out how to accomplish what I want, but this time I am stuck. I have tried a couple of hundred combinations now and my head is starting to hurt. I’ve reduced ...

Saving multiple files through xcopy in a batch file

When I use the following code in command prompt, it works fine. But when I use the same code in a batch file, nothing happens. My batch file simply consists of: for %f in (D:\flexcube1,D:\flexcube2,D:\flexcube3) do xcopy %f D:\o\ /e but it does not work. I don't understand it and I have to use a batch file to copy multiple files. An...

How to Use an Environment Variable as an Environment Variable Name

Hi, In my pursuit of a solution to another environment-variable/batch-file related problem, I have once again come across a problem I have visited before (but cannot for the life of me remember how, or even if I solved it). Say you have two BAT files (or one batch file and the command line). How can one pass an environment variable nam...

Run a .bat file on closing java app

I want to run a .bat file when I close my Java application. I try, but when I close Java app the bat file doesn't start. ...

Scheduled task to open URL

At a certain time each day, I'd like my browser to pop open a tab to a certain URL. My goals: be able to set the URL from the scheduled task use the default browser (rather than hard-coding it) I can't seem to accomplish both of these goals at once. I'll post my partial solutions as answers, but I'm hoping someone will have somethi...

"Start" command in batch script

When using start /max program_name to start a bunch programs, how to focus on each program when it opens. For now, it open focus on the first program, and launch others on the back. thanks. OS: Windows Server 2003 Program: any windows program, like notepad PS. It will focus on newly opened program on Windows XP SP3, but not Windows se...

windows batch file to call remote executable with username and password

Hi I am trying to get a batch file to call an executable from the server and login. I have a monitoring program that allows me send and execute the script. OK here goes.... //x3400/NTE_test/test.exe /USER:student password Now this doesn't work. The path is right because when I type it in at the run menu in xp it works. Then I manu...

Use .bat file to recursively loop through folders and get hold of .class files

HI all, This is what i'm trying to do. I have a .bat file which takes in a argument which is nothing but a folder name. What i do first is go one level up (cd ..). Now in this directory i have 3 folders and each folders have sub-folders and have .class files in them. What i want to do is recursively loop through the folders and get hol...

how to delete only empty directories from a batch file

Is there a way to delete all empty sub-directories below a given directory from a batch file? Or is it possible to recursively copy a directory, but excluding any empty directories? ...

How can I run a batch file silently?

I have a batch file with some commands that I need to run with my installer, but I'd rather a console not appear (in Windows). I'm executing the batch file from a WiX installer, via a custom action. I tried adding an @ECHO OFF to the top of the file, but that didn't seem to do anything. Is there a way that I can run this batch file sile...