Option Explicit

Dim shell, fso, scriptDir, ps1, command, args, i

Set shell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")

scriptDir = fso.GetParentFolderName(WScript.ScriptFullName)
ps1 = fso.BuildPath(scriptDir, "service-manager-ui.ps1")

If Not fso.FileExists(ps1) Then
    MsgBox "PowerShell service installer was not found:" & vbCrLf & ps1, vbCritical, "DigiTS Integration Module"
    WScript.Quit 1
End If

args = "-NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden -File " & Chr(34) & ps1 & Chr(34)

For i = 0 To WScript.Arguments.Count - 1
    args = args & " " & Chr(34) & Replace(WScript.Arguments(i), Chr(34), "\" & Chr(34)) & Chr(34)
Next

Dim uac
Set uac = CreateObject("Shell.Application")
uac.ShellExecute "powershell.exe", args, "", "runas", 0
