Skip to content

Instantly share code, notes, and snippets.

@maca134
Created April 20, 2021 15:46
Show Gist options
  • Save maca134/9bbe75e3096a94913df69d906926fa28 to your computer and use it in GitHub Desktop.
Save maca134/9bbe75e3096a94913df69d906926fa28 to your computer and use it in GitHub Desktop.
Workshop Uploader
@ECHO off
SETLOCAL enableextensions enabledelayedexpansion
CD /D "%~dp0"
SET BASEPATH=%~dp0
REM =============================[CONFIG START]=============================
SET STEAMCMDPATH=.steamcmd
REM Steam login details, you may need to run this twice if you have Auth Guard enabled (which you should)
SET STEAMUSERNAME=
SET STEAMPASSWORD=
SET STEAMAUTHGUARD=
REM 221100 for dayz 107410 for arma3
SET APPID=221100
REM Set to 0 when uploading new mod or the workshop id when updating
SET WORKSHOPID=0
SET MODPATH=C:\Path\To\@MyMod
SET MODTITLE=Some Title
SET MODDESCRIPTION=Some description
SET MODIMAGE=C:\Path\To\preview.jpg
REM 0 is PUBLIC, 1 is Friends Only, 2 is HIDDEN
SET MODVISIBILITY=1
REM ==============================[CONFIG END]==============================
SET STEAMCMD=%STEAMCMDPATH%\steamcmd.exe
ECHO Checking for SteamCMD
IF NOT EXIST "%STEAMCMD%" CALL :DOWNLOADSTEAMCMD "%STEAMCMDPATH%"
ECHO Copying content to temp folder
MKDIR "%BASEPATH%.tmp\content"
XCOPY "%MODPATH%" "%BASEPATH%.tmp\content\" /E
ECHO Creating meta.cpp
SET METACPP=%BASEPATH%.tmp\content\meta.cpp
IF EXIST "%METACPP%" DEL "%METACPP%"
FOR /F "tokens=*" %%g IN ('powershell.exe -Command [DateTime]::UtcNow.ToBinary^(^).ToString^(^)') DO SET TIMESTAMP=%%g
ECHO protocol = 1;>>"%METACPP%"
ECHO publishedid = %WORKSHOPID%;>>"%METACPP%"
ECHO name = "%MODTITLE%";>>"%METACPP%"
ECHO timestamp = %TIMESTAMP%;>>"%METACPP%"
ECHO Creating VDF file
SET VDFFILE=%BASEPATH%.tmp\mod.vdf
IF EXIST "%VDFFILE%" DEL "%VDFFILE%"
ECHO "workshopitem">>"%VDFFILE%"
ECHO {>>"%VDFFILE%"
ECHO "appid" "%APPID%">>"%VDFFILE%"
ECHO "publishedfileid" "%WORKSHOPID%">>"%VDFFILE%"
ECHO "contentfolder" "%BASEPATH%.tmp\content">>"%VDFFILE%"
ECHO "previewfile" "%MODIMAGE%">>"%VDFFILE%"
ECHO "visibility" "%MODVISIBILITY%">>"%VDFFILE%"
ECHO "title" "%MODTITLE%">>"%VDFFILE%"
ECHO "description" "%MODDESCRIPTION%">>"%VDFFILE%"
ECHO "changenote" "">>"%VDFFILE%"
ECHO }>>"%VDFFILE%"
ECHO Uploading mod to Steam
SET STEAMCMDARGS=+@ShutdownOnFailedCommand 1 +@NoPromptForPassword 1
IF NOT "%STEAMAUTHGUARD%"=="" SET STEAMCMDARGS=%STEAMCMDARGS% +set_steam_guard_code %STEAMAUTHGUARD%
SET STEAMCMDARGS=%STEAMCMDARGS% +login %STEAMUSERNAME% %STEAMPASSWORD% +workshop_build_item "%VDFFILE%" +quit
"%STEAMCMD%" %STEAMCMDARGS%
ECHO.
ECHO Upload complete
ECHO Removing temp folder
RMDIR /S /Q "%BASEPATH%.tmp"
PAUSE
GOTO :EOF
:DOWNLOADSTEAMCMD
ECHO Downloading SteamCMD
IF EXIST "%~1" RMDIR /S /Q "%~1"
MKDIR %~1
powershell.exe -Command (new-object System.Net.WebClient).DownloadFile('https://steamcdn-a.akamaihd.net/client/installer/steamcmd.zip', '%~1\steamcmd.zip')
powershell.exe -Command Expand-Archive -LiteralPath '%~1\steamcmd.zip' -DestinationPath '%~1'
DEL "%~1\steamcmd.zip"
"%~1\steamcmd.exe" +quit
EXIT /b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment