我有一个批处理脚本,它启用了大量的审计。从我运行此脚本的文件夹放置在我的桌面上,登录的用户名是“Doctor A” (命令运行的路径是c:\user\Doctor a\Desktop\script\test.bat
)。运行批处理命令时无效的路径
运行SOM批处理命令我想推出一个PowerShell脚本使用以下行后:
powershell.exe -ExecutionPolicy Bypass "%~dp0\Audit_folders_and_regkeys.ps1"
当我运行这个命令我得到一个错误说
The term 'C:\Users\Doctor' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:16 + C:\Users\Doctor <<<< A\Desktop\CyperPilot_Audit_Conf_External_Network\CyperPilot_Audit_Conf_External_Network\\Audit_folders_and_regkeys.ps1 + CategoryInfo : ObjectNotFound: (C:\Users\Doctor:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
好像它不会比C:\Users\Doctor
更进一步我在批处理文件中写什么来解决这个问题?
如果我把该脚本文件夹放在c:\ script \ ....中,它就完美了 –
'powershell.exe -ExecutionPolicy Bypass -File“%〜dp0 \ Audit_folders_and_regkeys.ps1”' – PetSerAl