Advertisement
Guest User

Untitled

a guest
Jun 15th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 2.47 KB | None | 0 0
  1. #RequireAdmin
  2. #include <MsgBoxConstants.au3>
  3.  
  4. if not RunWait('C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe "Mount-DiskImage ""' & @ScriptDir & '\FF7DISC1.ISO"""', @ScriptDir, @SW_HIDE) == 0 then ; mount iso
  5.    MsgBox($MB_ICONERROR, "Error", "Failed to mount ISO: " & @error & @CRLF & @extended) ; error if mounting ISO fails
  6. else
  7.  
  8. if not WinExists("7thHeaven Version") then ; only run 7th Heaven if it's not already open
  9.    if not Run(@ScriptDir & "\7thHeaven\7thHeaven.exe", @ScriptDir & "\7thHeaven\") then ; run 7th Heaven
  10.       MsgBox($MB_ICONERROR, "Error", "Failed to launch 7th Heaven: " & @error & @CRLF & @extended) ; error if launching fails
  11.    endif
  12. else
  13.  
  14. Sleep(2000) ; sleep a bit to make sure the ISO is mounted and window is loaded
  15.  
  16. WinActivate("7thHeaven Version") ; activate window
  17. WinWaitActive("7thHeaven Version") ; wait
  18.  
  19. $drives = DriveGetDrive($DT_CDROM) ; get drive letters
  20. If @error Then
  21.     ; An error occurred when retrieving the drives.
  22.     MsgBox($MB_ICONERROR, "Error", "Failed to get drive letter: " & @error & @CRLF & @extended) ; error if getting drive letter
  23.  else
  24.  
  25. $drive = "none"
  26. For $i = 1 to $drives[0]
  27.    ; get the drive letter of FF7DISC1.iso
  28.    If DriveGetLabel($drives[$i]) == "FF7DISC1" then
  29.       $drive = $drives[$i]
  30.       ExitLoop()
  31.    EndIf
  32. Next
  33.  
  34. if $drive == "none" then
  35.     MsgBox($MB_ICONERROR, "Error", "Failed to get drive letter: No such drive") ; error if getting drive letter
  36. else
  37.  
  38.     if not RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Square Soft, Inc.\Final Fantasy VII", "DataDrive", "REG_SZ", $drive & "\") then ; write drive letter to registry
  39.        MsgBox($MB_ICONERROR, "Error", "Failed to write drive letter to registry: " & @error & @CRLF & @extended) ; error if failed
  40.     else
  41.  
  42. Sleep(2000) ; some extra delay to make sure the window has loaded
  43.  
  44. if not ControlClick("7thHeaven Version", "", "[TEXT:Launch Game]") then ; launch game
  45.    MsgBox($MB_ICONERROR, "Error", "Failed to launch game: " & @error & @CRLF & @extended) ; error if clicking "Launch Game" fails
  46. else
  47.  
  48. Sleep(10000) ; sleep 10 seconds
  49.  
  50. WinClose("7thHeaven Version") ; finally, close 7th Heaven
  51.  
  52. endif
  53. endif
  54. endif
  55. endif
  56. endif
  57.  
  58. if not RunWait('C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe "Dismount-DiskImage ""' & @ScriptDir & '\FF7DISC1.ISO"""', @ScriptDir, @SW_HIDE) == 0 then ; mount iso
  59.    MsgBox($MB_ICONERROR, "Error", "Failed to unmount ISO:  " & @error & @CRLF & @extended) ; error if mounting ISO fails
  60. endif
  61.  
  62. endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement