How to test if procc is running Continuously

February 5, 2011 at 08:29:48
Specs: Windows 7, 12GHZ,12GB DDR5
set service = GetObject ("winmgmts:")

for each Process in Service.InstancesOf ("Win32_Process")
If Process.Name = "cmd.exe" then

End If
next
strProgramPath = "lol.bat"
strProgramPath = "CF_444.vbs"

set objShell = createobject("Wscript.Shell")

objShell.Run strProgramPath
set service = GetObject ("winmgmts:")

I tried making it start itself over since i dont seem able to put DO ~n~ LOOP, but did not work anyone?


See More: How to test if procc is running Continuously

Report •


#1
February 5, 2011 at 08:40:46
i dont seem able to put DO ~n~ LOOP
Why not?

How To Ask Questions The Smart Way


Report •

#2
February 5, 2011 at 09:26:00
dont fine the appropriate place to put it... i always get ERROR Do without Loop :(

Report •

#3
February 5, 2011 at 10:01:56
Then that means you're missing the end of the loop.
http://ns7.webmasters.com/caspdoc/h...

How To Ask Questions The Smart Way


Report •

Related Solutions

#4
February 5, 2011 at 11:14:00
Ive tried now dozens of way without Loop, i also looked into the information site about the command, however my head spins now :p, im aware what u try to do, “Give a man a fish; you have fed him for today. Teach a man to fish; and you have fed him for a lifetime” however i seem unable to do this properly. if anyone could assist and publish my code (fixed) i'd be greatful.. heres what i got :(

set service = GetObject ("winmgmts:")

strProgramPath = "CF_444.vbs"
set objShell = createobject("Wscript.Shell")

objShell.Run strProgramPath
set service = GetObject ("winmgmts:")

for each Process in Service.InstancesOf ("Win32_Process")
If Process.Name = "cmd.exe" then

wscript.quit
End If
next
strProgramPath = "lol.bat"
set objShell = createobject("Wscript.Shell")

objShell.Run strProgramPath
set service = GetObject ("winmgmts:")
wscript.quit

It works as intended... sorta but im gona have a batch file Write the VBS before excuting it, problem nr1, it seem to corrupt the code even if i have > and not >> on first batch to vbs, and it seem to hug proccess alot n make the Mouse blink lol...


Report •

#5
February 5, 2011 at 12:19:38
if exist CF_444.vbs goto next
ECHO.set service = GetObject ("winmgmts:")>>CF_444.vbs
ECHO.>>CF_444.vbs
ECHO.strProgramPath = "CF_444.vbs">>CF_444.vbs
ECHO.set objShell = createobject("Wscript.Shell")>>CF_444.vbs
ECHO.>>CF_444.vbs
ECHO.objShell.Run strProgramPath>>CF_444.vbs
ECHO.set service = GetObject ("winmgmts:")>>CF_444.vbs
ECHO.>>CF_444.vbs
ECHO.for each Process in Service.InstancesOf ("Win32_Process")>>CF_444.vbs
ECHO. If Process.Name = "cmd.exe" then>>CF_444.vbs
ECHO.>>CF_444.vbs
ECHO. wscript.quit>>CF_444.vbs
ECHO. End If>>CF_444.vbs
ECHO.next>>CF_444.vbs
ECHO.strProgramPath = "lol.bat">>CF_444.vbs
ECHO.set objShell = createobject("Wscript.Shell")>>CF_444.vbs
ECHO.>>CF_444.vbs
ECHO.objShell.Run strProgramPath>>CF_444.vbs
ECHO.set service = GetObject ("winmgmts:")>>CF_444.vbs
ECHO.wscript.quit>>CF_444.vbs
Start CF_444.vbs

Other codes


:Next


Report •

#6
February 6, 2011 at 06:19:29
Option Explicit ' Comment Me Out When Debugging
On Error Resume Next ' Comment Me Out When Debugging

Do
If Check() = vbTrue Then ' Cmd is Started
Sleep()
Else ' Cmd is Not Started
StartV()
End If
Loop

Function Check()
Dim objService , colProcess ' Declair Var!
Set objService = GetObject( "winmgmts:" ) ' GetObject SWbemServicesEx
For Each colProcess In objService.InstancesOf( "Win32_Process" ) ' Enum The Collection
If Not InStr( colProcess.Name , "cmd.exe" ) = vbFalse Then ' Check For "cmd"
Check = vbTrue
End If
Next ' Check Next Process
Set(objService)=Nothing ' Clean Up Object!
Set(colProcess)=Nothing ' Clean Up Var!
End Function

Function StartV()
Dim objShell , strProg ' Declair Var!
strProg = "Crap.bat" ' Set Var!
Set objShell = CreateObject( "WScript.Shell" ) ' Create Object
objShell.Run strProg ' Run Your Program
Set(objShell)=Nothing ' Clean Up Object!
Set(strProg)=Nothing ' Clean Up Var!
End Function

Function Sleep()
WScript.Sleep(1000*0) ' (1000 = 1 second)
End Function


Report •


Ask Question