Re: Shutdown help required

Posted: 09-20-2004, 08:12 PM
You can use the Win32_ComputerShutdownEvent class in WMI to do this. Here
is a simple vbscript which shows general idea. Alternatively, a permanent
consumer can be created to eliminate the need for the vbscript. See
http://msdn.microsoft.com/library/en...asp?frame=true.

<vbscript>
if (wscript.arguments.count > 0) then
sComputer = wscript.arguments(0)
else
sComputer = "."
end if

set osvc = getobject("winmgmts:\\" & sComputer & "\root\cimv2")
set osink = wscript.createobject("wbemscripting.swbemsink","si nk_")

osvc.execnotificationqueryasync osink, "select * from
Win32_ComputerShutdownEvent"

while true
wscript.echo "waiting..."
wscript.sleep 1000
wend



sub sink_onobjectready(obj, ctx)
wscript.echo "Computer is shutting down."

set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "notepad.exe"
end sub
</vbscript>


--
Philip Nunn [MSFT]
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm.
"Selvin" <anonymous@discussions.microsoft.com> wrote in message
news:46bb01c49f0c$02a9c180$a601280a@phx.gbl...
> Hello,
>
> Can anyone help me with the task shown below:
>
> -: I would like to run a visual basic program when users
> shutdown windows.
>
> I would appreciate any information at any level.
> Suggestions can be detailed or an overview.
>
> Regards
>
> Selvin

Reply With Quote

Responses to "Re: Shutdown help required"

 
LinkBack Thread Tools Display Modes
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may 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
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Viewing available wireless Netowrks - help required. essenby Windows Vista Networking & Sharing 7 11-21-2007 03:49 AM
Moving a file that required admin rights, it does it twice! Jon Abbott Windows Vista File Management 1 06-30-2006 08:15 PM
Single User Option Required Ol_Red Windows Vista Security 1 06-16-2006 02:21 AM
No Physical Memory is Available at the Location Required chrissyboy777 Windows Vista Install & Setup 0 06-11-2006 07:48 AM
Internet not immediatly available on dial-up. Refresh required!? redsmartie Windows XP Network & Web 2 07-02-2003 06:23 PM


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90