Change IsOutlookSignature in a Citrix / Terminal Server environment

Published on
15,021 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 52

Expert Comment

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

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

Join & Write a Comment

In this video I will demonstrate how to set up Nine, which I now consider the best alternative email app to Touchdown.
The video will let you know the exact process to import OST/PST files to the cloud based Office 365 mailboxes. Using Kernel Import PST to Office 365 tool, one can quickly import numerous OST/PST files to Office 365. Besides this, the tool also comes…
Suggested Courses
Course of the Month3 days, 5 hours left to enroll

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month