【发布时间】:2019-11-15 01:52:54
【问题描述】:
以下文件位于同一文件夹中。
Testing.cmd
Toast notification.ps1
运行 [Toast notification] .vbs
当我运行 Toast notification.ps1 时,它可以工作。但是,当我运行 Run [Toast notification].vbs 时,.ps1 文件没有运行。
以下是 PowerShell 脚本:
[reflection.assembly]::loadwithpartialname("System.Windows.Forms")
[reflection.assembly]::loadwithpartialname("System.Drawing")
# notify.icon type: Information, Warning or Error.
$notify = new-object system.windows.forms.notifyicon
$notify.icon = [System.Drawing.SystemIcons]::Information
$notify.visible = $true
$notify.showballoontip(10,"", "The CPU is hot.",
[system.windows.forms.tooltipicon]::None)
$notify.dispose()
以下是VBScript:
Path = split(wscript.scriptFullName, wscript.scriptname)(0)
Item1 = Path & "Toast notification.ps1"
Item2 = Path & "Testing.cmd"
Set Action = CreateObject("Wscript.shell")
Action.run ("powershell -executionpolicy bypass -file ""& Item1 &""")
Action.run ("""" & Item2 & ""), 0
当我双击 VBScript 文件时,.ps1 文件没有运行。 “Path”可用于运行Testing.cmd,但我无法使其与.ps1 文件一起使用。我该如何解决这个问题?
以下是Testing.cmd文件:
(ncpa.cpl)
【问题讨论】:
-
请编辑问题,并添加更多详细信息。您使用哪个 shell 和什么命令来调用 vbs 脚本?
-
@vonPryz,照你说的做。请再次阅读问题。
标签: powershell vbscript