Sign in to follow this  
Followers 0
Arnold

Steam tool

2 posts in this topic

Steam tool

(use at your own risk)

 

TESTED ON 64-BIT WINDOWS 10 PRO ENGLISH VERSION

ONLY SUPPORTS DEFAULT STEAM INSTALLATION FOLDER!

 

 

What it does:

Automatically links your Steam games and userdata to use target drive and/or backs up your Steam userdata and games to target drive.

 

How it works:

1. If C:\Program Files (x86)\Steam\userdata folder (not symbolic link) exists this tool backs up its contents to X:\Program Files (x86)\Steam\userdata folder every time you start your computer (unless /NOBACKUP argument is present). The hidden flag is set on the folder on the target drive.

 

2. If C:\Program Files (x86)\Steam\userdata folder (or symbolic link) does NOT exist this tool creates a symbolic link (with hidden and not content indexed flags) in C:\Program Files (x86)\Steam directory to point to X:\Program Files (x86)\Steam\userdata folder.

 

3. If a C:\Program Files (x86)\Steam\steamapps\common\<game> folder (not symbolic link) exists this tool backs up its contents to X:\Program Files (x86)\Steam\steamapps\common\<game> folder every time you start your computer (unless /NOBACKUP argument is present). The hidden flag is set on the folder on the target drive.

 

4. If a C:\Program Files (x86)\Steam\steamapps\common\<game> folder (or symbolic link) does NOT exist but X:\Program Files (x86)\Steam\steamapps\common\<game> folder DOES exist (without the hidden flag) this tool creates a symbolic link (with hidden and not content indexed flags) in your C:\Program Files (x86)\Steam\steamapps\common\ directory to point to X:\Program Files (x86)\Steam\steamapps\common\<game> folder.

 

5. Keeps your app manifest files up to date in both C:\Program Files (x86)\Steam\steamapps folder and X:\Program Files (x86)\Steam\steamapps folder.

 

How to use:

 

INSTALLING:

1. Create a new file named __Steam.bat with the following contents in your TARGET DRIVE ROOT FOLDER:

:: __Steam.bat
:: Copyright (c) 2016 Otso O.
 
@ECHO OFF
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
 
IF EXIST "%ProgramFiles%\Steam" (
    SET "PROGRAMFILESPATH=%ProgramFiles%"
    SET "STEAMPATH=%ProgramFiles%\Steam"
    SET "PROGRAMFILESPATH2=%~d0\Program Files"
    SET "STEAMPATH2=%~d0\Program Files\Steam"
    GOTO :SETUP
) ELSE (
    IF EXIST "%ProgramFiles(x86)%\Steam" (
        SET "PROGRAMFILESPATH=%ProgramFiles(x86)%"
        SET "STEAMPATH=%ProgramFiles(x86)%\Steam"
        SET "PROGRAMFILESPATH2=%~d0\Program Files (x86)"
        SET "STEAMPATH2=%~d0\Program Files (x86)\Steam"
        GOTO :SETUP
    )
    
    MSG "%USERNAME%" "__Steam.bat: Steam installation not found!"
    ENDLOCAL
    EXIT /B 1
)
 
:SETUP
IF NOT EXIST "%~d0\__SteamSetup.txt" (
    GOTO :STEAM
)
 
DEL "%~d0\__SteamSetup.txt"    
 
IF NOT EXIST "%PROGRAMFILESPATH2%" MKDIR "%PROGRAMFILESPATH2%"    
IF NOT EXIST "%STEAMPATH2%" MKDIR "%STEAMPATH2%"
 
