![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-09-26 03:38 |
47,813 topics / 349,918 posts / today 0 new / 48,275 members |
| DOS批处理 & 脚本技术(批处理室) » [Closed] How to modify the system path environment variable with batch processing |
| Printable Version 22,898 / 31 |
| Floor16 ihouge | Posted 2007-04-06 13:37 |
| 初级用户 Posts 10 Credits 20 | |
|
The information I've been searching for for a long time has finally started to come to light. The internet is really great.
|
|
| Floor17 elick | Posted 2007-07-05 14:53 |
| 新手上路 Posts 1 Credits 2 | |
| Floor18 next45 | Posted 2007-09-17 16:18 |
| 新手上路 Posts 1 Credits 2 | |
|
I'm sorry! I'm a newbie! I plan to create a batch file. It needs to add J:\Lotus\Notes\Data to the current PATH. Is there any senior brother to help?
From J:\Domino\Data;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Support Tools\;C:\Program Files\QuickTime\QTSystem\ To J:\Domino\Data;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\Support Tools\;C:\Program Files\QuickTime\QTSystem\;J:\Lotus\Notes\Data |
|
| Floor19 ddosdos | Posted 2007-12-01 22:04 |
| 新手上路 Posts 1 Credits 2 | |
|
Good
|
|
| Floor20 HAT | Posted 2007-12-02 01:38 |
| 版主 Posts 5,017 Credits 9,023 | |
Originally posted by next45 at 2007-9-17 04:18 PM: |
|
| Floor21 81291895 | Posted 2007-12-04 01:09 |
| 初级用户 Posts 17 Credits 42 | |
|
```
@echo off Set /p Paths=Enter the "Path" path you want to add, separate multiple paths with ";" : Set Regfile=HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment For /f "tokens=3" %%i in ('Reg Query "%Regfile%" /v path^|Find /i "REG_EXPAND_SZ"') Do Set Pathf=%%i Reg add "%Regfile%" /v path /t REG_EXPAND_SZ /d %Pathf%;%Paths% /f>nul ``` |
|
| Floor22 bobo2007 | Posted 2008-03-11 18:39 |
| 新手上路 Posts 1 Credits 2 | |
| Floor23 axuan | Posted 2008-05-26 13:57 |
| 初级用户 Posts 20 Credits 44 | |
| Floor24 dato | Posted 2008-05-26 15:36 |
| 高级用户 Posts 377 Credits 916 | |
|
Hey, in Java teaching, there are always people who mess up the path system variable, which causes many program loading problems. But after looking at setx for a long time, I find that it only has the replace function and no append function, which makes it a bit troublesome.
|
|
| Floor25 soliton | Posted 2008-07-04 19:51 |
| 新手上路 Posts 1 Credits 2 | |
|
I'm also working on this problem and want to try setx. I've modified the environment variables with wimc but they can't take effect immediately.
|
|
| Floor26 HAT | Posted 2008-07-04 20:56 |
| 版主 Posts 5,017 Credits 9,023 | |
|
Modifying environment variables with wmic can take effect immediately. Did you write the command incorrectly? Post it and let's see?
|
|
| Floor27 ywwywwjm | Posted 2008-07-06 16:04 |
| 初级用户 Posts 13 Credits 42 | |
|
1. Use pathman
pathman /rs "c:\123" pathman /as "C:\WINDOWS\system32\qqq" pathman /as J:\Lotus\Notes\Data 2. Use WMIC WMIC /PRIVILEGES:ENABLE ENVIRONMENT where name='PATH' set VariableValue="%PATH%;J:\Lotus\Notes\Data" |
|
| Floor28 afu35 | Posted 2008-10-22 08:29 |
| 新手上路 Posts 1 Credits 1 | |
|
I used to use reg add/delete to modify the registry (in bat scripts) to add or delete environment variables before, but I found that after adding them, they don't take effect immediately and I need to restart the OS. I wonder if there is a way without restarting the OS.
|
|
| Floor29 HAT | Posted 2008-10-22 09:48 |
| 版主 Posts 5,017 Credits 9,023 | |
|
```
wmic ENVIRONMENT where "name='path' and username='<system>'" set VariableValue="%path%;C:\test" ``` |
|
| Floor30 tireless | Posted 2008-10-22 09:54 |
| 银牌会员 Posts 1,122 Credits 2,025 | |
I used to use reg add/delete to modify the registry (in a bat script) to add or delete environment variables, but I found that after adding them, they don't take effect immediately and require a system restart. I wonder if there is a method that doesn't require restarting the OS. You can use the command-line tool NirCmd to refresh the environment variables: NirCmd sysrefresh environment Or use a tool to modify environment variables, such as pathman http://upload.cn-dos.net/img/989.rar |
|
| Prev 1 2 3 Next |
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |