Torgeir
Mon Nov 29 12:07:56 CST 2004
Jo wrote:
> Hi,
>
> I would like to create a script which is able to check if it
> is being run in an terminal service session.
> It should only be allowed to run locally and not remotely.
Hi
Check the environment variable %SESSIONNAME%. If it is
non-existent or contains the value Console, you are not
running in a terminal service session.
This should work:
'--------------------8<----------------------
Set oShell = CreateObject("WScript.Shell")
Set oProcessEnv = oShell.Environment("PROCESS")
sSessionName = oProcessEnv("SESSIONNAME")
If sSessionName = "" Or LCase(sSessionName) = "console" Then
WScript.Echo "Running locally!"
End If
'--------------------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