googlymoogly
December 1st, 2006, 10:40 AM
Or rather, unwanted behaviour.
I wanted to use the most excellent tool CmdLine in a scheduled script that checks whether a certain process is running, and if not, then restart it. Due to several technical reasons, running them as services isn't advisable.
So, anyway... this is my script:
dim apa
set oShell = createobject("wscript.shell")
mystr = "cmdline | find ""[PATH_TO_EXECUTABLE]"" /i"
set apa = oShell.exec("%comspec% /c """ & mystr & """")
if apa.stdout.readall = "" then
DO STUFF
else
DON'T DO STUFF
end if
cmdline always returns a line though, because, well... the piped find command is "running", see.
You can even do
cmdline | find "asgojiesiosaegj" /i
and it'll return
find "asgojiesiosaegj" /i
I suggest a switch for CmdLine that would ignore this type of thing, if possible.
Thanks!
[Edit]
Actually, I found a solution by doing
find "BLABLA" /i /c, and then checking for > 1.
So this thread is kind of pointless I guess! I'll blame a long work day.
I wanted to use the most excellent tool CmdLine in a scheduled script that checks whether a certain process is running, and if not, then restart it. Due to several technical reasons, running them as services isn't advisable.
So, anyway... this is my script:
dim apa
set oShell = createobject("wscript.shell")
mystr = "cmdline | find ""[PATH_TO_EXECUTABLE]"" /i"
set apa = oShell.exec("%comspec% /c """ & mystr & """")
if apa.stdout.readall = "" then
DO STUFF
else
DON'T DO STUFF
end if
cmdline always returns a line though, because, well... the piped find command is "running", see.
You can even do
cmdline | find "asgojiesiosaegj" /i
and it'll return
find "asgojiesiosaegj" /i
I suggest a switch for CmdLine that would ignore this type of thing, if possible.
Thanks!
[Edit]
Actually, I found a solution by doing
find "BLABLA" /i /c, and then checking for > 1.
So this thread is kind of pointless I guess! I'll blame a long work day.