create this batch

  • Thread starter Thread starter tandemino
  • Start date Start date
T

tandemino

hi all
I want to create this batch file :

if (a.exe run) then (stop a.exe)
else (run b.exe)

where a.exe and b.exe are generic program

thanks all

--


__________________________________________
For reply to email
remove" togli_nospam"


Inviato da www.mynewsgate.net
 
tandemino said:
hi all
I want to create this batch file :

if (a.exe run) then (stop a.exe)
else (run b.exe)

where a.exe and b.exe are generic program

So you need tools to list/kill running programs/processes

The support tools for w2k have tlist/kill,
XP has tasklist/taskkill
The free pstools from http://www.sysinternals.com contain pslist/pskill.
The also free cmdow from http://www.commandline.co.uk can do both.

Since the options and the output of the tools varies, you should
state your os and preferrence.

HTH
 
Unless it is not an option for you, VBScript may be a good option. The
below is based on my simple "Kill Process If Running" script at
http://www.adminscripteditor.com/scriptlibrary/view.asp?id=443

There are also similar KiXtart functions at:
http://www.adminscripteditor.com/scriptlibrary/view.asp?id=145
http://www.adminscripteditor.com/scriptlibrary/view.asp?id=146



KillProcess = "a.exe"

Set Shell = CreateObject("WScript.Shell")
Set ProcessList =
GetObject("winmgmts://.").InstancesOf("win32_process")

For Each Process In ProcessList
If Process.Name = KillProcess Then
Process.Terminate
ProcessKilled = "True"
End If
Next

If ProcessKilled <> "True"
Shell.Run ("b.exe")
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top