SET "TMPBATCH=%TEMP%\%RANDOM%%RANDOM%%RANDOM%.bat"
SET "TMPACL=%TEMP%\%RANDOM%%RANDOM%%RANDOM%.tmp"
SET "TMPACL2=%TEMP%\%RANDOM%%RANDOM%%RANDOM%.tmp"
ECHO @ECHO OFF > "%TMPBATCH%"
ECHO SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION >> "%TMPBATCH%"
ECHO. >> "%TMPBATCH%"
ECHO TAKEOWN /F "%PROGRAMFILESPATH2%" ^> NUL >> "%TMPBATCH%"
ECHO ICACLS "%PROGRAMFILESPATH2%" /RESET /C /Q >> "%TMPBATCH%"
ECHO ICACLS "%PROGRAMFILESPATH2%" /SETOWNER "NT SERVICE\TrustedInstaller" /C >> "%TMPBATCH%"
ECHO ICACLS "%PROGRAMFILESPATH%" /SAVE "%TMPACL%" /C >> "%TMPBATCH%"
ECHO ICACLS "%PROGRAMFILESPATH2%" /INHERITANCE:D /C >> "%TMPBATCH%"
ECHO ICACLS "%PROGRAMFILESPATH2%\.." /RESTORE "%TMPACL%" /C >> "%TMPBATCH%"
ECHO ATTRIB +R "%PROGRAMFILESPATH2%" >> "%TMPBATCH%"
ECHO DEL "%TMPACL%" >> "%TMPBATCH%"
ECHO. >> "%TMPBATCH%"
ECHO TAKEOWN /F "%STEAMPATH2%" /R /SKIPSL ^> NUL >> "%TMPBATCH%"
ECHO ICACLS "%STEAMPATH2%" /RESET /T /C /Q >> "%TMPBATCH%"
ECHO ICACLS "%STEAMPATH2%" /SETOWNER "BUILTIN\Administrators" /C >> "%TMPBATCH%"
ECHO ICACLS "%STEAMPATH%" /SAVE "%TMPACL2%" /C >> "%TMPBATCH%"
ECHO ICACLS "%STEAMPATH2%" /INHERITANCE:E /C >> "%TMPBATCH%"
ECHO ICACLS "%STEAMPATH2%\.." /RESTORE "%TMPACL2%" /C >> "%TMPBATCH%"
ECHO DEL "%TMPACL2%" >> "%TMPBATCH%"
ECHO. >> "%TMPBATCH%"
ECHO ECHO. ^> "%~d0\__SteamSetupComplete.txt" >> "%TMPBATCH%"
ECHO. >> "%TMPBATCH%"
ECHO ENDLOCAL >> "%TMPBATCH%"
 
SET "TMPSCRIPT=%TEMP%\%RANDOM%%RANDOM%%RANDOM%.vbs"    
ECHO Set objShell = CreateObject^("Shell.Application"^) > "%TMPSCRIPT%"
ECHO objShell.ShellExecute "CMD.exe", "/C START /MIN %TMPBATCH% ^& EXIT", "", "RUNAS" >> "%TMPSCRIPT%"
 
CSCRIPT //NOLOGO "%TMPSCRIPT%"
 
:WAIT
PING -N 1 127.0.0.1 > NUL
IF NOT EXIST "%~d0\__SteamSetupComplete.txt" GOTO :WAIT
DEL "%~d0\__SteamSetupComplete.txt"
 
IF NOT EXIST "%STEAMPATH2%\steamapps" MKDIR "%STEAMPATH2%\steamapps"
IF NOT EXIST "%STEAMPATH2%\steamapps\common" MKDIR "%STEAMPATH2%\steamapps\common"    
IF NOT EXIST "%STEAMPATH2%\userdata" MKDIR "%STEAMPATH2%\userdata"
 
DEL "%TMPBATCH%"
DEL "%TMPSCRIPT%"
 
:STEAM
IF NOT EXIST "%STEAMPATH2%\steamapps" (
    MSG "%USERNAME%" "__Steam.bat: %STEAMPATH2%\steamapps directory does not exist!"
    ENDLOCAL
    EXIT /B 1
)
    
IF NOT EXIST "%STEAMPATH2%\steamapps\common" (
    MSG "%USERNAME%" "__Steam.bat: %STEAMPATH2%\steamapps\common directory does not exist!"
    ENDLOCAL
    EXIT /B 1
)
 
IF NOT EXIST "%STEAMPATH2%\userdata" (
    MSG "%USERNAME%" "__Steam.bat: %STEAMPATH2%\userdata directory does not exist!"
    ENDLOCAL
    EXIT /B 1
)
 
IF NOT EXIST "%STEAMPATH%\steamapps" MKDIR "%STEAMPATH%\steamapps"    
IF NOT EXIST "%STEAMPATH%\steamapps\common" MKDIR "%STEAMPATH%\steamapps\common"
 
SET "NOBACKUP=FALSE"
IF /I "%~1"=="/NOBACKUP" SET "NOBACKUP=TRUE"
    
