- PR -

Dr Watson's % % argument

1
投稿者投稿内容
Oregon
ベテラン
会議室デビュー日: 2001/08/01
投稿数: 52
お住まい・勤務地: Tualatin 97062
投稿日時: 2001-09-28 00:40
how can I pass a string that includes '%'?
e.g. need to set "drwtsn32 -p %ld -e %ld -g" at an application.
a simple approach as below fails because w2k thinks '%' special:

hoge.bat
コード:
@echo off
call :regedit_dummy "drwtsn32 -p %%ld -e %%ld g"
goto  :eof

:regedit_dummy
echo %*
goto :eof


produces a wierd result
コード:
C:> hoge.bat
"drwtsn32 -p ld g"



Oregon
ベテラン
会議室デビュー日: 2001/08/01
投稿数: 52
お住まい・勤務地: Tualatin 97062
投稿日時: 2001-10-06 01:20
a solution is:
コード:
@echo off
setlocal
set args=drwtsn32 -p %%ld -e %%ld g
call :regedit_dummy
endlocal
goto  :eof

:regedit_dummy
echo %* %args%
goto :eof


this outputs: drwtsn32 -p %ld -e %ld g
at a sacrifice of global pollution
but that's would be a small price.

what then is a next question:
how can I pass a string that includes '!'?

コード:
@echo off
call :say Hello! and World! for me
endlocal
goto  :eof

:say
echo %*
goto :eof



this produces:
Hello for me

1

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