guys.
i am writing an application that needs to add my application's path to the PATH variable..is there any way to do it in VB???
thnx
nean
Printable View
guys.
i am writing an application that needs to add my application's path to the PATH variable..is there any way to do it in VB???
thnx
nean
What do you mean by 'path variable'? App.Path ?
why do you have to do that?
modern day computers don't use the path variable like in the DOS days.
We have shortcuts, and can click on a folder to change to it, so it's really not necessary. If every program used the path variable, it would grow too big.
no i mean the PATH environment variable in windows..
becaus i need to put my application path in PATH variable so that next time i can execute my application from the command prompt..Quote:
why do you have to do that?
guys got any ideas??? :rolleyes:
Checkout this thread:
http://www.vbforums.com/showthread.php?t=61438
It demonstrates a way to set environment variables such as PATH. So (in theory anyway) you should be able to add your app's path to that.
Hope that helps.
system properties -> environmental variables -> path
as you will see, there are only 4 or 5 things there. every other app does it without editing the path. maybe you want to put a batch file, (or a command/cmd file) to start off your program. that way you can run it from the start menu.
enter this in Notepad, and save it with your c:\appname.cmd
VB Code:
cd \myapp runmyapp.exe cd\
that way you can type the appname to start from any folder. :wave:
But neanthedral wants to be able to run his app from a command prompt (don't ask me why) and your suggestion will only work from the command line if appname.cmd can be found in the current PATH.Quote:
Originally Posted by dglienna
Sorry, I meant to place it at the root level of your hard drive. this is in the path. anywhere in the path would be OK. you can get the path by typing path at the command prompt
hey i saw that thread..there they have said that we can do it using registry...
how do we do that???
The PATH environment is stored in the registry here:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
So I guess you could modify it that way.
export the hive before you attempt to change it. if you do it wrong, your system will be unusable.
Good advice :thumb:Quote:
Originally Posted by dglienna
now u are confusing me... :confused:Quote:
export the hive before you attempt to change it. if you do it wrong, your system will be unusable.
hive??export??
how do i do that???
and how do i change the registry ?? should i use regedit or is there some vb method for this??
n y will my system become unstable??
you can use regedit. find the hive (where the key is located) and click export to save a copy of it. whether or not you manage to do what you want, you will always have a way to get back your system, although you would have trouble doing it. safemode would be involved, and it would not be pretty if the system wouldn't start.
it you want, you can also use VB to change the registry. this carries more risks, as you may eventually make the path too big, as I implied before.
I still suggest you use a different method. if you are distributing your program, your users may not like it if you change their path, and they may have software on their system that may not allow it to be changed.
but, at least you were warned.
it is taking me time to get what u were saying..
but i think i understand u.. :thumb:
thanks
nean
I hope that I helped you not harm your system. :wave: