![]() |
|
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Programmer
Join Date: Jun 2006
Location: Fayettehell, NC
Posts: 56
Rep Power: 3
![]() |
My first real shot at some VBScripting
Hey, i was posting before about making a VBScript to do a simple process check and if it wasn't running it would fire the process up. Well, i went ahead and took a shot at it. I replaced the app name w/ notepad so it would be easier to read out. Bassically, if notepad is not running the script runs perfect. If notepad is running, i get a couple, "It's working great!" but then it runs notepad again. I am sure it's something simple here I am just not experienced enough and kinda blind at the moement. I've been hunkering over line drive machines all day and i am cross eyed. lol
-Marshall ' VBScript source code
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Process",,48)
For Each objItem in colItems
if objItem.Caption = "notepad.exe" then
msgbox ("It it's working great!")
appvar = 0
elseif appvar <> 0
appvar = 1
end if
Next
if appvar >= 1 then
strComputer = "."
Hidden_Window=5
Set objWMIService = GetObject ("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objStartup = objWMIService.Get("Win32_ProcessStartup")
Set objConfig = objStartup.SpawnInstance_
bjConfig.ShowWindow = Hidden_Window
Set objProcess = GetObject ("winmgmts:root\cimv2:Win32_Process")
errReturn = objProcess.Create("notepad.exe", null, objConfig, intProcessID)
WScript.echo "Notepad was not running, but it is now!"
else
end ifAdded note:I just realize it had a script error. I think it was after I added the IF appvar >=1 statement on the last part. Arg! I will keep hackin at it.
__________________
_Marshall_ "America has bred a society that is innocent and incapable of accepting responsibility, but yet, is able to place blame on others without guilt." |
|
|
|
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|