【发布时间】:2016-07-17 02:52:50
【问题描述】:
这个 VBScript 运行一些 PowerShell 脚本。我将notepad.exe 的调用放在那里以确保它以管理员身份运行。
我的 PowerShell 脚本会打开控制台,但随后会立即关闭。
我想让它们保持打开状态。
怎么了?
这是我的 VBScript:
RunAsAdmin()
Set shell = WScript.CreateObject("WScript.shell")
shell.Run("powershell.exe -noexit -executionpolicy bypass -file .\Source\RemoveWindows10Apps-2.0.ps1"), 1 , True
Set shell = WScript.CreateObject("WScript.shell")
shell.Run("powershell.exe -noexit -executionpolicy bypass -file .\Source\ChangeWin10StartLayout.ps1"), 1 , True
Set shell = WScript.CreateObject("WScript.shell")
shell.Run("powershell.exe -noexit -executionpolicy bypass -file .\Source\NewFolder.ps1"), 1 , True
Set shell = WScript.CreateObject("WScript.shell")
shell.Run("notepad.exe"), 1 , True
Function RunAsAdmin()
Dim objAPP
If WScript.Arguments.length = 0 Then
Set objAPP = CreateObject("Shell.Application")
objAPP.ShellExecute "wscript.exe", """" & _
WScript.ScriptFullName & """" & " RunAsAdministrator",,"runas", 1
WScript.Quit
End If
End Function
【问题讨论】:
-
它与 RunAsAdmin 功能有关,因为当我将其取出时,我的窗口保持打开状态,但它们不会以管理员身份运行。
-
答案是否必须在 VBScript 中?这是elevates within the script的一些powershell
标签: powershell vbscript