-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.vbs
More file actions
40 lines (37 loc) · 1.41 KB
/
Copy pathsetup.vbs
File metadata and controls
40 lines (37 loc) · 1.41 KB
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
Set WshShell = CreateObject("WScript.Shell")
Set ScriptFso = CreateObject("Scripting.FileSystemObject")
PriviledgesRequired
ProcessTemplate "shuffler-lib-template.wsc", "shuffler-lib.wsc", Array("___CLSID___"),_
Array(Left(CreateObject("Scriptlet.TypeLib").Guid, 38)), "RegSvr32 scrobj.dll /n /i:___OUTPUTPATH___ /s"
Private Sub PriviledgesRequired
On Error Resume Next
Err.Clear
WshShell.RegRead("HKEY_USERS\S-1-5-19\Environment\TEMP")
If Err.Number <> 0 Then
WScript.Echo "Elevated priviledges required."
WScript.Quit(2)
End If
End Sub
Private Sub ProcessTemplate(TemplateName, OutputName, arrTextTemplate, arrReplacement, CommandTemplate)
OutputPath = BuildPath(OutputName)
With ScriptFso.OpenTextFile(BuildPath(TemplateName), 1)
TemplateText = .ReadAll()
.Close()
End With
For i = 0 To UBound(arrTextTemplate)
TemplateText = Replace(TemplateText, arrTextTemplate(i), arrReplacement(i))
Next
With ScriptFso.OpenTextFile(OutputPath, 2, True)
.Write(TemplateText)
.Close()
End With
If IsNull(CommandTemplate) Then Exit Sub
With WshShell.Exec(Replace(CommandTemplate, "___OUTPUTPATH___", OutputPath))
Do : Loop Until .Status = 1
End With
End Sub
Private Function BuildPath(FileName)
With ScriptFso
BuildPath = .BuildPath(.GetParentFolderName(WScript.ScriptFullName), FileName)
End With
End Function