RG024 – Secrets of PWRGATE.EXE

By Max Ranzau

 

For years pwrgate.exe, an integral part of Workspace Manager has had the ability to launch pretty much everything else. This is very useful for creating customized startmenus and offering certain users special capabilities straight off the startmenu.

A good example of such, would be the ability to launch the User Installed Appliation Wizard (formerly known as the Partially Managed Workstation wizard). Many users and admins did not like the fact that you had to go through the Workspace Preferences/Powerpanel in order to start it from the tab named Other.

The basic idea is that you create a new managed Workspace Manager application, where the commandline is %programfiles%\res Workspace Manager\pwrgate.exe <AppID>.  Now it’s quite obvious that this AppID number here is the secret sauce. Note that it’s an integer, which means the number can be both positive and negative. I got curious to what else it might do, so I set off launching pwrgate systematically with a lot of integers to find out what’s there, besides what’s currently listed in the existing KB article Q201579.

Another interesting capability is that you can launch applications using PwrGate.exe {GUID}. The GUID of the application can be found when you open up the managed applications properties and look at the Properties|General tab. There is an advantage to using the GUID. Suppose you want to export the buildingblock with the AppID to another environment. When you re-import the buildingblock, the applications AppID will be generated afresh, meaning any reference to it elsewhere would be invalid. The applications GUID is however recorded in the buildingblock and will not change unless you specify to do so during mass import of multiple buildingblocks.

Pwrgate.exe is also responsible for launching every managed shortcut you create. If you check the properties on any shortcut in a Workspace Manager controlled startmenu, you will see something like this here on the right. That value actually corresponds to an AppID assigned to the application uppon creation.

You can get an overview of all the AppID’s for all the regular applications you’ve created and/or imported into your environment. Just go to the Composition|Applications|Managed Applications and select the Application list tab like shown here:

Besides the visible AppID’s, there are a number of hidden applications, part of Workspace Manager which you can launch this way. Below is a handy little reference to what pwrgate.exe can do in Workspace Manager:

 

 ID  Function
– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
 15  Launch the Printing Preferences panel
 14  Launch the Explorer’s Run dialogue and refresh session
  8  Launch the Workspace Preferences panel
  7  Launch the Workspace Manager Management Console
  6  Launch the Access Wizard (for delegation)
  5* ? + Refresh (tries to launch a commandline 0 that doesn’t exist)
  4* ? + Refresh (tries to launch a commandline 0 that doesn’t exist)
  3  Launch the PowerHelp panel
  2  Launch the WorkSpace Preferences panel (unknown diff from 2)
 -2  Force a Refresh of the session
 -3  Logoff
-15  Launch the Restore UserSettings  wizard
-16  Launch the User Installed Application wizard
-44  Force Logoff *2
-55  Save Settings and User Settings, then initiate restart *3
-77  From WM2011: Lauch sync event specified by {GUID} *1

* These may possibly be reserved for future use.

– – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –

*3)  Parameter -55 was added in Workspace Manager 2012 SR3. The reason for this parameter is that installation packages initiated by Microsoft System Center Configuration Manager (SCCM) sometimes need a reboot. In a regular reboot initiated by this system, settings and User Settings are not saved. For these situations, it is now possible to initiate a restart of the system with the -55 parameter.

*2) Parameter -44 was added in Workspace Manager 2011 SR3.  This command results in a Forced Logoff of RES Workspace Manager Composer. It can be used in a virtual environment like Citrix XenDesktop to prevent a possible disruption of the standard Composer Logoff procedure. This is a known issue of Citrix XenDesktop version 4.0.5034 and higher i.c.w. Microsoft Windows XP. To use this command, add a managed application in the RES Workspace Manager Console that starts pwrgate.exe -44, make this available to users who experience a disruption of the standard Log Off procedure and hide the standard Log Off button.

*1) The -77 appID above deserves a little more detail. From Workspace Manager 2011 and up, it is now possible to automagically create a new managed application shortcut for an exisisting sync job.Once you’ve created a FileSync job in Workspace Manager, save it, then open it up again. You will notice a nice button, called “Create Managed Application for on-demand synchronization…” at the bottom of the dialog box which will allow you to create mentioned shortcut. The commandline of the shortcut will be pwrgate.exe -77 {GUID-of-the-sync-job}. In other words, you don’t have to manually create a shortcut for this, as the WM2011 console has provisions to do so for you:

The resulting shortcut will allow the user to manually kickstart any sync job you have defined. This could be very useful in laptop scenarios where you could create a “Sync My Stuff Now!” icon for the users.

 

Now, if you want to avoid creating all of the working shortcuts above, you can  just download the BuildingBlock below. This will give you a nice set of predefined applications as shown here on the right. Note all apps are set to All Users access per default, but they are harmless as the user won’t be able to start anything he’s not allowed to.

