[英]How to run a PowerShell script in folder having space in its name?
Running a script in C:\\Users\\Ooker\\Desktop
is fine, but yields error in C:\\Users\\Ooker\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup
. 在C:\\Users\\Ooker\\Desktop
运行脚本很好,但是在C:\\Users\\Ooker\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup
产生错误。
I guess it's because of Start Menu
have space in between, but I don't know how to double click the file and make it run. 我猜这是因为“ Start Menu
之间有空格,但是我不知道如何双击文件并使其运行。 There seems to have no way to bracket the path beforehand. 似乎没有办法事先将路径括起来。
I can run it in CLI, and it doesn't reference itself. 我可以在CLI中运行它,并且它不会引用自身。
Few ways to do it. 很少有办法做到这一点。
Registry: Edit your reg key at 注册表:在以下位置编辑您的注册表项
HKEY_CLASSES_ROOT\Microsoft.PowerShellScript.1\Shell\Open\Command
to 至
"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -noLogo -ExecutionPolicy unrestricted -file "%1"
or 要么
Shortcut: Create a shortcut with the target: 快捷方式:使用目标创建快捷方式:
powershell.exe -command "& 'C:\Users\Ooker\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\MyScript.ps1'"
keep in mind that the opening in a notepad is a safety measure in the event you accidentally run it when it is not intended. 请记住,记事本中的开口是一种安全措施,以防您在不希望的情况下意外运行它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.