blob: 24fa86c4aa06289c65d6a359c3c0a1d972a3a293 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
Set UAC = CreateObject("Shell.Application")
Const PROCESS = "xmake.exe"
If WScript.Arguments.count < 2 Then
WScript.echo "Help: run <flag> <command> [args]"
WScript.echo " flags:"
WScript.echo " N - normal"
WScript.echo " A - run as admin"
WScript.echo " W - wait xmake to exit"
WScript.echo " You should use 'N' if no speical flags needed"
WScript.echo " e.g.: run WA xmake-install.exe /Q"
Else
Dim flags
Dim program
flags = UCase(WScript.arguments(0))
program = WScript.arguments(1)
Dim verb
Dim wait
If InStr(flags, "A") <> 0 Then
verb = "runas"
Else
verb = "open"
End If
If InStr(flags, "W") <> 0 Then
Dim counter
counter = 0
Dim sQuery
sQuery = "select * from win32_process where name='" & PROCESS & "'"
Do
Set SVC = getobject("winmgmts:root\cimv2")
Set cproc = SVC.execquery(sQuery)
iniproc = cproc.count
counter = counter + 1
If counter >= 20 Then
WScript.echo "xmake still hasn't exited after 10 seconds, aborting..."
WScript.quit 1
End If
If iniproc <> 0 Then
WScript.echo "Waiting for xmake to exit..."
wscript.sleep 500
End If
Loop Until iniproc = 0
Set cproc = Nothing
Set SVC = Nothing
End If
Dim ucCount
Dim args
args = ""
For ucCount = 2 To (WScript.Arguments.count - 1) Step 1
Dim carg
if InStr(WScript.Arguments(ucCount), " ") <> 0 Then
carg = """" & Replace(WScript.Arguments(ucCount), """", """""") & """"
ElseIf Len(WScript.Arguments(ucCount)) = 0 Then
carg = """"""
Else
carg = WScript.Arguments(ucCount)
End If
args = args & " " & carg
Next
UAC.ShellExecute program, args, "", verb, 1
End If
|