- - PR -
a script to delete a bogus path
1
| 投稿者 | 投稿内容 | ||||||||
|---|---|---|---|---|---|---|---|---|---|
|
投稿日時: 2001-08-09 03:35
sample
an implementation:
easy to change it to "insert a path at..." | ||||||||
|
投稿日時: 2001-08-09 11:45
Hi Oregon,
Do you like this script? :-) ------------------------------- @echo off set PATH=!PATH:;%~1;=;! set PATH=!PATH:;%~1=;! [ メッセージ編集済み 編集者: yamachan 編集日時 2001-08-09 11:48 ] | ||||||||
|
投稿日時: 2001-08-10 01:34
nice try, but pain starts here.
the %var:xxx=yyy% trick fails for space separated folder names: (C:\Program Files\)
it deleted only %1 portion of "Bogus" and "Another Bogus" folders with PATH being left imcomplete. in addition arg quoting also fail:
notice ";;" was left in the midst. | ||||||||
|
投稿日時: 2001-08-10 11:36
Hi Oregon, Thanks!
Yes, it needs quoting for space separated folder names. That's why I used "%~1", not "%1". :-) About another problem, I have no idea. I found a bug, but I think it wasn't the cause of the ";;" problem. Anyway, the following code looks working fine in my environment. CMD's option is "/f:on /v:on" ------------------------------- @echo off set PATH=!PATH:;%~1;=;! set PATH=!PATH:;%~1=! | ||||||||
|
投稿日時: 2001-08-11 02:16
the last line of your code really bothers me.
because it's not guarded by ";" delimiter. the open ended pattern like this would cause a diaster: e.g. suppose we try to remove "C:\WINNT" from PATH=C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem the result is: C:\WINNT\system32;\System32\Wbem another thing is that the two lines for middle ones and the last one in the path but the very first one. to be constuctive, and since I really like the yamachan's idea, how about putting the ";" guards around? [1] prepend/append ";" to PATH [2] prepend/append ";" to the BOGUS path [3] use %var:a=b% to replace [2] out of [1] [4] remove ";" guards from [3]
| ||||||||
|
投稿日時: 2001-08-17 15:20
Hi Oregon,
Sorry for my slow response. This week is a big vacation season in Japan, and I was off-lined. :-) "prepend/append" solution is cool! Your code looks fine. I updated it just to suit my taste. :-) ------------------------------------- @echo off set PATH=;%PATH%; set PATH=!PATH:;%~1;=;! set PATH=%PATH:~1,-1% | ||||||||
1
