英文:
Add reg file located in a subfolder with spaces in his name
问题
Hello i am trying to execute a reg file (with spaces in his name) located in a subfolder named : "Remove Extra Folders from Windows 10 This PC".
My actual script is :
reg import $PSScriptRoot + '\Remove Extra Folders from Windows 10 This PC\Remove Extra Folders from Windows 10 This PC.reg'
I also tried :
regedit /s $PSScriptRoot + '\Remove Extra Folders from Windows 10 This PC\Remove Extra Folders from Windows 10 This PC.reg'
Doesn't work
Any suggestion ?
英文:
Hello i am trying to execute a reg file (with spaces in his name) located in a subfolder named : "Remove Extra Folders from Windows 10 This PC".
My actual script is :
reg import $PSScriptRoot + '\Remove Extra Folders from Windows 10 This PC\Remove Extra Folders from Windows 10 This PC.reg'
I also tried :
regedit /s $PSScriptRoot + '\Remove Extra Folders from Windows 10 This PC\Remove Extra Folders from Windows 10 This PC.reg'
Doesn't work
Any suggestion ?
答案1
得分: 1
使用括号来强制 PowerShell 在将结果值传递给 reg.exe
之前评估字符串连接:
reg import ($PSScriptRoot + '\Remove Extra Folders from Windows 10 This PC\Remove Extra Folders from Windows 10 This PC.reg')
或者,使用可展开(双引号)字符串:
reg import "$PSScriptRoot\Remove Extra Folders from Windows 10 This PC\Remove Extra Folders from Windows 10 This PC.reg"
英文:
Use parentheses to force PowerShell to evaluate the string concatenation before passing the resulting value to reg.exe
:
reg import ($PSScriptRoot + '\Remove Extra Folders from Windows 10 This PC\Remove Extra Folders from Windows 10 This PC.reg')
Alternatively, use an expandable (double-quoted) string:
reg import "$PSScriptRoot\Remove Extra Folders from Windows 10 This PC\Remove Extra Folders from Windows 10 This PC.reg"
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论