Skip to content

Commit

Permalink
v1.2.0
Browse files Browse the repository at this point in the history
- now runs as administrator only at first launch, if 'run_admin = 1' in ini file
- now can run the game through a different executable (e.g. settings launcher) at first launch
  • Loading branch information
alex47exe committed Feb 21, 2019
1 parent b84d524 commit 5f22f82
Show file tree
Hide file tree
Showing 8 changed files with 237 additions and 106 deletions.
2 changes: 1 addition & 1 deletion ProgramData.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ___ UniGame Launcher v1.1.0 © 2017-2018, SalFisher47
# ___ UniGame Launcher v1.2.0 © 2017-2019, SalFisher47


[launcher]
Expand Down
3 changes: 2 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ Universal launcher for games, to be placed in game folder. I would say it's best

**Features:**

- runs as administrator only at first launch
- runs as administrator only at first launch, if `run_admin = 1` in *ini* file
- can run game executable with arguments and / or compatibility settings

- can run game executable on the first cpu core, thanks to included [RunFirst.exe](https://www.activeplus.com/products/runfirst) - to be used only on some older games that don't run properly on multi-core cpus
- can run the game through a different executable (e.g. settings launcher) at first launch
- if savegame folder is specified, creates a *_savegame.lnk* shortcut to it

------
Expand Down
131 changes: 85 additions & 46 deletions UniGame_Launcher_one.au3
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_UPX_Parameters=-9 --strip-relocs=0 --compress-exports=0 --compress-icons=0
#AutoIt3Wrapper_Res_Description=UniGame Launcher
#AutoIt3Wrapper_Res_Fileversion=1.1.0.47
#AutoIt3Wrapper_Res_ProductVersion=1.1.0.47
#AutoIt3Wrapper_Res_LegalCopyright=2017-2018, SalFisher47
#AutoIt3Wrapper_Res_Fileversion=1.2.0.47
#AutoIt3Wrapper_Res_ProductVersion=1.2.0.47
#AutoIt3Wrapper_Res_LegalCopyright=2017-2019, SalFisher47
#AutoIt3Wrapper_Res_SaveSource=n
#AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

Expand All @@ -19,22 +20,22 @@
#pragma compile(InputBoxRes, true)
#pragma compile(CompanyName, 'SalFisher47')
#pragma compile(FileDescription, 'UniGame Launcher')
#pragma compile(FileVersion, 1.1.0.47)
#pragma compile(FileVersion, 1.2.0.47)
#pragma compile(InternalName, 'UniGame Launcher')
#pragma compile(LegalCopyright, '2017-2018, SalFisher47')
#pragma compile(LegalCopyright, '2017-2019, SalFisher47')
#pragma compile(OriginalFilename, UniGame_Launcher_one.exe)
#pragma compile(ProductName, 'UniGame Launcher')
#pragma compile(ProductVersion, 1.1.0.47)
#pragma compile(ProductVersion, 1.2.0.47)
#EndRegion ;**** Pragma Compile ****

; === UniGame Launcher.au3 =========================================================================================================
; === UniGame_Launcher_one.au3 =====================================================================================================
; Title .........: UniGame Launcher
; Version .......: 1.1.0.47
; AutoIt Version : 3.3.14.5
; Language ......: English
; Description ...: Universal Game Launcher
; Description ...: Universal Game Launcher one
; Author(s) .....: SalFisher47
; Last Modified .: November 18, 2018 - last compiled on January 8 2019
; Last Modified .: January 19, 2019 - last compiled on January 19 2019
; ==================================================================================================================================

Global $Env_RoamingAppData = @AppDataDir, _
Expand All @@ -45,6 +46,11 @@ Global $Env_RoamingAppData = @AppDataDir, _
If @error Then $Env_SavedGames = $Env_UserProfile & "\Saved Games"

$Ini = @ScriptDir & "\" & StringTrimRight(@ScriptName, 4) & ".ini"
$ini_RunAdmin = IniRead($ini, "launcher", "run_admin", "")

; check for game path and add it to ini file in C:\ProgramData\SalFisher47\UniGame Launcher
If Not FileExists(@AppDataCommonDir & "\SalFisher47\UniGame Launcher") Then DirCreate(@AppDataCommonDir & "\SalFisher47\UniGame Launcher")
FileInstall("ProgramData.ini", @AppDataCommonDir & "\SalFisher47\UniGame Launcher\" & StringTrimRight(@ScriptName, 4) & ".ini", 0)

$exe_run = IniRead($Ini, "Exe", "exe_run", "")
$exe_path_full = @ScriptDir & "\" & $exe_run
Expand All @@ -53,20 +59,18 @@ $exe_path_only = StringTrimRight($exe_path_full, StringLen($exe_only)+1)
$exe_cmd = IniRead($Ini, "Exe", "exe_cmd", "")
$exe_compat = IniRead($Ini, "Exe", "exe_compat", "")

$exe_run_alt = IniRead($Ini, "Exe", "exe_run_alt", "")
$exe_path_full_alt = @ScriptDir & "\" & $exe_run_alt
$exe_only_alt = StringTrimLeft($exe_path_full_alt, StringInStr($exe_path_full_alt, "\", 0, -1))
$exe_path_only_alt = StringTrimRight($exe_path_full_alt, StringLen($exe_only_alt)+1)
$exe_cmd_alt = IniRead($Ini, "Exe", "exe_cmd_alt", "")
$exe_compat_alt = IniRead($Ini, "Exe", "exe_compat_alt", "")

$run_first = IniRead($Ini, "Exe", "run_first", 0)
If Not FileExists(@AppDataCommonDir & "\SalFisher47\RunFirst") Then DirCreate(@AppDataCommonDir & "\SalFisher47\RunFirst")
FileInstall("RunFirst\RunFirst.exe", @AppDataCommonDir & "\SalFisher47\RunFirst\RunFirst.exe", 0)
FileInstall("RunFirst\RunFirst.txt", @AppDataCommonDir & "\SalFisher47\RunFirst\RunFirst.txt", 0)

; check for game path and add it to ini file in C:\ProgramData\SalFisher47\UniGame Launcher
If Not FileExists(@AppDataCommonDir & "\SalFisher47\UniGame Launcher") Then DirCreate(@AppDataCommonDir & "\SalFisher47\UniGame Launcher")
FileInstall("ProgramData.ini", @AppDataCommonDir & "\SalFisher47\UniGame Launcher\" & StringTrimRight(@ScriptName, 4) & ".ini", 0)
$first_launch = 1
If IniRead(@AppDataCommonDir & "\SalFisher47\UniGame Launcher\" & StringTrimRight(@ScriptName, 4) & ".ini", "launcher", "game_path", "") <> @ScriptDir Then
$first_launch = 0
IniWrite(@AppDataCommonDir & "\SalFisher47\UniGame Launcher\" & StringTrimRight(@ScriptName, 4) & ".ini", "launcher", "game_path", " " & @ScriptDir)
EndIf

; check for savegame path and add it to ini file in C:\ProgramData\SalFisher47\UniGame Launcher
$ini_Savegame_dir = IniRead($ini, "savegame", "savegame_dir", "")
$ini_Savegame_subdir = IniRead($ini, "savegame", "savegame_subdir", "")
Expand All @@ -89,53 +93,88 @@ Switch $ini_Savegame_dir
Case "GameDir"
$Savegame_dir = @ScriptDir & "\" & $ini_Savegame_subdir
EndSwitch
If $Savegame_dir <> "" Then

If IniRead(@AppDataCommonDir & "\SalFisher47\UniGame Launcher\" & StringTrimRight(@ScriptName, 4) & ".ini", "launcher", "game_path", "") <> @ScriptDir Then
$first_launch = 1
IniWrite(@AppDataCommonDir & "\SalFisher47\UniGame Launcher\" & StringTrimRight(@ScriptName, 4) & ".ini", "launcher", "game_path", " " & @ScriptDir)
If IniRead(@AppDataCommonDir & "\SalFisher47\UniGame Launcher\" & StringTrimRight(@ScriptName, 4) & ".ini", "launcher", "savegame_path", "") <> $Savegame_dir Then
;$first_launch = 0
IniWrite(@AppDataCommonDir & "\SalFisher47\UniGame Launcher\" & StringTrimRight(@ScriptName, 4) & ".ini", "launcher", "savegame_path", " " & $Savegame_dir)
EndIf
EndIf

If $first_launch == 1 Then
_RunUser()
If $ini_RunAdmin == 1 Then
_RunAdmin()
Exit
Else
_RunMain()
Exit
EndIf
Else
_RunAdmin()
If IsAdmin() Then
$first_launch = 1
If IniRead(@AppDataCommonDir & "\SalFisher47\UniGame Launcher\" & StringTrimRight(@ScriptName, 4) & ".ini", "launcher", "savegame_path", "") <> $Savegame_dir Then
IniWrite(@AppDataCommonDir & "\SalFisher47\UniGame Launcher\" & StringTrimRight(@ScriptName, 4) & ".ini", "launcher", "savegame_path", " " & $Savegame_dir)
EndIf
_RunMain()
Exit
Else
$first_launch = 0
If IniRead(@AppDataCommonDir & "\SalFisher47\UniGame Launcher\" & StringTrimRight(@ScriptName, 4) & ".ini", "launcher", "savegame_path", "") <> $Savegame_dir Then
IniWrite(@AppDataCommonDir & "\SalFisher47\UniGame Launcher\" & StringTrimRight(@ScriptName, 4) & ".ini", "launcher", "savegame_path", " " & $Savegame_dir)
EndIf
_RunMain()
Exit
EndIf
EndIf

Func _RunUser() ; main script
RegRead('HKCU\Software\Valve\Steam', 'SteamPath')
If @error Then
RegWrite('HKCU\Software\Valve\Steam', 'SteamExe','REG_SZ','d:/steam/steam.exe')
RegWrite('HKCU\Software\Valve\Steam', 'SteamPath','REG_SZ','d:/steam')
RegWrite('HKLM\SOFTWARE\Valve\Steam', 'InstallPath','REG_SZ','D:\Steam')
EndIf
If RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers", $exe_path_full) <> $exe_compat Then
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers", $exe_path_full, "REG_SZ", $exe_compat)
EndIf
$desktopRatio = Round(@DesktopWidth/@DesktopHeight, 2)

_RunMain()

Func _RunMain() ; main script
RegRead('HKCU\Software\Valve\Steam', 'SteamPath')
If @error Then
RegWrite('HKCU\Software\Valve\Steam', 'SteamExe','REG_SZ','d:/steam/steam.exe')
RegWrite('HKCU\Software\Valve\Steam', 'SteamPath','REG_SZ','d:/steam')
RegWrite('HKLM\SOFTWARE\Valve\Steam', 'InstallPath','REG_SZ','D:\Steam')
EndIf
If RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers", $exe_path_full) <> $exe_compat Then
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers", $exe_path_full, "REG_SZ", $exe_compat)
EndIf
If $Savegame_dir <> "" Then
If Not FileExists($Savegame_dir) Then DirCreate($Savegame_dir)
FileCreateShortcut($Savegame_dir, @ScriptDir & "\_savegame.lnk")
EndIf
If $first_launch == 1 Then
; add commands here to run before game exe at first launch
If $run_first == 1 Then
If $Savegame_dir <> "" Then
If Not FileExists($Savegame_dir) Then DirCreate($Savegame_dir)
FileCreateShortcut($Savegame_dir, @ScriptDir & "\_savegame.lnk")
If $exe_run_alt <> "" Then
ShellExecute(@AppDataCommonDir & "\SalFisher47\RunFirst\RunFirst.exe", '"' & $exe_path_full_alt & '"' & " " & $exe_cmd_alt & " " & $CmdLineRaw, $exe_path_only_alt, "", @SW_HIDE)
Else
ShellExecute(@AppDataCommonDir & "\SalFisher47\RunFirst\RunFirst.exe", '"' & $exe_path_full & '"' & " " & $exe_cmd & " " & $CmdLineRaw, $exe_path_only, "", @SW_HIDE)
EndIf
ShellExecute(@AppDataCommonDir & "\SalFisher47\RunFirst\RunFirst.exe", '"' & $exe_path_full & '"' & " " & $exe_cmd & " " & $CmdLineRaw, $exe_path_only, "", @SW_HIDE)
Else
If $Savegame_dir <> "" Then
If Not FileExists($Savegame_dir) Then DirCreate($Savegame_dir)
FileCreateShortcut($Savegame_dir, @ScriptDir & "\_savegame.lnk")
If $exe_run_alt <> "" Then
ShellExecute($exe_only_alt, " " & $exe_cmd_alt & " " & $CmdLineRaw, $exe_path_only_alt)
Else
ShellExecute($exe_only, " " & $exe_cmd & " " & $CmdLineRaw, $exe_path_only)
EndIf
EndIf
; add commands here to run after game exe at first launch
Else
; add commands here to run before game exe at every launch, except the first one
If $run_first == 1 Then
ShellExecute(@AppDataCommonDir & "\SalFisher47\RunFirst\RunFirst.exe", '"' & $exe_path_full & '"' & " " & $exe_cmd & " " & $CmdLineRaw, $exe_path_only, "", @SW_HIDE)
Else
ShellExecute($exe_only, " " & $exe_cmd & " " & $CmdLineRaw, $exe_path_only)
EndIf
; add commands here to run after game exe at every launch, except the first one
EndIf
EndFunc

Func _RunAdmin() ; run main script as admin on first launch
If RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers", @ScriptDir & "\" & StringTrimRight(@ScriptName, 4) & ".exe") <> "RUNASADMIN" Then
RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers", @ScriptDir & "\" & StringTrimRight(@ScriptName, 4) & ".exe", "REG_SZ", "RUNASADMIN")
EndIf
;---
If $Savegame_dir <> "" Then
If Not FileExists($Savegame_dir) Then DirCreate($Savegame_dir)
FileCreateShortcut($Savegame_dir, @ScriptDir & "\_savegame.lnk")
EndIf
ShellExecute(StringTrimRight(@ScriptName, 4) & ".exe", $CmdLineRaw, @ScriptDir)
;---
If RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers", @ScriptDir & "\" & StringTrimRight(@ScriptName, 4) & ".exe") == "RUNASADMIN" Then
Expand Down
Binary file modified UniGame_Launcher_one.exe
Binary file not shown.
20 changes: 18 additions & 2 deletions UniGame_Launcher_one.ini
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
# ___ UniGame Launcher v1.1.0 © 2017-2018, SalFisher47
# ___ UniGame Launcher v1.2.0 © 2017-2019, SalFisher47


[exe]

# ___ Executable to run, command-line parameters & compatibility settings
# For optional compatibility settings, use WIN95 / WIN98 / WINXPSP2 / WINXPSP3 / ...
# ... VISTARTM / VISTASP1 / VISTASP2 / WIN7RTM / WIN8RTM with or without RUNASADMIN
exe_run =
exe_run = game.exe
exe_cmd =
exe_compat =

# ___ Executable to run only at first launch, command-line parameters & compatibility settings
# Use it only if you need to run the game through a different executable (e.g. settings launcher) at first launch, ...
# ... or same as above, but with different command-line parameters & compatibility settings
exe_run_alt =
exe_cmd_alt =
exe_compat_alt =

# ___ If 1, runs the game on the first cpu core, through RunFirst.exe
# To be used only on some older games that don't run properly on multi-core cpus
run_first = 0
Expand All @@ -31,5 +38,14 @@ savegame_dir =
savegame_subdir =


[launcher]

# ___ If 1, runs this launcher as administrator at first launch
# Running from another PC, username or game folder, will do the same
run_admin = 1






Loading

0 comments on commit 5f22f82

Please sign in to comment.