473,320 Members | 1,904 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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

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.

Is there any mechanism/way through which I can come to know programmatically whether application is running locally or remotely?
Apr 21 '10 #1
8 4610
MrMancunian
569 Expert 512MB
Perhaps you can check for the applicationdirectory? Something like My.Application.Info.DirectoryPath...

Steven
Apr 21 '10 #2
@MrMancunian
Steven, thank for reply

Directory Path returns “C:\Program Files\[Application Folder]” either executing the application locally or remotely, which doesn't make any difference. I tried for both Citrix and Remote Desktop.

Please advice.
Apr 22 '10 #3
robjens
37
That doesnt really make sense. Why would the server side user have the same local directory structure as the one who is running it actually local?

Either way, if the appl. path won't help you, I suggest you simply set a application boolean as flag for either running local or remote. How do you know which user will run local/remote? Do you install every time they login/connect? Or keep a .xml file somewhere with this data? User setting perhaps, app.config or???

Many many options here.
Apr 23 '10 #4
Robjens, thanks for reply

I think I was unable to explain my problem specially using Remotely and locally mechanism, let me try again.

I have two types of users.

1- Who can install the application to their machine and launch it locally.
2- Second type of users has nothing install on their local machines (client)
they will login to the server and launch the program from server.

Important thing is that I have to maintain same version of program for local and server machines. So I need to check at the start of the program whether it is launched by local user or remote user? As program behave differently for local and remote launching.

Hence directory structure is same but scenarios are different.

Hope its make sense, other wise I 'll try to explain it in more detail :)
Apr 26 '10 #5
robjens
37
I am wondering, how do the local people obtain their copy of the application? In other words, how do you distribute it? Since you are the creator, you'd be in full control there. In those scenario's where you have virtual machines, the local installs would usually be automatically be ran from some kind of update manager so the network admins can control every aspect of the software package.

You already know that the remote version is the correct one right? The question is if the local installed people have a) internet connection and b) have their own workstations. That would make it a lot easier. All you would need to do is write a script that checks a remote db/file/whatever to see if they have the latest version and if not, force a upgrade on them.

Basically it's a two way street and you can go either way. Or they check with you on a server if the versions match, or you check on their workstations most probably some setup log file that you want to verify. That is also pretty easy.

If you cannot rely on them having a connection of some sort and you do not wish to disable the program completely, well that's about it then. You are officially out of options besides having to rely on "hard" media such as asking people face to face what versions they have and send CD's by regular mail....I guess you get the idea ... we don't like that and boy would the co-workers have a field day ;)


Hope I could have been of some help even though it ain't much...
May 2 '10 #6
robjens
37
And reading your post again....you say:

"As program behave differently for local and remote launching.
Hence directory structure is same but scenarios are different."

Why rely on a directory structure to do your verification when you can easily check for the version through either a txt, xml or registry key for that matter. There are literally dozens of options there.

In steps:

1) distribute the local copies and include a script for writing a version integer/string to a shared file on a network server somewhere, or have the script write to the system registry.

2) every time you distribute a package or have one ready, you write to a file version +1

3) whenever remote people connect they already have the right version

4) when a local user starts the program, get (intranet/internet) access to the shared file and if TheirVersion <> YourVersion = ForceUpdate
May 2 '10 #7
Frinavale
9,735 Expert Mod 8TB
How does the user "log into the server"?

I think that you really have 2 separate applications here.

You could use precompiler statements to build 2 different applications based on the same code. One compiled version will be tailored to be installed and run on the server and the other version will be tailored to be installed and run locally.


So say you have a function in your code that logs errors. This function, when compiled for the server, will log an error message into the Windows Event Log. When this function is compiled for the local desktop client, error will be appended to a Log.txt file.

You would have the following code for the "LogError" subroutine:
Expand|Select|Wrap|Line Numbers
  1. Public Sub LogError(ByVal errorMessage As String)
  2. #If APPLICATIONTYPE = "Server"
  3.   'Code that writes the error message to a 
  4.   'Windows Event Log called "ServerApplicationLog"
  5.  
  6.   Dim thelog As New System.Diagnostics.EventLog
  7.   Dim theSource As String = "ServerApplicationLog"
  8.   thelog.Source = theSource
  9.   'Recording the error
  10.   thelog.WriteEntry(errorMessage, Diagnostics.EventLogEntryType.Error)
  11.   thelog.Dispose()
  12. #End If
  13.  
  14. #If APPLICATIONTYPE = "Local"
  15.   'Code that writes the error message to a TXT file
  16.   'called "clientLog.txt" that exists in the application's startup path.
  17.  
  18.  Dim logFilePath As String = Application.StartupPath + "\clientLog.txt" 
  19.   Using outfile As New StreamWriter(logFilePath)
  20.     outfile.Write(errorMessage)
  21.   End Using
  22. #End If
  23. End Sub
You would define the APPLICATIONTYPE variable by adding it the "Custom Constraints" in the Advanced Compiler Settings for your application.
To do this:
  • Right click on your project name in the Solution Explorer and click Properties
  • Click the Compiler tab/button
  • Click the "Advanced Compile Options..." button
  • In the Custom Constraints text box type: APPLICATIONTYPE = "ServerApplicationLog" if you are compiling the application for the server...otherwise type APPLICATIONTYPE = "Local"
  • Click the Ok button
  • Build your application

-Frinny
May 4 '10 #8
Thanks Frinavale and robjens...I am already aproaching some workarounds...
May 10 '10 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Scott | last post by:
I have been told that the only way to develop an ASP.NET application is to do it on the localhost, and then just copy the files out to the web server that will be hosting. Is this true? ...
0
by: faktujaa | last post by:
Hi, I have created an application that uses IIS to host remote components. All the remote components are listed in app.config in client and web.config in server. Now the app.config can contain...
2
by: faktujaa | last post by:
Hi, I have created an application that uses IIS to host remote components. All the remote components are listed in app.config in client and web.config in server. Now the app.config can contain...
2
by: Evan Camilleri | last post by:
how can I create a web application remotely? i have access to a server and would like to create a web-application in a folder - if it is my IIS then i right click, properties and press create...
3
by: Wayne Gibson | last post by:
Hi, Is it possible to determine what web server is running a website, if so how? Also is it possible to determine if the web site is running locally or remotely. Thanks Wayne
5
by: Lara | last post by:
Hi, I am getting the following error. All the files are stored in a directory named 'web' as told by the Server Administrtor can anyone help me Server Error in '/' Application....
1
by: Zachariah | last post by:
I created a Windows Service and part of its functionality is to move a PDF file from a location on the service's local drive stInPath (C:\PDF\) to a location on another server stOutPath...
1
by: lauralucas | last post by:
Hello I'm using ASP.NET 1.1, Visual Studio 2003, IIS 5.1 and windows XP as development machine. I can work in this machine locally and create web apps that I can access via localhost. No problem...
0
by: sunrt | last post by:
We have an As400 system that has program which executes batch files which resides on the SQL server 7.0 computer . Those batch files run SQL server jobs using isql. The whole idea about this is...
0
by: tamayi | last post by:
I have a problem (like most others posting issues on this forum :) ) I have a remote server running Windows XP SP2, with both SQL Server 2005 Express with Advanced Features and SQL 2000...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.