<

Go Premium for a chance to win a PS4. Enter to Win

x

Change IsOutlookSignature in a Citrix / Terminal Server environment

Published on
14,972 Points
5,372 Views
1 Endorsement
Last Modified:
Awarded
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
		Else
			IsOutlookRunning = False
		End If
	Next
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
1 Comment
 
LVL 51

Expert Comment

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

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Join & Write a Comment

This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month