Jump to content

All my products and services are free. All my costs are met by donations I receive from my users. If you enjoy using any of my products, please donate to support me. Thank you for your support. Tom Speirs

Patreon

This batch file causes ePSXe to immediately end back to GameEx


G70Man

Recommended Posts

I've written this batch file to load registry keys for different controller setups on the ePSXe:

 

setlocal

set ouateonetoo=%~1
set "ouateonetoo=%ouateonetoo:~0,-3%"
set "ouateonetoo=%ouateonetoo%reg"
regedit.exe /s "%ouateonetoo%"

Sleep 5
endlocal

CD "C:\Program Files\ePSXe\"


It is set to run before as ctrlrreg.bat "[rompath]\[romfile]". It changes the extension from whatever it is to .reg then loads the file to the registry.

With this set to run before ePSXe, it does succeed and terminate after the sleep but then returns back to the game menu. If I set it so GameEx doesn't run the batch file, the emulator loads and works fine.

I've tried with and without the setlocal, the sleep, and the CD. My initial thought was that somehow the active directory was being changed by the process but nothing made any difference. I've also tried the reg restore command instead of regedit without any change.

If I run the batch file then the emulator outside GameEx, it works properly.

Anyone have any idea what might be going on here?

Link to comment
Share on other sites

Could be loads of things + that's where I started a couple of years ago - manipulating things via batch. Save yourself some grey hairs + heartburn by either:

a) Download Visual Studio Express + learn c# (will save you time in the long run). Batch will be a world of pain. 

or

b ) Try this:

This actually started with a need to maipulate PSX ROMS and manage per-game settings such as sharers, graphics and controls. So - you'll be able to save your controls per-game without faffing about with horrendously obscure and illogical batch idiosyncrasies. :)

Good luck

 

Link to comment
Share on other sites

54 minutes ago, stigzler said:

There is an old app that I think could help you:

ePSXeCutor

think it was around in the days of XP.

I was going to suggest the same thing, but didn't want to step on your toes.  ePSXeCutor works pretty well and I run it on Window 7.  AFAIK there are no issues with running it on more modern versions of Windows as well.

Here's some info on getting it set up in GameEx (keep reading beyond that post as well; setting up ePSXeCutor in GameEx is not for the faint of heart, but it works well once you do so).

Link to comment
Share on other sites

@nullPointer - no worries - I aint precious about me toes - all about options, right?

@G70Man - did have another thought. You could try Emvoy but this may be a little overkill for your needs. Alternatively, you could use this batch:

Spoiler

echo off
setlocal enableextensions enabledelayedexpansion
echo =======================================================
echo ePSXe Settings Script
echo =======================================================
:: ======================================================
:: ePSXe Settings Importer/Exporter
:: By Stigzler 2014
:: Search CodePlex EmVoy
:: Designed to be used with EmVoy utility but can be stand alone
:: Run util with parameters for game specific operation
:: Run util without parameters to grab current emu settings and save as default profile
:: ======================================================
:: Command Line Parameters - MUST BE PASSED IN THIS ORDER
:: 1 - Import or Export - = grab or populate settings from/to emulator. Values: "imp" or "exp" or "def" (imports to 'default')
:: 2 - Emulator Path - full path to Emu - ENCLOSE IN QUOTES
:: 3 - Gamename - this will be the name of the folder where settings are stored - ENCLOSE IN QUOTES
:: 4 - History - creates a history of settings - "Yes" or "No"(minus quotes)- Defaults to no if not passed
:: ======================================================
:: e.g. To run:
:: "C:\Scripts\EmVoy_ePSXe.bat" imp "C:\Emulators\ePSXe\ePSXe200" "Wipeout" Yes
:: =====================================================        
:: Admin Check
echo Full command line recieved:
echo %*
echo =======================================================
echo.
echo Administrative permissions required. Detecting permissions...
net session >nul 2>&1
if '%errorlevel%' == '0' (
        echo SUCCESS: Administrative permissions confirmed.
        ::pause
        goto START 
    ) else ( 
        echo ERROR: Script does not have admin status. Attempting elevation. May fail..
        ::pause
        cd /d "%~dp0"
        echo %time% > flagfile.ini
        goto getPrivileges ) 
