Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ' VB Script Document
- ' SteamOverlay hook for Warcraft via battle.net
- 'option explicit
- Launcher = "Battle.net.exe"
- ' alt:".\World of Warcraft\Wow-64.exe"
- Client = "Battle.net.exe"
- BattleNet = "Battle.net.exe"
- Bnet = true
- ' if nothing was passed in, we are starting from scratch, so start the launcher
- If WScript.Arguments.length = 0 Then
- Home = WScript.ScriptFullName
- Home = Left(Home, InStr(Home, WScript.ScriptName)-1)
- 'run the launcher
- Set objShell = WScript.CreateObject("Shell.Application")
- objShell.ShellExecute Launcher, "", Home
- ' create the file that the elevated script will copy executables's path and commandline to
- set fso = CreateObject("Scripting.FileSystemObject")
- set tempfolder = fso.GetSpecialFolder(2)
- tempname = tempfolder & "\" & "steam.tmp"
- set tempfile = fso.CreateTextFile(tempname)
- tempfile.close()
- 'run this script but signal that it needs to elevate by giving it the tempfile name as an argument
- Set objShell = CreateObject("Shell.Application")
- objShell.ShellExecute "wscript.exe", Chr(34) & WScript.ScriptFullName & Chr(34) & " " & tempname, "", "runas", 2
- 'WScript.Echo "Waiting for other script to finish..."
- ' check every second if the temporary file has been updated with the commandline info
- Do While True
- 'check the filesize of the tempfile
- set tempfile = fso.GetFile(tempname)
- If tempfile.Size > 0 Then Exit Do
- WScript.Sleep 1000
- Loop
- ExecutablePath = Home
- set tempfile = fso.OpenTextFile(tempname)
- CommandLine = tempfile.ReadLine
- tempfile.close()
- Set objShell = CreateObject("Shell.Application")
- objShell.ShellExecute Client, CommandLine, ExecutablePath
- fso.DeleteFile tempname
- WScript.Quit
- Else
- ' we are elevated now
- 'WScript.Echo "Waiting for launcher to start client..."
- 'Get Windows Manager object
- Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
- ' check every second for client that was launched by launcher
- Do While bnet
- On Error Resume Next
- 'Get info on processes named Client
- Set InstanceList = objWMIService.ExecQuery _
- ("Select * from Win32_Process Where Name = '" & Client & "'")
- for Each Instance in InstanceList
- cmdline = Instance.CommandLine
- 'we found the client we care about
- Instance.Terminate()
- 'remove the exe path and name from the cmdline
- position = InStr(1, cmdline, """ ") + 1
- cleanCmdLine = Right(cmdline, Len(cmdline) - position)
- tempname = WScript.Arguments(0)
- set fso = CreateObject("Scripting.FileSystemObject")
- If fso.FileExists(tempname) Then
- set tempfile = fso.OpenTextFile(tempname, 2)
- tempfile.WriteLine(cleanCmdLine)
- tempfile.close()
- End If
- WScript.Quit
- Next
- WScript.Sleep 1000
- 'Get info on processes named BattleNet, exit if released.
- Set BNetList = objWMIService.ExecQuery _
- ("Select * from Win32_Process Where Name = '" & BattleNet & "'")
- for Each BnetI in BNetList
- bnetline = BnetI.CommandLine
- Next
- if bnetline = "" then bnet = false
- Loop
- End If
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement