active processes
Moderators: Dorian (MJT support), JRL
active processes
Hello,
could somebody help me with the following problem ?!
I want to know if a special process is started(running), if yes it should start another program.
This should all be done with one script, is that possible ?!
Best and thanx in advance
could somebody help me with the following problem ?!
I want to know if a special process is started(running), if yes it should start another program.
This should all be done with one script, is that possible ?!
Best and thanx in advance
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Thanx for your fast reply....
now my example here :
Yes there is a mistake.... but i cant find it.
I cutted your script till the processname, i chekc if the process is running and the show it as message box
------------------------------------------
VBSTART
Sub Processes
'displays each process, its size lists each process and the cpu time it has used.
sComputer = "."
Set oWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & sComputer & "\root\cimv2")
Set colProcessList = oWMIService.ExecQuery _
("Select Name, WorkingSetSize from Win32_Process")
If oProcess.Name="ikke.exe"
MsgBox oProcess.Name
else
exit
endif
End Sub
VBEND
VBRun>Processes
now my example here :
Yes there is a mistake.... but i cant find it.
I cutted your script till the processname, i chekc if the process is running and the show it as message box
------------------------------------------
VBSTART
Sub Processes
'displays each process, its size lists each process and the cpu time it has used.
sComputer = "."
Set oWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & sComputer & "\root\cimv2")
Set colProcessList = oWMIService.ExecQuery _
("Select Name, WorkingSetSize from Win32_Process")
If oProcess.Name="ikke.exe"
MsgBox oProcess.Name
else
exit
endif
End Sub
VBEND
VBRun>Processes
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Try this:
If ikke.exe is running the message box will say "ikke.exe is running". Otherwise nothing will happen.
Code: Select all
VBSTART
'returns the number of copies of ProcessName that are running
'will return 0 if ProcessName is not running
Function IsProcessRunning(ProcessName)
Set oWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colProcessList = oWMIService.ExecQuery ("Select Name from Win32_Process where Name='" & ProcessName & "'")
IsProcessRunning = colProcessList.count
End Function
VBEND
VBEval>IsProcessRunning("ikke.exe"),res
If>res=1
MessageModal>ikke.exe is running
Endif
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Ok heres the final script i made with your help.
The script runs like a charm, but ... as soon as i make an .exe out of it directly an windows error shows up.
ANy idea what im doin wrong ?
---------------------------------------------------------------------------------
code :
Run Program>c:\subd\prog1.exe
VBSTART
'returns the number of copies of ProcessName that are running
'will return 0 if ProcessName is not running
Function IsProcessRunning(ProcessName)
Set oWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colProcessList = oWMIService.ExecQuery ("Select Name from Win32_Process where Name='" & ProcessName & "'")
IsProcessRunning = colProcessList.count
End Function
VBEND
label>loop1
VBEval>IsProcessRunning("prog1.exe"),res
If>res=1
MessageModal>is running
Run Program>c:\subd\prog2.exe
else
MessageModal>is NOT RUNNING
goto>loop1
Endif
label>loop2
VBEval>IsProcessRunning("prog3.exe"),res
If>res=1
MessageModal>prog3.exe is running
Run Program>c:\subd\prog4.exe
else
MessageModal>prog3.exe is NOT RUNNING
goto>loop2
Endif
---------------------------------------------------------------------------------
The script runs like a charm, but ... as soon as i make an .exe out of it directly an windows error shows up.
ANy idea what im doin wrong ?
---------------------------------------------------------------------------------
code :
Run Program>c:\subd\prog1.exe
VBSTART
'returns the number of copies of ProcessName that are running
'will return 0 if ProcessName is not running
Function IsProcessRunning(ProcessName)
Set oWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colProcessList = oWMIService.ExecQuery ("Select Name from Win32_Process where Name='" & ProcessName & "'")
IsProcessRunning = colProcessList.count
End Function
VBEND
label>loop1
VBEval>IsProcessRunning("prog1.exe"),res
If>res=1
MessageModal>is running
Run Program>c:\subd\prog2.exe
else
MessageModal>is NOT RUNNING
goto>loop1
Endif
label>loop2
VBEval>IsProcessRunning("prog3.exe"),res
If>res=1
MessageModal>prog3.exe is running
Run Program>c:\subd\prog4.exe
else
MessageModal>prog3.exe is NOT RUNNING
goto>loop2
Endif
---------------------------------------------------------------------------------
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
What windows error shows up?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
The time ill start the proggi.exe a windows message popups with :
proggie.exe ha encountered a problem and has to be closed.
I wrote(copied from this forum) also this and made a exe out of it.... also a problem :
------------------------------------------------------------------------
VBSTART
Sub killProcess(pgm)
set wmi = getobject("winmgmts:")
sQuery = "select * from win32_process " & "where name='" & pgm & "'"
set processes = wmi.execquery(sQuery)
for each process in processes
process.terminate
next
End Sub
VBEND
VBRun>KillProcess,prog1.exe
---------------------------------------------------------------------------
I checkd it on a windows2000 and 3 different windowsXP systems
Strange isnt it ?
I mean, if the failures would popup during the script running i could see whats happening... but after that its a exe-file ... i dont get it.
Did i turn off something in the system so it produces the problem, but what since i tested it also on 3 different XP-systems
Thanx
proggie.exe ha encountered a problem and has to be closed.
I wrote(copied from this forum) also this and made a exe out of it.... also a problem :
------------------------------------------------------------------------
VBSTART
Sub killProcess(pgm)
set wmi = getobject("winmgmts:")
sQuery = "select * from win32_process " & "where name='" & pgm & "'"
set processes = wmi.execquery(sQuery)
for each process in processes
process.terminate
next
End Sub
VBEND
VBRun>KillProcess,prog1.exe
---------------------------------------------------------------------------
I checkd it on a windows2000 and 3 different windowsXP systems
Strange isnt it ?
I mean, if the failures would popup during the script running i could see whats happening... but after that its a exe-file ... i dont get it.
Did i turn off something in the system so it produces the problem, but what since i tested it also on 3 different XP-systems
Thanx