:getPrivileges
if '%1'=='ELEV' ( goto START )

set "batchPath=%~f0"
set "batchArgs=ELEV"

::Add quotes to the batch path, if needed
set "script=%0"
set script=%script:"=%
IF '%0'=='!script!' ( GOTO PathQuotesDone )
    set "batchPath=""%batchPath%"""
:PathQuotesDone

::Add quotes to the arguments, if needed.
:ArgLoop
IF '%1'=='' ( GOTO EndArgLoop ) else ( GOTO AddArg )
    :AddArg
    set "arg=%1"
    set arg=%arg:"=%
    IF '%1'=='!arg!' ( GOTO NoQuotes )
        set "batchArgs=%batchArgs% "%1""
        GOTO QuotesDone
        :NoQuotes
        set "batchArgs=%batchArgs% %1"
    :QuotesDone
    shift
    GOTO ArgLoop
:EndArgLoop

::Create and run the vb script to elevate the batch file
ECHO Set UAC = CreateObject^("Shell.Application"^) > "%temp%\OEgetPrivileges.vbs"
ECHO UAC.ShellExecute "cmd", "/c ""!batchPath! !batchArgs!""", "", "runas", 1 >> "%temp%\OEgetPrivileges.vbs"
"%temp%\OEgetPrivileges.vbs" 

:: Monitor child process for closure:
:wait
PING 1.1.1.1 -n 1 -w 100 >NUL
if exist flagfile.* goto :wait
echo Child Process Finished...
exit

:START
::Remove the elevation tag and set the correct working directory
IF '%1'=='ELEV' ( shift /1 )
cd /d "%~dp0"
:: =====================================================

set impexp=%1
set emupath=%2
set gamename=%3
set history=%4
if not defined impexp (
        echo No command parameters, grabbing settings and writing to default...
        set impexp=imp
        set gamename=default
        set history=Yes
:ReEnter
        set /p emupath=Enter the path the ePSXe.exe here: 
        if exist !emupath!\ePSXe.exe (
                echo Correct path. Continuing with set default settings process....
            ) else ( 
                echo Incorrect path, please re-enter. 
                goto :ReEnter
            )
        set emupath=!emupath!\
        echo Emu Path set as: [!emupath!]
    )
if %impexp% == def (
        echo def tag passed - grabbing settings and writing to default...
        set impexp=imp
        set gamename=default
        set history=Yes
    )
if not defined gamename call :Error "Mode set, but no emulator path passed. Can't complete script. Quitting....."
if not defined gamename call :Error "Mode set, but no gamename passed. Can't complete script. Quitting....."
if not defined history set history=No

:ValidateParams
::Passed variables validation
echo Validating passed variables:
echo Emulator Path=%emupath%
set emupath=%emupath:"=%
echo Ammended E ulator Path=%emupath%
echo Gamename=%gamename%
set gamename=%gamename:"=%
echo Ammended Gamename=%gamename%
echo Import or Export = %impexp% 
set res=False
if %impexp% == imp set res=true
if %impexp% == exp set res=true
if %res% == true (
    echo Import Export switch valid
    ) else (
        echo Import/Export switch Invalid! Stopping Script.
        exit /b 
    )
        
echo Preserve History = %history%
set res=False
if %history% == Yes set res=true
if %history% == No set res=true
if %res% == true (
    echo History switch valid
    ) else (
        echo History switch Invalid! Stopping Script.
        exit )
        
        
:: ========================================================
:: Global Variables
set timestamp=%DATE:/=-%@%TIME::=-%
set timestamp=%timestamp: =%
set filenamegb=default
set filenamepb=default

:: =====================================================
:: User Variables - SET HERE!

