Results 1 to 17 of 17

Thread: [Resolved]how to change path variable

  1. #1

    Thread Starter
    Member neanthedral's Avatar
    Join Date
    Dec 2004
    Posts
    57

    Resolved [Resolved]how to change path variable

    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
    Last edited by neanthedral; Feb 11th, 2005 at 02:18 AM. Reason: resolved
    ------------------------------------------------------
    "i am neither a psycopath nor ur abnormal demi-god;
    me - i am just an average software engineer...which is far worse ..so beware.. " .NeaNthedraL
    ------------------------------------------------------

  2. #2
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: how to change path variable

    What do you mean by 'path variable'? App.Path ?

  3. #3
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: how to change path variable

    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.

  4. #4

    Thread Starter
    Member neanthedral's Avatar
    Join Date
    Dec 2004
    Posts
    57

    Re: how to change path variable

    no i mean the PATH environment variable in windows..
    why do you have to do that?
    becaus i need to put my application path in PATH variable so that next time i can execute my application from the command prompt..
    ------------------------------------------------------
    "i am neither a psycopath nor ur abnormal demi-god;
    me - i am just an average software engineer...which is far worse ..so beware.. " .NeaNthedraL
    ------------------------------------------------------

  5. #5

    Thread Starter
    Member neanthedral's Avatar
    Join Date
    Dec 2004
    Posts
    57

    Unhappy Re: how to change path variable

    guys got any ideas???
    ------------------------------------------------------
    "i am neither a psycopath nor ur abnormal demi-god;
    me - i am just an average software engineer...which is far worse ..so beware.. " .NeaNthedraL
    ------------------------------------------------------

  6. #6
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,918

    Re: how to change path variable

    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.
    Pete

    No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.

  7. #7
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: how to change path variable

    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:
    1. cd \myapp
    2. runmyapp.exe
    3. cd\

    that way you can type the appname to start from any folder.
    Last edited by dglienna; Feb 11th, 2005 at 12:56 AM.

  8. #8
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,918

    Re: how to change path variable

    Quote Originally Posted by dglienna
    that way you can type the appname to start from any folder.
    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.
    Pete

    No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.

  9. #9
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: how to change path variable

    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

  10. #10

    Thread Starter
    Member neanthedral's Avatar
    Join Date
    Dec 2004
    Posts
    57

    Re: how to change path variable

    hey i saw that thread..there they have said that we can do it using registry...
    how do we do that???
    ------------------------------------------------------
    "i am neither a psycopath nor ur abnormal demi-god;
    me - i am just an average software engineer...which is far worse ..so beware.. " .NeaNthedraL
    ------------------------------------------------------

  11. #11
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,918

    Re: how to change path variable

    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.
    Pete

    No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.

  12. #12
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: how to change path variable

    export the hive before you attempt to change it. if you do it wrong, your system will be unusable.

  13. #13
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,918

    Re: how to change path variable

    Quote Originally Posted by dglienna
    export the hive before you attempt to change it. if you do it wrong, your system will be unusable.
    Good advice
    Pete

    No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.

  14. #14

    Thread Starter
    Member neanthedral's Avatar
    Join Date
    Dec 2004
    Posts
    57

    Re: how to change path variable

    export the hive before you attempt to change it. if you do it wrong, your system will be unusable.
    now u are confusing me...
    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??
    ------------------------------------------------------
    "i am neither a psycopath nor ur abnormal demi-god;
    me - i am just an average software engineer...which is far worse ..so beware.. " .NeaNthedraL
    ------------------------------------------------------

  15. #15
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: how to change path variable

    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.

  16. #16

    Thread Starter
    Member neanthedral's Avatar
    Join Date
    Dec 2004
    Posts
    57

    Re: how to change path variable

    it is taking me time to get what u were saying..
    but i think i understand u..
    thanks

    nean
    ------------------------------------------------------
    "i am neither a psycopath nor ur abnormal demi-god;
    me - i am just an average software engineer...which is far worse ..so beware.. " .NeaNthedraL
    ------------------------------------------------------

  17. #17
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: [Resolved]how to change path variable

    I hope that I helped you not harm your system.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width