0
我正在使用批量中的程序轻松设置您的IP设置,但出现错误。其中有变量的批量变量
这是造成问题的原因:
for /f "usebackq tokens=3* skip=2" %%D IN (`reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Desktop`) do set desktop=%%D
因此,这提供了一个错误:
powershell "$s=(New-Object -COM WScript.Shell).CreateShortcut('%desktop%\IP Configurator.lnk');$s.TargetPath='%0';$s.IconLocation = 'C:\Windows\System32\Shell32.dll,273';$s.Save();$bytes = [System.IO.File]::ReadAllBytes('%desktop%\IP Configurator.lnk');$bytes[0x15] = $bytes[0x15] -bor 0x20;[System.IO.File]::WriteAllBytes('%desktop%\IP Configurator.lnk', $bytes);Write-Output 'Shortcut created (or there was an error), press a key to continue'"
但它输出这个错误,这会导致多个错误,因为它:
Unable to save shortcut "C:\Users\Ryan\Desktop\programs\IP_Configurator\%USERPROFILE%\Desktop\IP Configurator.lnk".
At line:1 char:235
+ ... conLocation = 'C:\Windows\System32\Shell32.dll,273';$s.Save();$bytes ...
+ ~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], DirectoryNotFoundException
+ FullyQualifiedErrorId : System.IO.DirectoryNotFoundException
我不明白的是,它没有得到正确的桌面,我认为这是因为它不是交流通过计算%USERPROFILE%
是什么,只是从字面上用变量名和括号。我怎么才能知道变量值是什么?
的路径'C治愈你的问题:\用户\瑞安\桌面\程序\ IP_Configurator \%USERPROFILE%\桌面\ IP Configurator.lnk'不存在;请注意'%USERPROFILE%'包含完整路径,因此它展开为'C:\ Users \ Ryan \ Desktop \ programs \ IP_Configurator \ C:\ Users \ Ryan \ Desktop \ IP Configurator.lnk' ... – aschipfl
我知道那我只是不知道为什么它不扩大 –