tags:

views:

301

answers:

2

I have an MSI installer that fails if it is running over remote desktop. (Unless it is run with the /admin or /console option so that it gets session 0)

I want to use a VBScript custom action to determine if I am running as Session 0. I've learned that I can use two WMI calls to determine this:

  • GetCurrentProcessID()
  • ProcessIdToSessionId()

However, I have no clue how to call these things in VBScript. And ideas?

A: 


Set oShell = CreateObject( "WScript.Shell" ) connection=oShell.ExpandEnvironmentStrings("%SESSIONNAME%") WScript.Echo connection

"Console" = local machine "RDP-Tcp#0" = Remote Desktop

0 can be any number

Cj Anderson
A: 

Here's a much easier solution:

Set oShell = CreateObject( "WScript.Shell" )
sessionName=oShell.ExpandEnvironmentStrings("%SESSIONNAME%")
if ( sessionName = "Console" ) then 

    Msgbox "You are running directly!"
else

    MsgBox "You are in a Remote Session!"

end if
Nissan Fan
I thought of doing it this way, but I actually need to know the session id. If the user launches mstsc with the /console or /admin option, they get session 0 and the installation succeeds.
pduncan
I think you should understand that using /console will effectively overtake the console session. If someone is already logged in they will be prompted to let you take control unless that user is the same account that you are connecting as with the /console option. http://support.microsoft.com/kb/278845 Either way, the session will appear as Console.
Nissan Fan