experchange > scripting.vbscript

mistral (09-11-06, 08:20 PM)
Hi,

Need help to check is the syntax correct:

WshShell.RegWrite
"HKCU\Software\Microsoft\Windows\CurrentVersion\Po licies\ActiveDesktop"
"NoDeletingComponents"=dword:00000001
"NoEditingComponents"=dword:00000001
"NoCloseDragDropBands"=dword:00000001
"NoMovingBands"=dword:00000001

Set WSHShell = CreateObject("WScript.Shell")
WSHShell.Run "RUNDLL32.EXE Shell32.dll,SHExitWindowsEx 0"

WScript.quit

Is it OK?
Alexander Mueller (09-12-06, 12:13 AM)
11.09.2006 20:20, mistral schrieb:

[..]
> WSHShell.Run "RUNDLL32.EXE Shell32.dll,SHExitWindowsEx 0"
> WScript.quit
> Is it OK?


No

The RegWrite-part uses argument-syntax for REGEDIT4-scripts (*.reg)
For pure scripting you must put it into multiple calls:

Set WSHShell = CreateObject("WScript.Shell")
Const adKey = "HKCU\Software\Microsoft\Windows\CurrentVersion\Po licies\ActiveDesktop\"

WshShell.RegWrite adKey & "NoDeletingComponents", 1, "REG_DWORD"
WshShell.RegWrite adKey & "NoEditingComponents", 1, "REG_DWORD"
WshShell.RegWrite adKey & "NoCloseDragDropBands", 1, "REG_DWORD"
WshShell.RegWrite adKey & "NoMovingBands", 1, "REG_DWORD"

The Shutdown-command is syntactically ok, but iirc is no longer supported
under XP (assuming XP is your OS). Use either WMI-Win32_Shutdown or the
shell-util shutdown.exe for system-shutdown.

MfG,
Alex
mistral (09-12-06, 11:50 AM)
"Alexander Mueller" <millerax> wrote in message
news:6d93
[..]
> shell-util shutdown.exe for system-shutdown.
> MfG,
> Alex ---------------


Thanks for tipps.
In final part i meant Log off, not shutdown. Does anyone suggest a way to do
it in Vbscript. Thank you
Steven Burn (09-12-06, 12:23 PM)
"mistral" <mistral> wrote in message
news:1300
> In final part i meant Log off, not shutdown. Does anyone suggest a way to do
> it in Vbscript. Thank you




Watch for line wrap in the above link, or use the following;

Alexander Mueller (09-12-06, 12:31 PM)
mistral schrieb:
> Thanks for tipps.
> In final part i meant Log off, not shutdown. Does anyone suggest a way
> to do it in Vbscript. Thank you


'@From the Michael Harris-fund of kind scripting-donations

Const EWX_LOGOFF = 0

Set wmi = GetObject("winmgmts:{(Shutdown)}")
Set objSet = wmi.InstancesOf("Win32_OperatingSystem")

For Each obj in objSet
Set os = obj
Exit For
Next

os.Win32Shutdown EWX_LOGOFF
mistral (09-12-06, 01:35 PM)
"Steven Burn" <somewhere> wrote in message
news:1256
> "mistral" <mistral> wrote in message
> news:1300
>> In final part i meant Log off, not shutdown. Does anyone suggest a way to

> do
>> it in Vbscript. Thank you


http://groups.google.co.uk/group/microsoft.public.scripting.vbscript/browse_thread/thread/dacfb842cc2f64d2/d6c304eca5777249?lnk=st&q=vbscript+logoff+windows+ xp&rnum=1&hl=en#d6c304eca5777249> Watch for line wrap in the above link, or use the following;> http://surl.co.uk/?3734> --> Regards> Steven Burn> Ur I.T. Mate Group> www.it-mate.co.uk> Keeping it FREE!-------------OK, this is frequently asked question (the WMI docs for Win32Shutdown arecontradictory sometimes).Is the following correct:----code----Set wmi = GetObject("winmgmts:{(Shutdown)}")set objset = wmi.instancesof("win32_operatingsystem")for each obj in objset set os = obj : exit fornextConst EWX_LOGOFF = 0Const EWX_SHUTDOWN = 1Const EWX_REBOOT = 2Const EWX_FORCE = 4Const EWX_POWEROFF = 8os.win32shutdown EWX_LOGOFFend if--- code---------------thanks.
Mistral (09-12-06, 03:14 PM)
"Alexander Mueller" <millerax> wrote in message
news:1304
> mistral schrieb:


Thanks for tipps. In final part i meant Log off, not shutdown. Does anyone
suggest a way to do it in Vbscript. Thank you

> '@From the Michael Harris-fund of kind scripting-donations


> Const EWX_LOGOFF = 0


> Set wmi = GetObject("winmgmts:{(Shutdown)}")
> Set objSet = wmi.InstancesOf("Win32_OperatingSystem")


> For Each obj in objSet
> Set os = obj
> Exit For
> Next


> os.Win32Shutdown EWX_LOGOFF


------------
Thanks. Still note, how to complete script and exit? WScript.Quit ?

os.Win32Shutdown EWX_LOGOFF
WScript.Quit
Alexander Mueller (09-13-06, 02:10 PM)
Mistral schrieb:

> ------------
> Thanks. Still note, how to complete script and exit? WScript.Quit ?
> os.Win32Shutdown EWX_LOGOFF
> WScript.Quit


Yes Wscript.Quit ends script-execution.

But script-execution ends anyway if there is no more code to execute
or if the machine shuts down or the user logs off.

MfG,
Alex
Similar Threads