添加位于具有空格名称的子文件夹中的reg文件

huangapple go评论59阅读模式
英文:

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 添加位于具有空格名称的子文件夹中的reg文件
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 添加位于具有空格名称的子文件夹中的reg文件
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"

huangapple
  • 本文由 发表于 2023年2月9日 02:48:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/75390419.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定