:: Path pcsxr game settings folder:
set ScriptPath=%~dp0
set ScriptPath=%ScriptPath:~0,-1%
set settpath=%ScriptPath%\epsxe
:: Set up filenames for general and plugin settings:
echo *** Constructing filenames....
set filenameg="%gamename%_general.reg"
set filenamep="%gamename%_plugins.reg"
echo *** General Settings Filename: %filenameg%
echo *** Plugin Settings Filename: %filenamep%

:: ========================================================
:: Code ----------------------------------------------
echo ====================================================================================================
Echo ** Choosing Export or Import:
If %impexp% == imp (
    echo ** Start Import Process
    call :ImportSettings
    echo ** Settings Imported from Emulator!    )
If %impexp% == exp (
    echo ** Start Export Process
    call :ExportSettings
    echo ** Export process finished!    )
echo **** Ending Game Setting process. 
echo Killing any parent windows
cd /d "%~dp0"
del flagfile.*
::pause
exit
    
:: ======================================================
:: Subroutines

:Error [message]
echo Uh oh... Fatal Error: %~1 
echo Shutting down script
pause
exit /b 

:ImportSettings
:: Create/set folders for game
%settpath:~0,2%
cd %settpath%
echo *** Lining up Game folder...
if exist "%gamename%" (
    echo *** Game folder already exists - selecting directory
    cd "%gamename%"
    ) else (
    echo *** Creating new game folder and selecting directory
    mkdir "%gamename%"
    cd "%gamename%")

:: if history required:
echo *** User History request- history flag is "%history%"

:: Start of long if.---------------------------------------------------------
if "%history%" == "Yes" (
    :: setup folders + backup files
    echo **** User requiring backups - setup folders...
    if exist backup (
        echo **** Game settings backup folder already exists
    ) else (
        echo **** Game settings backup folder does not exist - creating new backup folder
        mkdir backup )
    set filenamegb="%gamename%_general_%timestamp%.reg"
    set filenamepb="%gamename%_plugins_%timestamp%.reg"
    echo **** Setting backup filenames:
    echo **** new General Settings Backup Filename: !filenamegb!
    echo **** new Plugin Settings Backup Filename: !filenamepb!
    :: test if any file to back up and do it
        echo **** Creating timestamped folder in backup + copying files...
        mkdir "backup\%timestamp%"
        copy /y *.* backup\!timestamp!
        echo **** Files backed up.
) else (
    :: No history required
    echo **** User not requiring History )
:: End IF ----------------------------------------------------------

:: Read reg values and save to files
echo *** Creating new Settings files...
echo Current directory: %CD%
echo *** Registry settings being grabbed:
regedit /E "%filenameg:"=%" "HKEY_CURRENT_USER\Software\epsxe"
regedit /E "%filenamep:"=%" "HKEY_CURRENT_USER\Software\Vision Thing"
echo *** Reg settings grabbed and files written.
:: Copy Memory Cards
echo *** Memory cards being saved:
copy /y "%emupath%memcards\*.mcr"
echo *** Memory cards saved.
:: Copy any ini created by plugins, left in plugin folder 
echo *** Any plugin inis being saved:
copy /y "%emupath%plugins\*.ini"
echo *** Reg plugin inis saved.
echo *** Ending Import Settings Routine
GOTO :EOF

:ExportSettings
Echo Loading game settings into registry
%settpath:~0,2%
cd %settpath%
echo Check whether folder exists (if doesn't - first run)
if exist "%gamename%" (
        echo Folder Exists - carry on with process
    ) else (
        echo Folder doesn't exist - loading defaults.
        set filenameg=default_general.reg
        set filenamep=default_plugins.reg
        set gamename=default
    )
cd "%gamename%"
echo Current directory: %CD%
echo Going onto load reg values....
::pause
regedit /S "%filenamep:"=%"
regedit /S "%filenameg:"=%"
echo Reg values loaded. Moving game memory cards and any inis to epsxe...
copy *.mcr "%emupath%memcards\"
copy *.ini "%emupath%plugins\"

::pause
GOTO :EOF
:: ========================================================

 

  • Like 1
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...