Update.cmd
- Code: Select all
@echo off
cls
title Installing updates . . .
Set LaunchPath=%~dp0
If "%LaunchPath:~-1%" == "\" (
Set LaunchPath=%LaunchPath:~0,-1%
)
REM Find Free Drive
REM Looping code from: https://ss64.org/viewtopic.php?pid=3657
Set Drives=Z Y X W V U T S R Q P O N M L K J I H G F E D C B A
set TN=1
:driveloop
set MapDrive=
for /f "tokens=%TN% " %%i in ("%Drives%") do (
set MapDrive=%%i
)
:: double quotes are important here, because string parts may contain spaces!
If "%MapDrive%" neq "" (
If NOT EXIST "%MapDrive%:\" (
Echo Using Drive: %MapDrive%:\
) ELSE (
SET /A TN+=1
goto:driveloop
)
)
If "%LaunchPath:~0,2%" == "\\" (
echo Network Path: %~dp0
net use %MapDrive%: %LaunchPath% /persistent:no
cd /D %MapDrive%:\cmd
call DoUpdate.cmd %*
cd /D %SystemDrive%
net use %MapDrive%: /delete
) else (
cd /D %~dp0cmd
call DoUpdate.cmd %*
)