Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GetprocessByName on Citrix returning all users processes.

Status
Not open for further replies.

hspoulsen

IS-IT--Management
Dec 13, 2001
11
DK
I'm using GetProcessByName to try to figure out if another program is already running on the users pc.
It works; I can see if "client.exe" is running, and if not, I can start it.

I now have a client that is using Citrix. Here my call to GetProcessByName is listing for all users connected to the Citrix Metaframe. "Client.exe" is therefore running, but not in the session that my program is running. And my program forgets to start the exe.

How do I solve this?

TIA
Henrik Staun Poulsen
Denmark
 
There might be a way that you can find out who ran the process by checking the [tt]proc.StartInfo.EnvironmentVariables[/tt]
Code:
[ "USERNAME" ]
.

[tt].EnvironmentVariables[/tt] returns a [tt]StringDictionary[/tt] of the environment of the process. The [tt]USERNAME[/tt] environment variable should give you the name of the user who started the process. (The only question is if you'll be able to get at the environment on a remote machine. Hopefully you can!)
 
I had similar projects and I applied the following soluton .
The solution is to have an application running as a service on the end-user PCs.
Let name it "appremoteservice.exe" and your application "appclient.exe".
The "appremoteserice.exe" will listen on a given port for clients to connect e.g. "appclient.exe" application which want to know if other applications ("client.exe") are running or not on that machine where is running the service.
Use Socket ,TcpClient System.ServiceProcess.ServiceBase and EventArgs classes to implement the service and your appclient.exe.
To encrypt/decrypt messages send between appclient.exe and appremoteservice.exe use
ICryptoTransform, RijndaelManaged, TripleDESCryptoServiceProvider and CryptoStream classes.
The "appclient.exe" will delegate the "appremoteservice.exe" to start the "client.exe" on that machine if it is not running Using the Process class.
The "appremoteservice.exe" will push the information about "client.exe" into a databse stored somwhere.
The "appclient.exe" connects to this database and shows info about "client.exe" on all machines where "appremoteservice.exe" was deployed.
The user checkbox each machine on which he desires to start "client.exe" and this information is send as encrypted string to the "appremoteservice.exe" on each machine.
Upon receiving this message the "appremoteservice.exe" starts the "client.exe" on that machine and updates the database.

Note.
Using a service you can control almost all processes running on the machine where the service is running.
-obislavu-
 
rosenk,

It looks like a good approach, but it returns my name instead of the real user that I can see in Task Manager.

obislavu, the problem is the "...if it is not running ...".
How do I determine this when using Citrix?

I hope that you have further suggestions, as I at a loss on what to do here.
Kind regards

Henrik Staun Poulsen
Denmark
 
If you can, write a quick test that shows you all of the items in the [tt]EnvironmentVariables[/tt] dictionary. There's a good chance that one of them can help you out. If not there might be a way using WSH to get more information about the process, but I don't actually know how offhand.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top