0% found this document useful (0 votes)
202 views2 pages

Steam Hearthstone Script

This document contains code to launch the Hearthstone game client through its launcher. It first checks if it needs to elevate privileges, and if so it copies the launcher path and command line to a temporary file. It then waits for the elevated script to finish launching the client before cleaning up and exiting.

Uploaded by

Samuele Garau
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
202 views2 pages

Steam Hearthstone Script

This document contains code to launch the Hearthstone game client through its launcher. It first checks if it needs to elevate privileges, and if so it copies the launcher path and command line to a temporary file. It then waits for the elevated script to finish launching the client before cleaning up and exiting.

Uploaded by

Samuele Garau
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Launcher = "Hearthstone Beta Launcher.

exe"
Client = "Hearthstone.exe"
' 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 com
mandline 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 "cscript.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 commandlin
e 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
While True
'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")
set tempfile = fso.OpenTextFile(tempname, 2)
tempfile.WriteLine(cleanCmdLine)
tempfile.close()
WScript.Quit
Next
WScript.Sleep 1000
Wend
End If

You might also like