あなたはリンゴをオレンジと比較していますが、あなたの場合は、引用符と剥奪引用符を比較しています。あなたの.nsiのパラメータに
最も外側の引用符を使用すると、上の変数に文字列を読めばそう
StrCpy $0 "Hello World"
MessageBox mb_ok $0
が、しかし
StrCpy $0 "Hello World"
MessageBox mb_ok "$0"
と全く同じであるコンパイラによって除去されますユーザーのマシンでは引用符は削除されません。
StrCpy $0 '"Hello World"' ; Pretending that we read "Hello World" (with quotes) from somewhere
MessageBox mb_ok $0
dif解決策はNSIS forumです。ここでは、関数のそのタイプの私の感想は次のとおりです。
!define PathUnquoteSpaces '!insertmacro PathUnquoteSpaces '
Function PathUnquoteSpaces
Exch $0
Push $1
StrCpy $1 $0 1
StrCmp $1 '"' 0 ret
StrCpy $1 $0 "" -1
StrCmp $1 '"' 0 ret
StrCpy $0 $0 -1 1
ret:
Pop $1
Exch $0
FunctionEnd
!macro PathUnquoteSpaces var
Push ${var}
Call PathUnquoteSpaces
Pop ${var}
!macroend
Section
!macro Test path
StrCpy $0 '${Path}'
StrCpy $1 $0
${PathUnquoteSpaces} $0
DetailPrint |$1|->|$0|
!macroend
!insertmacro Test 'c:\foo'
!insertmacro Test 'c:\foo bar'
!insertmacro Test '"c:\foo"'
!insertmacro Test '"c:\foo bar"'
SectionEnd
あなたのコードは、あなたの.nsiに私の機能をコピーした後、このようになります。
ReadRegStr $uninstallPath HKLM "Sofware\...\YourAppUninstKey" "UninstallString"
${PathUnquoteSpaces} $uninstallPath
CopyFiles $uninstallPath "C:\Temp"
をあなたがそのあなたの」気にする必要はありません。引数$ uninstallPathをスペースを含む可能性があるが引用符で囲まれていないCopyFilesに渡しますか? 引用符が必要ない場合は、レジストリに格納されているパスを囲んで削除するのが一般的な理由は何ですか? – user870130
変数に空白が含まれていても変数を引用する必要はなく、コンパイラがスクリプトの関数に渡したパラメータを解析した後に、エンドユーザーのマシンで拡張されます。実行可能なコマンドは、レジストリに格納されたときに引用符で囲まれなければならず、アイコンや他のファイルのような他のパスは通常引用符で囲まれません。以下も参照してください。https://blogs.msdn.microsoft.com/oldnewthing/20070515-00/?p=26863 – Anders
コードに軽微な問題があることに気付きました。最初のStrCpyはStrCpy $ 1 $ 0です。 – user870130