How to persistently set a variable in Windows 7 from a batch file?

前端 未结 7 1186
無奈伤痛
無奈伤痛 2020-12-02 08:38

I am trying to set the PATH environment variable in windows 7 using a bat-file; however it does not seem to work.

I am using this windows command:

se         


        
7条回答
  •  情歌与酒
    2020-12-02 09:14

    A simple (may be better) solution is to use PathMgr.cmd

    Down the pathmgr_1.0.2.zip in https://gallery.technet.microsoft.com/Batch-Script-To-Manage-7d0ef21e

    Unzip and put the pathmgr.cmd in the same folder as your batch file, then in your batch file write these two lines:

    call pathmgr.cmd /del %cd% /y
    call pathmgr.cmd /add %cd% /y
    

    This will:

    1) only update the user variable PATH, 2) will not include system PATH multiple times

    You can also run the batch file multiple times, and it will only include your current path ONCE in the PATH.

提交回复
热议问题