|
-
Apr 29th, 2010, 02:38 PM
#1
Thread Starter
Addicted Member
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
-
Apr 29th, 2010, 04:37 PM
#2
Re: System.Diagnostics.Process.Start _ from %homepath%
You should look up the "SHGetFolderPath" function.
Also, what programming language are you using, VB.Net, C#...?
-
Apr 29th, 2010, 05:11 PM
#3
Re: System.Diagnostics.Process.Start _ from %homepath%
 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%")
-
May 2nd, 2010, 06:56 PM
#4
Thread Starter
Addicted Member
Re: System.Diagnostics.Process.Start _ from %homepath%
 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!
-
May 3rd, 2010, 08:08 AM
#5
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.
-
May 3rd, 2010, 02:35 PM
#6
Thread Starter
Addicted Member
Re: System.Diagnostics.Process.Start _ from %homepath%
 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!
-
May 13th, 2010, 01:12 AM
#7
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"))
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|