running a scheduled batch file

G

Guest

hello.

I want to run a program when there is not an instance of a different program
running. I have a script, from the lovely mvps.org people which works a treat:

Set WshShell = WScript.CreateObject("WScript.Shell")
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery _
("SELECT * FROM Win32_Process WHERE Name = 'wow.exe'")
If colProcesses.Count = 0 Then
WshShell.Run chr(34) & _
"%Programfiles%\boinc\boincmgr.exe" & Chr(34)
End If

I have this set up to run (minimised) every hour using task scheduler, but
it will open multiple instances of boinc. What do I need to add so it wont
start boinc if it is already running?

And I need boinc to start minimised. I tried linking to a shortcut but the
batch wouldnt run it and also -min (actual boinc command) would not work in
the batch file, either boinc.exe -min" or after " -min.

I imagine its only one or two lines of code, I have looked on internet but
cant find much specific.

thanks
 
P

Pegasus \(MVP\)

watercress_soup said:
hello.

I want to run a program when there is not an instance of a different program
running. I have a script, from the lovely mvps.org people which works a treat:

Set WshShell = WScript.CreateObject("WScript.Shell")
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery _
("SELECT * FROM Win32_Process WHERE Name = 'wow.exe'")
If colProcesses.Count = 0 Then
WshShell.Run chr(34) & _
"%Programfiles%\boinc\boincmgr.exe" & Chr(34)
End If

I have this set up to run (minimised) every hour using task scheduler, but
it will open multiple instances of boinc. What do I need to add so it wont
start boinc if it is already running?

And I need boinc to start minimised. I tried linking to a shortcut but the
batch wouldnt run it and also -min (actual boinc command) would not work in
the batch file, either boinc.exe -min" or after " -min.

I imagine its only one or two lines of code, I have looked on internet but
cant find much specific.

thanks

The following batch file will run boinc.exe but only
a) if wow.exe is not resident, and
b) if boinc is not resident.

@echo off
tasklist | find /i "wow.exe" && goto :eof
tasklist | find /i "boinc.exe" || "%Programfiles%\boinc\boincmgr.exe"
 
R

Ramesh, MS-MVP

Starts boincmgr.exe if the following conditions are true:

* boincmgr.exe is not already running
* wow.exe is not already running

- - -
Set WshShell = WScript.CreateObject("WScript.Shell")
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery _
("SELECT * FROM Win32_Process WHERE Name = 'wow.exe' or Name =
'boincmgr.exe'")
If colProcesses.Count = 0 Then
WshShell.Run chr(34) & _
"%Programfiles%\boinc\boincmgr.exe" & Chr(34)
End If
- - -

--
Regards,

Ramesh Srinivasan, Microsoft MVP [Windows XP Shell/User]
Windows® XP Troubleshooting http://www.winhelponline.com


hello.

I want to run a program when there is not an instance of a different program
running. I have a script, from the lovely mvps.org people which works a
treat:

Set WshShell = WScript.CreateObject("WScript.Shell")
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery _
("SELECT * FROM Win32_Process WHERE Name = 'wow.exe'")
If colProcesses.Count = 0 Then
WshShell.Run chr(34) & _
"%Programfiles%\boinc\boincmgr.exe" & Chr(34)
End If

I have this set up to run (minimised) every hour using task scheduler, but
it will open multiple instances of boinc. What do I need to add so it wont
start boinc if it is already running?

And I need boinc to start minimised. I tried linking to a shortcut but the
batch wouldnt run it and also -min (actual boinc command) would not work in
the batch file, either boinc.exe -min" or after " -min.

I imagine its only one or two lines of code, I have looked on internet but
cant find much specific.

thanks
 
G

Guest

That is most excellent, thank you very much. I thought it would be simple but
not having any vb experience i didnt know where to start.

and i didnt quite know where to put pegasus' addition, but thanks anyway.

thanks :)
 
P

Pegasus \(MVP\)

Your Subject was "Running a scheduled batch file".
I gave you a batch file that will do what you want,
in two lines, as an alternative to the script file
you were using.


watercress_soup said:
That is most excellent, thank you very much. I thought it would be simple but
not having any vb experience i didnt know where to start.

and i didnt quite know where to put pegasus' addition, but thanks anyway.

