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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

determining windows server app path

Status
Not open for further replies.

phbrady

Programmer
Oct 17, 2003
41
0
0
US
I am writing a windows service and I can't find the equivalent of Application.ExecutablePath. How do I determine the path? Also, I'm trying to pass an argument using the following code:

Protected Overrides Sub OnStart(ByVal args() As String)
dim myArg as string
myArg = args(0)

When I try to do this, the app errors out as if it's not getting the argument. I'm passing it by setting it as a parameter of the service in the Options window. Is this the correct way to pass an argument to the service?
 
Not sure on the path off the top of my head, but for the arguments, look for Environment.Arguments instead. It should return a string array with the app name(0) and arguements(1+).

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Thanks!

You were close, actually it was environment.getCommandLineArgs. The first arg is the app name and includes the path.
I still don't know how to pass an argument, though - I tried setting one in the parameters property of the service but it didn't show up in the commandline arguments.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top