This repository has been archived by the owner on Nov 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
dialog.vbs
154 lines (134 loc) · 4.56 KB
/
dialog.vbs
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
' :: ===========================================================================
' :: NAME: dialog.vbs
' :: AUTHOR: Manuel Gil.
' :: DATE: 11/26/2017.
' :: VERSION: 1.0.3.0
' :: ===========================================================================
Dim strApplication
Dim strFunction
Dim strVersion
Dim strArguments
Dim strCustomization
Dim strSource
Dim strDestination
Dim strMessage
Call init()
If strFunction = "createCopy" Then
Call getSource()
Call getDestination()
strMessage = "Are you sure you want to create a backup copy of " & strSource & " in " & strDestination & "?"
ElseIf strFunction = "patchFiles" Then
Call getSource()
Call getDestination()
strMessage = "Are you sure you want to copy the contents of " & strSource & " in " & strDestination & "?"
ElseIf strFunction = "extractCustomization" Then
Call getCustomization()
Call getSource()
Call getDestination()
strMessage = "Are you sure you want to extract content from " & strSource & " in " & strDestination & "?"
ElseIf strFunction = "createList" Then
Call getSource()
strMessage = "Are you sure you want to create a list of " & strSource & "?"
End If
Call showMessage()
Call runCommands()
' Gets the Arguments
Function init()
Set objArgs = WScript.Arguments
' Minimum 3 Arguments
If ObjArgs.count < 3 Then
MsgBox "The arguments are not enough.",vbCritical,"File Manager."
WScript.quit
Else
' Batch File = Argument 1
strApplication = objArgs(0)
' Function = Argument 2
strFunction = objArgs(1)
' OS Version = Argument 3
strVersion = objArgs(2)
End If
End Function
' Gets Custom Folder
Function getCustomization()
strCustomization = Inputbox("Enter the path where the customization is located:" & vbCrlf & _
vbCrlf & "Note: The path must not have special characters.","File Manager.","")
' Path end with "\"
If strCustomization <> "" Then
If InStr(strCustomization, "(") = 0 And InStr(strCustomization, ")") = 0 Then
If Right(strCustomization, 1) = "\" Then
strCustomization = Left(strCustomization, Len(strCustomization) - 1)
End If
Else
MsgBox "The path contains special characters.",vbCritical,"File Manager."
WScript.quit
End If
Else
MsgBox "An error has occurred.",vbCritical,"File Manager."
WScript.quit
End If
End Function
' Gets Source Folder
Function getSource()
strSource = Inputbox("Enter the source path:" & vbCrlf & _
vbCrlf & "Note: The path must not have special characters.","File Manager.","")
' Path end with "\"
If strSource <> "" Then
If InStr(strSource, "(") = 0 And InStr(strSource, ")") = 0 Then
If Right(strSource, 1) = "\" Then
strSource = Left(strSource, Len(strSource) - 1)
End If
Else
MsgBox "The path contains special characters.",vbCritical,"File Manager."
WScript.quit
End If
Else
MsgBox "An error has occurred.",vbCritical,"File Manager."
WScript.quit
End If
End Function
' Gets Destination Folder
Function getDestination()
strDestination = Inputbox("Enter the destination path:" & vbCrlf & _
vbCrlf & "Note: The path must not have special characters.","File Manager.","")
' Path end with "\"
If strDestination <> "" Then
If InStr(strDestination, "(") = 0 And InStr(strDestination, ")") = 0 Then
If Right(strDestination, 1) = "\" Then
strDestination = Left(strDestination, Len(strDestination) - 1)
End If
Else
MsgBox "The path contains special characters.",vbCritical,"File Manager."
WScript.quit
End If
Else
MsgBox "An error has occurred.",vbCritical,"File Manager."
WScript.quit
End If
End Function
' Show Confirmation Message
Function showMessage()
objConfirmacion = MsgBox(strMessage,vbYesNo,"File Manager.")
If objConfirmacion = vbNo Then
WScript.quit
End If
End Function
' Start Batch File
Function runCommands()
Set objShell = CreateObject("Shell.Application")
' Create a JSON Object
' Function: {Source, Destination, Custom, OS Version}
strArguments = strFunction & ": {source:" & strSource & "," & _
"destination:" & strDestination & "," & _
"custom:" & strCustomization & "," &_
"version:" & strVersion & "}"
If strVersion = "5.2.3790" Then
' Run the Batch File in Windows Server 2003 or Windows XP (Without Runas)
objShell.ShellExecute strApplication, strArguments, "", "", 1
Else
' Run the Batch File As Administrator (Runas)
objShell.ShellExecute strApplication, strArguments, "", "runas", 1
End If
' Wait 3600 milliseconds
WScript.Sleep 3600
set objShell = nothing
End Function