Advertisement
Guest User

Diablo 3 Steam Overlay

a guest
Dec 6th, 2014
1,826
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. Launcher = "Diablo III Launcher.exe"
  2. Client = "Diablo III.exe"
  3.  
  4. ' if nothing was passed in, we are starting from scratch, so start the launcher
  5. If WScript.Arguments.length = 0 Then
  6. Home = WScript.ScriptFullName
  7. Home = Left(Home, InStr(Home, WScript.ScriptName)-1)
  8.  
  9. 'run the launcher
  10. Set objShell = WScript.CreateObject("Shell.Application")
  11. objShell.ShellExecute Launcher, "", Home
  12.  
  13. ' create the file that the elevated script will copy executables's path and commandline to
  14. set fso = CreateObject("Scripting.FileSystemObject")
  15. set tempfolder = fso.GetSpecialFolder(2)
  16. tempname = tempfolder & "\" & "steam.tmp"
  17. set tempfile = fso.CreateTextFile(tempname)
  18. tempfile.close()
  19.  
  20. 'run this script but signal that it needs to elevate by giving it the tempfile name as an argument
  21. Set objShell = CreateObject("Shell.Application")
  22. objShell.ShellExecute "cscript.exe", Chr(34) & WScript.ScriptFullName & Chr(34) & " " & tempname, "", "runas", 2
  23.  
  24. WScript.Echo "Waiting for other script to finish..."
  25. ' check every second if the temporary file has been updated with the commandline info
  26. Do While True
  27. 'check the filesize of the tempfile
  28. set tempfile = fso.GetFile(tempname)
  29. If tempfile.Size > 0 Then Exit Do
  30. WScript.Sleep 1000
  31. Loop
  32.  
  33. ExecutablePath = Home
  34. set tempfile = fso.OpenTextFile(tempname)
  35. CommandLine = tempfile.ReadLine
  36. tempfile.close()
  37.  
  38. Set objShell = CreateObject("Shell.Application")
  39. objShell.ShellExecute Client, CommandLine, ExecutablePath
  40.  
  41. fso.DeleteFile tempname
  42. WScript.Quit
  43. Else
  44. ' we are elevated now
  45. WScript.Echo "Waiting for launcher to start client..."
  46.  
  47. 'Get Windows Manager object
  48. Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
  49.  
  50. ' check every second for client that was launched by launcher
  51. While True
  52.  
  53. 'Get info on processes named Client
  54. Set InstanceList = objWMIService.ExecQuery _
  55. ("Select * from Win32_Process Where Name = '" & Client & "'")
  56.  
  57. for Each Instance in InstanceList
  58. cmdline = Instance.CommandLine
  59.  
  60. 'we found the client we care about
  61. Instance.Terminate()
  62.  
  63. 'remove the exe path and name from the cmdline
  64. position = InStr(1, cmdline, """ ") + 1
  65. cleanCmdLine = Right(cmdline, Len(cmdline) - position)
  66.  
  67. tempname = WScript.Arguments(0)
  68. set fso = CreateObject("Scripting.FileSystemObject")
  69. set tempfile = fso.OpenTextFile(tempname, 2)
  70. tempfile.WriteLine(cleanCmdLine)
  71. tempfile.close()
  72.  
  73. WScript.Quit
  74. Next
  75.  
  76. WScript.Sleep 1000
  77. Wend
  78. End If
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement