System.Diagnostics.Process.Start _ from %homepath%
Hello all,
I am trying to execute .bat files from a location that can be modified by all users so have chosen the %homepath% dir, but have thus far been unable to find a way to launch the .bat from this location any help???
Looking for something to the effect of this:
System.Diagnostics.Process.Start _
("%homepath%\batlaunch\meditech.bat")
Version 2008
Any help greatly appreciated!!
Chad
Re: System.Diagnostics.Process.Start _ from %homepath%
You should look up the "SHGetFolderPath" function.
Also, what programming language are you using, VB.Net, C#...?
Re: System.Diagnostics.Process.Start _ from %homepath%
Quote:
Originally Posted by
baja_yu
You should look up the "SHGetFolderPath" function.
In VB6 maybe but in .NET its easier to just use Environment.ExpandEnvironmentVariables like so:
vb.net Code:
Environment.ExpandEnvironmentVariables("%HOMEPATH%")
Re: System.Diagnostics.Process.Start _ from %homepath%
Quote:
Originally Posted by
chris128
In VB6 maybe but in .NET its easier to just use Environment.ExpandEnvironmentVariables like so:
vb.net Code:
Environment.ExpandEnvironmentVariables("%HOMEPATH%")
Using Visual Basic 2008 Express Edition
Been googling the ExpandEnvironmentVariables command, but not had much success. How can input the executable path into a button to launch an application in the User directory using this command? How do I orchestrate this, got this so far :)
Environment.ExpandEnvironmentVariables("%HOMEPATH%")
System.Diagnostics.Process.Start _
("%homepath%\batlaunch\meditech.bat")
Also, what area of the form would I place that ExpandEnvironment command?
Thanks!
Re: System.Diagnostics.Process.Start _ from %homepath%
you have to integrate the ExpandEnvironmentVariables into your file path like so:
Code:
System.Diagnostics.Process.Start(Environment.ExpandEnvironmentVariables("%HOMEPATH%") & "\batlaunch\meditech.bat")
but you should really also use IO.Path.Combine to combine two paths, as I dont know if your HOMEPATH variable will already have the "\" at the end of it.
Re: System.Diagnostics.Process.Start _ from %homepath%
Quote:
Originally Posted by
chris128
you have to integrate the ExpandEnvironmentVariables into your file path like so:
Code:
System.Diagnostics.Process.Start(Environment.ExpandEnvironmentVariables("%HOMEPATH%") & "\batlaunch\meditech.bat")
but you should really also use IO.Path.Combine to combine two paths, as I dont know if your HOMEPATH variable will already have the "\" at the end of it.
Works like a charm!! Thanks so much!
Re: System.Diagnostics.Process.Start _ from %homepath%
You would more likely do it like this:
Code:
System.Diagnostics.Process.Start(Environment.ExpandEnvironmentVariables("%HOMEPATH%\batlaunch\meditech.bat"))