IP ayarlarınızı kolayca ayarlamak için Batch uygulamasında bir program yapıyorum, ancak bir hata alıyorum. İçindeki değişkenle birlikte değişken değişken
Bu
soruna neden olan: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
Yani bu bir hata sağlamaktadır:
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'"
Ama yüzünden birden hatalara yol açar bu hatayı üretmektedir:
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
Elde edemediğim şey, masaüstünü düzgün bir şekilde almaması ve sanırım bunun bir AC değil. %USERPROFILE%
'un neyini hesaplar ve sadece değişken adını parantez ile kullanır. Değişken değerin ne olduğunu okumak için nasıl alabilirim?
yol 'C gidererek sorunu tedavi edilmelidir: \ Users Ryan \ Desktop \ lisansı \ \ IP_Configurator \% USERPROFILE% \ Desktop \ IP Configurator.lnk' yok; '% USERPROFILE%' ifadesinin tam bir yol içerdiğini, dolayısıyla 'C: \ Users \ Ryan \ Desktop \ program \ IP_Configurator \ C: \ Users \ Ryan \ Desktop \ IP Configurator.lnk' ...' ne genişlediğini unutmayın. – aschipfl
Bu sadece neden genişlemediğini bilmiyordum –