Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Jun 19th, 2006, 2:49 PM   #1
randum77
Programmer
 
randum77's Avatar
 
Join Date: Jun 2006
Location: Fayettehell, NC
Posts: 56
Rep Power: 3 randum77 is on a distinguished road
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 if

Added 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."
randum77 is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 1:51 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC