-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdisable.cmd
More file actions
126 lines (107 loc) · 3.3 KB
/
disable.cmd
File metadata and controls
126 lines (107 loc) · 3.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
@echo off
:: Steam should NOT be running while the changes are applied. If so, the changes are just reverted upon restarting steam.
setlocal ENABLEDELAYEDEXPANSION
:: check if steam is running. inform user to close first. then exit.
call :checkSteam
:: make sure parameters were entered. if not, get input.
call :checkParameters %1
:: make sure the steamapps directory looks real. (check for acf files)
call :checkSteamappsExist
:: see if the script was run before, if so, warn user
call :checkPreviousRun
:: make a temporary directory for the script
call :createTempDir
cls
echo Updating Auto update behavior for...
echo -- -- -- -- Log Started %DATE% @ %TIME% -- -- -- -->>%~dp0\log.txt
pushd "%steamapps%"
:: Get list of acf files.
for %%a in (*.acf) do (
:: Look for acf files with "AutoUpdateBehavior" "0".
for /f "tokens=1,2 delims= " %%x in (%%a) do (
if %%x == "AutoUpdateBehavior" if %%y == "0" (
:: Create a backup of the file first, then write the file changing the one value.
echo %%a
echo %%a>>%~dp0\log.txt
call :backupFile %%a
call :writeChange %%a
)
)
)
popd
echo.>>%~dp0\log.txt
echo.
echo Cleaning up...
:: Clean up temp files.
del /q "%tempdir%">nul
rmdir "%tempdir%">nul
echo Done. Press any key to close this window.
pause>nul
goto :EOF
:writeChange
for /f "tokens=* delims=" %%n in (%1) do (
set line=%%n
for /f "tokens=1,2 delims= " %%r in ("!line!") do (
if %%r == "AutoUpdateBehavior" (
set line=!line:"0"="1"!
)
)
echo.!line!>>"%tempdir%\%1"
)
copy /y "%tempdir%\%1" "%1">nul
goto :EOF
:backupFile
if not exist acf-backups\ mkdir acf-backups
copy /y "%1" "acf-backups\%1">nul
goto :EOF
:createTempDir
set tempdir=%TEMP%\steam-autoupdate-script-temp-%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%
mkdir "%tempdir%"
goto :EOF
:checkParameters
if "%~1" == "" (
echo No parameters were passed to the script. You can drop a steam library folder onto this script or enter parameters at the command line.
echo.
echo You may also just drop the Steam library folder on this window right now. Or you can type it in and press enter.
echo.
echo Click the X to close this window or don't type anything and press enter to cancel and close this.
echo.
set /p userInput=Steam Library Path:
echo.
if "!userInput!" == "" exit
call :setSteamapps !userInput!
) else (
call :setSteamapps %1
)
goto :EOF
:checkPreviousRun
if exist "%steamapps%\acf-backups" (
echo It appears that you have already ran this script on this library.
echo A backup was made:
for %%x in (%steamapps%\acf-backups) do echo %%~tx
echo.
echo Press any key to continue, or click the X ^(close button^) on this window to cancel.
pause>nul
)
goto :EOF
:checkSteam
for /f "usebackq tokens=1" %%x in (`tasklist /fi "imagename eq steam.exe" /nh`) do (
if /i "%%x" == "Steam.exe" (
echo Steam appears to be running. Please close steam first. Press any key to close this window...
pause>nul
exit
)
)
goto :EOF
:checkSteamappsExist
if not exist "%steamapps%\*.acf" (
echo "%steamapps%"
echo Does not contain ACF files. Please make sure to drop the steam library folder. Example: C:\Program Files\Steam\ OR D:\Steam
echo The "steamapps" folder will exist within that folder. Press any key to close this window...
pause>nul
exit
)
goto :EOF
:setSteamapps
set steamapps=%~1\steamapps
goto :EOF