thanks :)

Ramesh said:
Starts boincmgr.exe if the following conditions are true:

* boincmgr.exe is not already running
* wow.exe is not already running

- - -
Set WshShell = WScript.CreateObject("WScript.Shell")
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery _
("SELECT * FROM Win32_Process WHERE Name = 'wow.exe' or Name =
'boincmgr.exe'")
If colProcesses.Count = 0 Then
WshShell.Run chr(34) & _
"%Programfiles%\boinc\boincmgr.exe" & Chr(34)
End If
- - -

--
Regards,

Ramesh Srinivasan, Microsoft MVP [Windows XP Shell/User]
Windows® XP Troubleshooting http://www.winhelponline.com


hello.

I want to run a program when there is not an instance of a different program
running. I have a script, from the lovely mvps.org people which works a
treat:

Set WshShell = WScript.CreateObject("WScript.Shell")
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery _
("SELECT * FROM Win32_Process WHERE Name = 'wow.exe'")
If colProcesses.Count = 0 Then
WshShell.Run chr(34) & _
"%Programfiles%\boinc\boincmgr.exe" & Chr(34)
End If

I have this set up to run (minimised) every hour using task scheduler, but
it will open multiple instances of boinc. What do I need to add so it wont
start boinc if it is already running?

And I need boinc to start minimised. I tried linking to a shortcut but the
batch wouldnt run it and also -min (actual boinc command) would not work in
the batch file, either boinc.exe -min" or after " -min.

I imagine its only one or two lines of code, I have looked on internet but
cant find much specific.

thanks
 
R

Ramesh, MS-MVP

You're welcome!

In a batch file, and applies to Windows XP Professional (which has
tasklist.exe).

--
Regards,

Ramesh Srinivasan, Microsoft MVP [Windows XP Shell/User]
Windows® XP Troubleshooting http://www.winhelponline.com


That is most excellent, thank you very much. I thought it would be simple
but
not having any vb experience i didnt know where to start.

and i didnt quite know where to put pegasus' addition, but thanks anyway.

thanks :)

Ramesh said:
Starts boincmgr.exe if the following conditions are true:

* boincmgr.exe is not already running
* wow.exe is not already running

- - -
Set WshShell = WScript.CreateObject("WScript.Shell")
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery _
("SELECT * FROM Win32_Process WHERE Name = 'wow.exe' or Name =
'boincmgr.exe'")
If colProcesses.Count = 0 Then
WshShell.Run chr(34) & _
"%Programfiles%\boinc\boincmgr.exe" & Chr(34)
End If
- - -

--
Regards,

Ramesh Srinivasan, Microsoft MVP [Windows XP Shell/User]
Windows® XP Troubleshooting http://www.winhelponline.com
 
G

Guest

Pegasus (MVP) said:
Your Subject was "Running a scheduled batch file".
I gave you a batch file that will do what you want,
in two lines, as an alternative to the script file
you were using.

sorry, i got the terms wrong. thanks for trying to help anyway.
 
T

Torgeir Bakken \(MVP\)

watercress_soup said:
That is most excellent, thank you very much. I thought it would be simple but
not having any vb experience i didnt know where to start.
Hi,

And to start boincmgr minimized:

WshShell.Run chr(34) & _
"%Programfiles%\boinc\boincmgr.exe" & Chr(34), 7



WSH 5.6 documentation (local help file) can be downloaded from here
if you haven't got it already:
http://msdn.microsoft.com/downloads/list/webdev.asp
 
R

Ramesh, MS-MVP

Missed that part. Thanks Torgeir!

--
Regards,

Ramesh Srinivasan, Microsoft MVP [Windows XP Shell/User]
Windows® XP Troubleshooting http://www.winhelponline.com


watercress_soup said:
That is most excellent, thank you very much. I thought it would be simple
but
not having any vb experience i didnt know where to start.
Hi,

And to start boincmgr minimized:

WshShell.Run chr(34) & _
"%Programfiles%\boinc\boincmgr.exe" & Chr(34), 7



WSH 5.6 documentation (local help file) can be downloaded from here
if you haven't got it already:
http://msdn.microsoft.com/downloads/list/webdev.asp
 

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

Top