Question How i can check whether application is running locally or remotely?

Developer111

Member
Joined
Apr 21, 2010
Messages
24
Programming Experience
5-10
My desktop application is developed in VB.Net and can be run through two types of users, one who install it on their local machine and execute locally.
Second type of users will run the application remotely from the server.i.e. Application will install on the server and user will execute that application from client side. Server can be a Citrix Meta Frame or any server accessed through Remote Desktop Connection
I want to maintain single exe for both types of users.

Question:

Is there any mechanism/way through which I can come to know programmatically whether application is running locally or remotely?
 
You could try using:

System.Environment.CurrentDirectory.ToString

Then making a function to determine differences in the direcotry string. E.g. local apps will most likeley have the C:\\ prefix.
 
oliverg, Thanks for reply,

Yes, current directly returns “C:\Program Files\[Application Folder]” on executing the application locally. The server which I am currently accessing has only one drive “E:\” on which application is installed so on executing my application remotely it returns “E:\Program Files\[Application Folder]”.
Plus my application can be installed on any drive and I can’t differentiate on the basis of “C:\” , “E:\” or else. Please advice.
 
Try splitting the current directory string with a backslash so that you can differentiate "E:";

"if split(directory, "\")(0) = "E:" then remote = true".

Or, try using System.Environment.OSVersion.ToString or System.Environment.MachineName.ToString to determine the servers OS.
 
oliverg, Thanks for reply again,

Infact problem is not to get the drive letter, i mean to say If user's machine also installed my application on "E:" drive then how can i differentiate between the two?

System.Environment.OSVersion.ToString
OSVersion for both client and server is/can be same.

System.Environment.MachineName.ToString
I may have hundred of users so machine name(for client and server) may also match, i am not sure that on WAN whether client and server name can be same or not. Even not, it is not seem to be an efficient approch. Please advice some thing else.
 
It wouldn't be possible to have two different drives mapped as "E:\", so as long as your server applications base is a static address, just check for that exact address.
 
I think I should explain my problem a bit more clearly.

My application in installed on Server at “C:\Program Files\BPToolkit\[Application Folder]”. Same application is installed on any client machine at “C:\Program Files\BPToolkit\[Application Folder]”.

I am using Remote Desktop Connection.

Same exe is to be maintained for client machine or server machine. When exe is launching from the server machine different things will happens as compared to local machine. Your suggested piece of code/solution will be written in the start of the application.


I login to the server thru a user “abc”. “abc” will login successfully and launch My application from the server. All “Browse” options will display only server’s drives. It implies that application running from the server has nothing to do with the local drives of client’s machine.


Now my question is how I can come to know Programmatically that exe is launching from local client machine or from server machine.?
 
Back
Top