Vbscript有效路径

时间:2014-05-27 12:16:04

标签: powershell vbscript

我试图让调度程序运行Vbscript,它将运行一个Powershell脚本。 基本上这是我的Vbscript

command = "powershell.exe -nologo -command C:\Users\someuser\Desktop\appAPIMonitor.ps1"
set shell = CreateObject("WScript.Shell")
shell.Run command,0

当我在脚本上面运行时,它有效。但是当我将脚本放在我喜欢的路径上时,脚本不会像以前一样运行。所以它必须是无效的路径。这是我的新剧本

command = "powershell.exe -nologo -command C:\Users\someuser\My Work\App\Project\My.API.App\Scripts\appAPIMonitor.ps1"
set shell = CreateObject("WScript.Shell")
shell.Run command,0

有人能指出我的道路有什么问题吗?它是我的工作中的空白吗?或 My.Api.App 中的点?

1 个答案:

答案 0 :(得分:0)

这是我设法得到的解决方案。

command = "powershell.exe -nologo -file ""C:\Users\someuser\My Work\App\Project\My.API.App\Scripts\appAPIMonitor.ps1"" "
set shell = CreateObject("WScript.Shell")
shell.Run command,0

为最后一个引号添加一些空格并将 -command 更改为 -file 应该可以解决问题。我在这个问题上解决了这个问题希望将来帮助任何人。顺便说一句,感谢那些花费宝贵时间回答我问题的人。