我有一個批處理腳本,它啓用了大量的審計。從我運行此腳本的文件夾放置在我的桌面上,登錄的用戶名是「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