Running programs/scripts as a logged in user in a LabTech/Automate Script

2018-11-06T02:41:36+00:00January 16th, 2018|

Two of the questions that we get asked often in the LabTech Geek Slack are usually phrased like this:

  1. I am trying to map a drive/delete a desktop icon/edit the registry for a user in a script and it is not working
  2. How do I run things on the user desktop?

The reason number 1 doesn’t work is because the LabTech/Automate Agent Service that runs on each machine almost always is running as SYSTEM – giving it open access to pretty much everything on the machine. SYSTEM is king. In many ways, SYSTEM is like a user – if Bob logged on to a machine and had a mapped drive of M:, and Mary logged on to the same machine and had a network drive of F:, you wouldn’t expect to be able to map a drive for Mary when logged on a Bob; it’s the same concept here. When you map a drive as SYSTEM (IE from within a LabTech/Automate Script) it maps the drive under the context of the SYSTEM “User”.

There are a number of methods built in to LabTech/Automate to help facilitate you in doing many things for the currently logged on user, at it’s most basic you use the function IS USER LOGGED IN to expose a variable called %consolenumber% – this can then be used in numerous other script functions to execute things in the context of the logged in user.

Instead of going through them in depth in this blog post, I have put all of these actions into a script and added a heavy amount of notes. It is available here:

For those who just love a good screenshot, here is the script:



  1. Tim Wiser 24th January 2018 at 9:51 am - Reply

    Another trick is to use a REG ADD against HKLM which inserts a command into HKLM\Software\Microsoft\Windows\CurrentVersion\Run which will run a command or script (which needs to be written to a file locally or exist within the single Reg key) each and every time any user logs on.
    A ‘cleaner’ way to achieve a similar result but only have the command execute once is to look at Active Setup. Great for single, one-hit tasks. Active Setup is the thing that appear/appeaed when you logged into older versions of Windows and displayed messages in a box at the top left corner of the screen.

  2. latinamericancupid 30th August 2018 at 1:32 pm - Reply

    This piece of writing is truly a good one it helps new net
    visitors, who are wishing in favor of blogging.

  3. bed shops in Shipley West Yorkshire 23rd November 2018 at 3:18 am - Reply

    Thank you ffor the blog post. Jones and I are actually
    saving for just a new guide on this issue aand your writing has made us all to save all
    of our money. Your thoughts really resolved all our questions.
    In fact, in excess of what we had thhought of ahead of the time we came upon your great blog.
    I noo longer nurture doubts annd a troubled minjd because you have totally
    attended to the needs right here. Thanks

Leave A Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.