- PR -

%~$PATH:1 mystery

1
投稿者投稿内容
Oregon
ベテラン
会議室デビュー日: 2001/08/01
投稿数: 52
お住まい・勤務地: Tualatin 97062
投稿日時: 2001-08-11 04:48
suppose we have a PATH:
コード:

PATH=C:\WINNT\system32;C:\WINNT;C:\Program Files


and there is a folder, say "FreeAmp", under "C:\Program Files" then the script:
コード:

@echo off
if %~$PATH:1.==. echo HOGE


fails when used with an arg "FreeAmp"
コード:

C:\> hoge.bat "FreeAmp"
Files\FreeAmp.==. was unexpected at this time.



WHY?

if FreeAmp.EXE in stead is used,
everything goes dandy.


Oregon
ベテラン
会議室デビュー日: 2001/08/01
投稿数: 52
お住まい・勤務地: Tualatin 97062
投稿日時: 2001-08-19 04:52
it turned out that
%~1 is space separated folder savvy,
but %~$PATH:1 isn't.
so we need old trick of "" protector:

if "%~$PATH:1"=="" ...
1

スキルアップ/キャリアアップ(JOB@IT)