IF NOT EXIST "%STEAMPATH%\userdata" (
    MKLINK /J "%STEAMPATH%\userdata" "%STEAMPATH2%\userdata"
    ATTRIB +H +I "%STEAMPATH%\userdata" /L
    ATTRIB -H "%STEAMPATH2%\userdata"
) ELSE (
    FOR %%A IN ("%STEAMPATH%\userdata") DO (
        SET "ATTRIBUTES=%%~aA"
        IF /I NOT "!ATTRIBUTES:~8,1!"=="L" (
            IF "!NOBACKUP!"=="FALSE" (
                ROBOCOPY "%STEAMPATH%\userdata" "%STEAMPATH2%\userdata" /S /E /DCOPY:DT /COPY:DT /XO /R:1 /W:1
                ATTRIB +H "%STEAMPATH2%\userdata"
            )
        )
    )
)
 
SET "MANIFESTS=FALSE"
IF EXIST "%STEAMPATH2%\steamapps\*.acf" SET "MANIFESTS=TRUE"
IF EXIST "%STEAMPATH%\steamapps\*.acf" SET "MANIFESTS=TRUE"
 
IF "!MANIFESTS!"=="TRUE" (
    ROBOCOPY "%STEAMPATH2%\steamapps" "%STEAMPATH%\steamapps" "*.acf" /NODCOPY /COPY:DT /XO /R:1 /W:1
    ROBOCOPY "%STEAMPATH%\steamapps" "%STEAMPATH2%\steamapps" "*.acf" /NODCOPY /COPY:DT /XO /R:1 /W:1
)
 
FOR /F "TOKENS=*" %%A IN ('DIR "%STEAMPATH2%\steamapps\common" /A:D-H /B') DO (
    IF NOT EXIST "%STEAMPATH%\steamapps\common\%%~A" (
        MKLINK /J "%STEAMPATH%\steamapps\common\%%~A" "%STEAMPATH2%\steamapps\common\%%~A"
        ATTRIB +H +I "%STEAMPATH%\steamapps\common\%%~A" /L
        ATTRIB -H "%STEAMPATH2%\steamapps\common\%%~A"
    )
)
                
IF "!NOBACKUP!"=="FALSE" (
    FOR /F "TOKENS=*" %%A IN ('DIR "%STEAMPATH%\steamapps\common" /A:D-H-L /B') DO (
        IF NOT EXIST "%STEAMPATH2%\steamapps\common\%%~A" MKDIR "%STEAMPATH2%\steamapps\common\%%~A"
        
        ROBOCOPY "%STEAMPATH%\steamapps\common\%%~A" "%STEAMPATH2%\steamapps\common\%%~A" /S /E /DCOPY:DT /COPY:DT /XO /R:1 /W:1
        ATTRIB +H "%STEAMPATH2%\steamapps\common\%%~A"
    )
)
 
ENDLOCAL
EXIT /B 0

2. Right click on __Steam.bat -> Create shortcut

3. Move the SHORTCUT into C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp folder

4. Edit the shortcut properties if you want to (/NOBACKUP, start minimized etc. etc.)

 

FIRST TIME SETUP:

1. EXIT Steam

2. Open Task Manager -> Startup -> Steam Client Bootstrapper -> DISABLE

3. (optional) Move userdata folder to X:\Program Files (x86)\Steam folder

4. (optional) Move any game folders you want to X:\Program Files (x86)\Steam\steamapps\common folder

5. Create file named __SteamSetup.txt in your TARGET DRIVE ROOT FOLDER

6. Restart your computer

7. Click YES on UAC prompt if needed

8. Open Task Manager -> Startup -> Steam Client Bootstrapper -> ENABLE

9. RUN Steam

 

UNINSTALLING:

1. Delete the SHORTCUT from C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp folder

2. Delete the __Steam.bat

 

Notes:

X: is the target drive

C: is the system drive

Program Files (x86) is Program Files on 32-bit windows

 

To preserve the Windows default settings:

Access control lists (security settings) of C:\Program Files (x86) and C:\Program Files (x86)\Steam folders are copied to the respective folders on drive X: during first time setup.

 

TrustedInstaller is set as the owner of X:\Program Files (x86) folder during first time setup.

 

Administrators is set as the owner of X:\Program Files (x86)\Steam folder during first time setup.

 

<user name> is set as the owner of X:\Program Files (x86)\Steam\* folders during first time setup.

 

The read only ® flag is set on X:\Program Files (x86) folder during first time setup.

 

Any symbolic links created by the tool on C: drive will have the hidden flag (H) and the not context indexed flag (I) set.

 

Any backups created or modified by the tool on X: drive will have the hidden flag (H) set.

2

Share this post


Link to post
Share on other sites

Let me know if you would have use for this kind of tool and I'll maybe make it into a .exe that is easier to use and supports user-defined folders & rules :angryarnold:

0

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  
Followers 0