Click here to download:

 

PS: If you found this article of interest, you may want to have a look at article RG004, which describes the commandlines of Workspace Manager.

12 Comments

  • By Patrik, March 13, 2010 @ 08:50

    You’re the man :-)

  • By Dennis Persson, March 17, 2010 @ 15:29

    Really cool, I will try these out.

  • By Frode, April 17, 2010 @ 17:12

    Once again… thanks for all your effort.. this saves me and everyone else a lot of time !!

  • By Praveet, October 21, 2010 @ 06:41

    Have you noticed that when powergate.exe is used to launch a Managed App that the managed app does not focus as the main windows in a windows 2008 R2 Terminal server environment. the focus is still set on the command prompt or RUN command. can be annoying if you have a 3rd pary application that needs to launch a res managed application.

  • By Sly Dog, April 19, 2011 @ 10:35

    -77 is Folder sync on-demand

  • By RESguru, April 19, 2011 @ 10:39

    Thanks Syl, I’ll put it in the article!

  • By Marco, September 7, 2012 @ 04:10

    Praveet: You are right, specially if one wants to start another application from your application via for instance OLE! Then you are stuck with the wrong window…

  • By Hank, July 12, 2013 @ 01:26

    at my workstation, 37 launches internet explorer

  • By Brian Klausen, September 30, 2013 @ 06:09

    Hi there.
    Is there any way to force PowerGate to load user settings without launching the application?
    Say you have app 1 that has a bunch of settings. Then you have app 2, and app 2 calls not the .exe of app 1, but a .dll that is installed with app 1 and uses the user settings of app 1.
    Thus I would like a way to ensure that app 1 settings are loaded, upon starting app 2 – or maybe before app 2 loads app 1’s .dll.
    Since I can’t seem to configure WM to load application settings at logon, or link them to a global user setting, we’re toying with the idea of programmatically forcing WM to load the settings.

    Any comments?

  • By RESguru, September 30, 2013 @ 17:42

    Hi Brian, well this is an interesting challenge.
    I don’t believe there is a way to make Pwrgate do what you’re asking, but it leaves me wondering why you can’t link the user setting between the two apps? I mean, there has to be an executable of sorts that’s being launched in order to call the DLL from app1.

    If linking is not possible, I would perhaps look at putting the mentioned two applications, DLL files and all into an App-V package. At least you’d be 100% guaranteed that the two apps and DLL’s share the same settings and RESWM would cater for it as well.

    Just my $0.02
    /Max

  • By Brian Klausen, October 2, 2013 @ 00:26

    Hi Max.
    Thank you for chiming in.

    Have been along those lines, but unfortunately my case is not as simple. To be more specific, the “launcher app” (lets call it that) can launch quite a number of apps – like – a LOT. This is only and complexity issue which “just” means that people need to think when administrating – but that’s inherent in the application portfolio design – nothing WM can change here.
    But I can’t link one app to many apps – only many apps to one app (if you catch the difference).
    This could then be doable, however, quite a number of called apps, are actually also used by other users outside the context of the “caller app”.

    Basically you can think of it as a business automation and workflow tool, that calls everything in the Office-suite, a large number of homebrew apps, a bit of terminal emulation, etc. etc.
    The users of the “caller app” are around 60% of the entire landscape. So hinging something like Office – being used by nearly 100% of the users – on a different app that 40% of the users doesn’t have access to, seems like a bad idea.

    I would have liked if I could create a global user settings item, and then link user settings from the various apps to that, and filtering it accordingly. Thus ensuring that for a specific group or workspace, settings for certain apps are loaded at logon. Sadly this doesn’t seem to be possible at the moment.

    Oh – and it is a +5000 seats and several hundreds apps environment – so doubling up on configuration and filtering, etc., will be quite a nightmare (but may prove the only possibility).

    Hope this clarifies…

  • By RESguru, October 2, 2013 @ 09:29

    Hi Brian, after reading through the use case, I believe you’re right: I don’t think WM is able to do what you are after here, although it’s close. It looks like one would need access control on the linking to do what you need. In the current release you would have to create many placeholder/suite apps.

    Tell you what, I’ll bring this thread to the attention of product management and if you at the same time open a support ticket we can get some more eyeballs on it, perhaps then a solution will manifest itself. Also, if you haven’t already done so, be sure to put this in as a feature request on RES UserVoice, accessible via the support portal.

    Thanks for sharing,
    /Max

Other Links to this Post

RSS feed for comments on this post. TrackBack URI

Leave a comment

Comments are welcome as always. Just do the math below. * Time limit is exhausted. Please reload the CAPTCHA.