.bat

Reading a value from a file in a windows batch script

I'm trying to read a value from a file and use it in a subsequent command. I have a file called AppServer.pid which contains the process id of my app server (just the number, it's not a properties file or anything like that). The app server is hanging, so I want to take this value and pass it to the kill command. So my script will be s...

How to execute a .bat file from a C# windows form app?

What I need to do is have a C# 2005 GUI app call a .bat and several VBScript files at user's request. This is just a stop-gap solution until the end of the holidays and I can write it all in C#. I can get the VBScript files to execute with no problem but I am unable to execute the .bat file. When I "click" in the C# app to execute the .b...

Run batch file when argument contains quotes and spaces (from .NET framework)

I have a bat file which sets some environment variables, and then executes a command on the command line. I want to replace the hard coded command with one passed in via a parameter. So: :: Set up the required environment SET some_var=a SET another_var=b CALL some.bat :: Now call the command passed into this batch file %1 The prob...

How do you run a .bat file from PHP?

Can anyone tell me how to execute a .bat file from a PHP script? I have tried - exec("C:[path to file]"); system("C:[path to file]"); nothing is working. Ive checked the PHP manuals and googled around but cant find a good answer. Anyone know where im going wrong? I'm running windows 2003 server and have successfully manually ran the ...

How can i return and process results from running a .bat file from PHP

I have a PHP script that executes a .bat file using system("cmd /c C:\dir\file.bat"); This launches an AWS server and returns info such as the id of the server started. I need to use this id in the script later on. How can I return the results from the .bat file to PHP and then how can I extract the id from the rest of the results. I...

Check when a Program is Done Running using a .BAT

How would I go about checking to see if a specific program is done running? I'm attempting to make a script that runs a series of .exe's (specifically and setup program and a number of patches) in order automatically. So far I've been able to get them to run at the same time, but that's obviously not what I need. How can I get them t...

Batch file doubts

Hi all, This is a doubt regarding a test.bat file which opens a particular .exe file which is corresponding to my application.So now i am able to open it successfully.But i get stuck up in the next thing which is it should open the File option present in the .exe window IDE and load a .cfg file and then it should open a 'Genera...

how to store hostname in a variable in a .bat file

I would like to convert this /bin/sh syntax into a widely compatible windows batch script: host=`hostname` echo ${host} How to do this so that it'll work on any Vista, WinXP, Win2k machine? To clarify: I would then like to go on in the program and use the hostname as stored in the variable host. In other words, the larger goal of th...

Some help working out kinks in a .bat

My current .bat file is as follows: @echo off rem iTunes tasklist /FI "IMAGENAME eq itunes.exe" /FO CSV > "C:/ForStartingStuff/ForItunes.log" FOR /F %%A IN (' "C:/ForStartingStuff/ForItunes.log" ') DO IF %%~zA EQU 0 GOTO end cd "C:\Program Files (x86)\iTunes" :end taskkill /im notepad.exe del "C:/ForStartingStuff/ForItunes.log rem WC3 B...

Windows .BAT to move all directories matching mask from dir A to dir B

Hi - I want to write a .BAT file to move all sub-directories (whose name matches a mask) of C:\WINNT\Temp to H:\SOMEOTHERPLACE. So if my mask is ABC* then the directories : C:\WINNT\Temp\ABC1 C:\WINNT\Temp\ABC2 C:\WINNT\Temp\ABC3 should be moved to H:\SOMEOTHERPLACE and everything else (including files, as opposed to directories,...

Problem running .bat file on Windows due to "input line is too long"

Hi, I'm using Windows and have a batch file (contents attached below) where I'm building up a classpath before trying to run a Java class. Unfortunately the classpath is fairly big and the file ends up being ~14kb. When I run it I'm getting an 'input line too long' error. I have read elsewhere that the max. size for an env variable i...

Batch file conversion to vbscript

I need to convert a batch file to vbscript but am unfamiliar with both. If I can understand what is going on in the batch file I can work out the vbscript easy enough. Problem is the batch file runs a few cscript commands which is supposed to have a syntax of cscript [script name] [host options] [script arguments] However whomever ...

embed Javascript in .bat files.

Hi, Is ther any way to execute javascript from a .bat file or embed the javascript in .bat file. I need a javascript code to write/read to a file in a local folder.This javascript i should be able to execute it using a .bat. Is it possible?. Thanks SNA ...

What should I write into the .bat file for it to find all files in folder and replace them with file from another?

What should I write into the .bat file for it to find all files with same names in folder (and it's sub folders) and replace them with file from another file (from another folder)? Is there any fast way if we have 1 000 000 folders with nearely 10 000 files for replacement? ...

Replacing files in a folder with another file with a dos-batch

Is there any example on DOS Batch - Find and Replace command for files? I need to find all files with some exact name in a folder (and its sub folders) and replace tham all (one by one for ex) with another known file ...

How can I pause the console window in .pl and .bat file?

As I know, when I run cs myConsoleApp.cs from windows command line, I can pause the Console Window by add the code below: Console.ReadLine(); Then How can I pause Console Window in myConsoleApp.pl and myConsoleApp.bat? I just want to monitor the running result from the Console window. Thank you. Suppose myConsoleApp.bat like this: ta...

unable to start .bat file from JSP

I have a batch file runthis.bat dir >dir.txt If I double click on this, a text file is being created with name dir.txt Now I have to run this batch file using JSP. <% Runtime run =Runtime.getRuntime(); run.exec("C:/Program Files/Apache Software Foundation/Tomcat 5.5/webapps/try/runthis.bat"); out.println("SUCCESS"); %> I'm getting ...

Save gcc compile status to a text file for Java

I'm making a C Assessment Program through Java, which has a bunch of programming questions for C, and it lets the user input an answer in the form of C code, and then press a "Compile" button, which is linked to a bat file that runs the user input code through gcc. I've got the input and compiling working, but I need to get the output f...

How to check location of 32bit Program FIles folder in windows .bat script

I want to write .bat script which works under all flavours of Windows, no matter if 32 or 64 bit. In this script I want to run some file.exe. That file is located in C:\Program Files\ under 32-bit systems or C:\Program FIles (x86)\ under x64 systems. I can write: "%ProgramFiles(x86)%\file.exe" under 64bit systems or "%ProgramFiles%\fil...

WMCI - how to get the ERRORLEVEL

Hi, I want to use the "wmic" command for finding out if a specific java process is still up and running. E.g.> wmic process where "commandLine like '%ACTMonitor%' and executablePath like '%PATH1%' and name like '%java%'" The problem now is that the errorlevel of this command is always 0, no matter if there is a process listed or not. ...