Re: script at logon
From: Torgeir Bakken \(MVP\) (Torgeir.Bakken-spam_at_hydro.com)
Date: 02/04/05
- Next message: Scott Fenstermacher: "Re: script at logon"
- Previous message: Sam Low: "Script Encoder"
- In reply to: anonymous_at_discussions.microsoft.com: "Re: script at logon"
- Next in thread: Scott Fenstermacher: "Re: script at logon"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 04 Feb 2005 16:43:47 +0100
anonymous@discussions.microsoft.com wrote:
> Dear Torgeir,
>
> Thank you for your answer. I will live this option in the
> background for a while for the reasons Scott explained: I
> have never hidden the shell or the Explorer in such a way
> and I'm not sure how I could recover it (i.e. how could I
> edit the register again to change the values).
Hi
The way to recover is to press Ctrl+Alt+Delete and then select
"Task Manager", then "New Task...". You can now start regedit.exe,
or explorer.exe or any other program you want to. If you don't
want ordinary users to be able to do the same, you will need
to configure a policy that disable it for them, e.g. the
"Remove Task Manager" policy under "User Configuration\Administrative
Templates\System\Ctrl+Alt+Del Options"
Also, if you are not able to add a logoff routine to your library
software, you will need to add something that does log the user off
when the user exits the library software.
You could e.g. add the script below in a scheduled task that is
configured to start at user logon.
The script goes into a loop and checks for an executable every
second (notepad.exe in this example). When it detects that the app
is not running, the script will log off the user.
'--------------------8<----------------------
Const EWX_LOGOFF = 0
Const EWX_FORCE = 4
sProcessName = "notepad.exe"
sComputer = "." ' use "." for local computer
' necessary to use the RemoteShutdown privilege to log off another
' user than the one defined in the scheduled task.
Set oWmi = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(RemoteShutdown)}!\\" _
& sComputer & "\root\cimv2")
WScript.Sleep 5000 ' wait 5 seconds before starting checking
Do
Set colProcessList = oWmi.ExecQuery _
("Select * from Win32_Process Where Name = '" & sProcessName & "'")
If colProcessList.Count = 0 Then
Exit Do
End If
WScript.Sleep 1000 ' wait 1 second before checking again
Loop
Set colOpSys = oWmi.ExecQuery("select * from Win32_OperatingSystem")
For Each oOpSys in colOpSys
Set oOS = oOpSys : Exit For
Next
oOS.Win32shutdown EWX_LOGOFF + EWX_FORCE
'--------------------8<----------------------
-- torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide: http://www.microsoft.com/technet/scriptcenter/default.mspx
- Next message: Scott Fenstermacher: "Re: script at logon"
- Previous message: Sam Low: "Script Encoder"
- In reply to: anonymous_at_discussions.microsoft.com: "Re: script at logon"
- Next in thread: Scott Fenstermacher: "Re: script at logon"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|