[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More


Change IsOutlookSignature in a Citrix / Terminal Server environment

Published on
15,216 Points
1 Endorsement
Last Modified:
This is an addendum to the following article:

Acitve Directory based Outlook Signature

The script is fine, and works in normal client-server domains.

If you want to use the script on a Citrix or Terminal Services server, the IsOutlookFunction stops if anyone on the server has Outlook running.  In this case, you want to check only if Outlook is running for the current user:

I changed the code as follows:

Function IsOutlookRunning()
	strComputer = "."
	strQuery = "Select * from Win32_Process " & _
	"Where Name = 'OUTLOOK.EXE'"
	Set objWMIService = GetObject("winmgmts:" _
	& "{impersonationLevel=impersonate}!\\" _
	& strComputer & "\root\cimv2")
	Set colProcesses = objWMIService.ExecQuery(strQuery)
	For Each objProcess In colProcesses

=>	    colProperties = objProcess.GetOwner(strNameOfUser,strUserDomain)
		If UCase(objProcess.Name) = "OUTLOOK.EXE" Then
=>		    If objSysInfo.Username = strNameOfUser Then		                             IsOutlookRunning = True
=>		   Else
=>		        IsOutlookRunning = False
=>		    End if
			IsOutlookRunning = False
		End If
End Function

Open in new window

This script checks for a running "Outlook.exe" process for the current user.

I found the code that I added from the Question/Answer "Hey, Scripting Guy! Blog" website.

Most of the time Google is your friend in finding the right code--you only have to know how to incorporate it into you're own scripts.

I used the GetOwner method, which returns two variables--one that returns the name of the user who 'owns'  the process, and another that returns the domain that the user belongs to.  We do not need the domain, so I left it alone.  In my script above, I used variables named "strUserName" and "strUserDomain".  These names are not important--you can call the variables "A" and "B", or "X" and "Y", or anything you want--however, a descriptive name is preferable.

Each "Outlook.exe" process is examined to see if the owner is the current user.  When the owner is the current user, we will use IsOutlookRunning to check if Outlook is running.  If it is running, IsOutlookRunning returns TRUE.  In all other cases, where Outlook is not running, or all Outlook processes are owned by other users, IsOutlookRunning returns FALSE.

I hope this code is useful for people who want to use an automated signature with Outlook on Terminal Services or Citrix servers.

Of course, this method may be used in many other cases where you want to know the owner of a process.

Kind regards,

Carlo van Orsouw
Princen Group
The Netherlands
1 Comment
LVL 56

Expert Comment

by:Mark Wills
Good Tip ! Thanks, will keep this one handy...

Featured Post

Learn Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Basic Overview of office 365 user portal
See the Basics of Office 365's Note Taking app, OneNote

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month