Open Oreloth opened 1 month ago
It looks like you're encountering a permissions issue when trying to run the PowerShell script. Here’s a step-by-step guide to ensure you run PowerShell as an administrator and execute your script successfully:
This ensures that PowerShell has the necessary permissions to execute scripts and access resources that require administrative privileges. It seems the script didn't automatically run with admin privileges on your system, so we need to do this manually.
cd D:\Dossiers\Téléchargements
This command changes the current directory to D:\Dossiers\Téléchargements.
& '.\Once Human.ps1'
This command executes the script named Once Human.ps1 located in the current directory.
By following these steps, you should be able to run your PowerShell script with administrative privileges and avoid the error related to permissions. Running PowerShell as an administrator ensures that the script has the necessary permissions to perform actions that require elevated privileges.
It's okay for me, I'm SysAdmin, you can still run the PS terminal as admin with "Win + X, A" combination. The real problem is to fix this error for some of my friends, and probably many other people, since some users will be reluctant or will find it difficult to use such manipulations. I've tried to modify the script for the elevation request myself, but I can't see what the problem is, your script seems fine to me, it even works on some PCs, but not on others.
I took the liberty of recreating the script in Batch to make it more compatible and more reliable in terms of execution. In this case, permissions elevation works better. I'll leave you the script here, for now it just detects the game and change the hosts file.
@echo off
setlocal enabledelayedexpansion
:: Check for admin permissions and ask if necessary
if not "%1"=="am_admin" (powershell start -verb runas '%0' am_admin & exit /b)
set "Epic=0"
set "steamAppId=2139460"
set "gameName=Once Human"
set "gameExe=ONCE_HUMAN.exe"
:: Check if Steam is installed
if not exist "%ProgramFiles(x86)%\Steam\steam.exe" (
echo Steam is not installed. Please install Steam and try again.
pause
exit /b 1
)
:: Find the game installation path
for /f "tokens=2*" %%A in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App %steamAppId%" /v "InstallLocation" 2^>nul') do (
set "gamePath=%%B"
)
:: If not found in HKLM, try HKCU
if not defined gamePath (
for /f "tokens=2*" %%A in ('reg query "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App %steamAppId%" /v "InstallLocation" 2^>nul') do (
set "gamePath=%%B"
)
)
if not defined gamePath (
echo %gameName% is not installed. Please install the game through Steam and try again.
pause
exit /b 1
)
:: Check if the game executable exists
if not exist "%gamePath%\%gameExe%" (
echo %gameName% executable not found. Please verify the game installation.
pause
exit /b 1
)
:: Check if the game is already running
tasklist /FI "IMAGENAME eq %gameExe%" 2>NUL | find /I /N "%gameExe%">NUL
if not errorlevel 1 (
echo %gameName% is already running.
pause
exit /b 0
)
:: Define hosts file path and entries to add
set "hostsFile=%windir%\System32\drivers\etc\hosts"
set "entries=127.0.0.1 t.appsflyer.com 127.0.0.1 events.appsflyer.com 127.0.0.1 register.appsflyer.com 127.0.0.1 conversion.appsflyer.com 127.0.0.1 sdk.appsflyer.com"
:: Check and add entries to hosts file
echo Modifying hosts file...
for %%i in (%entries%) do (
findstr /c:"%%i" "%hostsFile%" >nul
if errorlevel 1 (
echo %%i >> "%hostsFile%"
echo Added: %%i
) else (
echo Already exists: %%i
)
)
:: Launch the game
echo Launching %gameName%...
start "" "steam://rungameid/%steamAppId%"
echo Script execution completed.
pause```
I followed instructions, but got these errors. Anything to help?