• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

Issue with updating via batch

Solaris17

Super Dainty Moderator
Staff member
Joined
Aug 16, 2005
Messages
25,893 (3.79/day)
Location
Alabama
System Name Rocinante
Processor I9 14900KS
Motherboard EVGA z690 Dark KINGPIN (modded BIOS)
Cooling EK-AIO Elite 360 D-RGB
Memory 64GB Gskill Trident Z5 DDR5 6000 @6400
Video Card(s) MSI SUPRIM Liquid X 4090
Storage 1x 500GB 980 Pro | 1x 1TB 980 Pro | 1x 8TB Corsair MP400
Display(s) Odyssey OLED G9 G95SC
Case Lian Li o11 Evo Dynamic White
Audio Device(s) Moondrop S8's on Schiit Hel 2e
Power Supply Bequiet! Power Pro 12 1500w
Mouse Lamzu Atlantis mini (White)
Keyboard Monsgeek M3 Lavender, Akko Crystal Blues
VR HMD Quest 3
Software Windows 11
Benchmark Scores I dont have time for that.
As a proof of concept im attempting to update a batch file by having it check for a new "version" currently this is the code I have but set /p seems to not work.

Currently I use a text file with the version number in it. Ideally it should check this number and then decide if the current version is good or not. Unfortunately CMD gets stuck at setting the version and does not try to continue to bits. I heard of a way to use delims but im uncertain how this would work. This is what I have now.

Code:
set /p version=1.9.2

bitsadmin /transfer ATLAS /download /priority high http://www.teamdotexe.org/Downloads/version.txt "%userprofile%\desktop\version.txt"
set /p nwstvrsn=<version.txt
set nwstvrsn=%nwstvrsn: =%
if %version% lss %nwstvrsn% goto newupdateavailable
if %version%==%nwstvrsn% goto noupdateavailable

:newupdateavailable
echo Downloading Update
bitsadmin /transfer ATLAS /download /priority high http://www.teamdotexe.org/Downloads/"ATLAS %nwstvrsn%.bat" "%userprofile%\desktop\"

:noupdateavailable
echo No Update Available
 

FordGT90Concept

"I go fast!1!11!1!"
Joined
Oct 13, 2008
Messages
26,259 (4.63/day)
Location
IA, USA
System Name BY-2021
Processor AMD Ryzen 7 5800X (65w eco profile)
Motherboard MSI B550 Gaming Plus
Cooling Scythe Mugen (rev 5)
Memory 2 x Kingston HyperX DDR4-3200 32 GiB
Video Card(s) AMD Radeon RX 7900 XT
Storage Samsung 980 Pro, Seagate Exos X20 TB 7200 RPM
Display(s) Nixeus NX-EDG274K (3840x2160@144 DP) + Samsung SyncMaster 906BW (1440x900@60 HDMI-DVI)
Case Coolermaster HAF 932 w/ USB 3.0 5.25" bay + USB 3.2 (A+C) 3.5" bay
Audio Device(s) Realtek ALC1150, Micca OriGen+
Power Supply Enermax Platimax 850w
Mouse Nixeus REVEL-X
Keyboard Tesoro Excalibur
Software Windows 10 Home 64-bit
Benchmark Scores Faster than the tortoise; slower than the hare.
Are you intending to prompt the user for the version number? If not, you should be using /a and put it in quotes. If you haven't found it already this page should prove very helpful.
 

Solaris17

Super Dainty Moderator
Staff member
Joined
Aug 16, 2005
Messages
25,893 (3.79/day)
Location
Alabama
System Name Rocinante
Processor I9 14900KS
Motherboard EVGA z690 Dark KINGPIN (modded BIOS)
Cooling EK-AIO Elite 360 D-RGB
Memory 64GB Gskill Trident Z5 DDR5 6000 @6400
Video Card(s) MSI SUPRIM Liquid X 4090
Storage 1x 500GB 980 Pro | 1x 1TB 980 Pro | 1x 8TB Corsair MP400
Display(s) Odyssey OLED G9 G95SC
Case Lian Li o11 Evo Dynamic White
Audio Device(s) Moondrop S8's on Schiit Hel 2e
Power Supply Bequiet! Power Pro 12 1500w
Mouse Lamzu Atlantis mini (White)
Keyboard Monsgeek M3 Lavender, Akko Crystal Blues
VR HMD Quest 3
Software Windows 11
Benchmark Scores I dont have time for that.
I still couldnt get it to do what i really wanted it to do so I have a manual invoke in place.

Code:
:vcheck
@echo off
cls
bitsadmin /transfer Version /download /priority high http://www.teamdotexe.org/Downloads/version.txt "%userprofile%\desktop\version.txt"
Echo.
Echo Checking version of ATLAS on the server.
Echo.
Echo Current version is...
Echo.
type "%userprofile%\desktop\version.txt"
Echo.
Echo.
Echo Version of ATLAS running is %build%
Echo.
DEL "%userprofile%\desktop\version.txt"
Echo Do you want to update?
Echo.
Echo 1 = YES
Echo.
Echo 2 = NO
ECHO.
set choice=
ECHO.
Echo Select (1) or (2)
Echo.
set /p choice=
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto update
if '%choice%'=='2' goto menu

:update
@Echo off
cls
Echo.
bitsadmin /transfer ATLAS /download /priority high http://www.teamdotexe.org/Downloads/ATLAS.bat "%userprofile%\desktop\ATLAS-%random%.bat"
Echo.
Echo Download Complete!
Echo.
Echo Re-Run ATLAS after this window closes!
Echo.
goto end

that is the finished product above for those interested.

%build% is a set variable I have at the beginning of the batch. that is manually updated with each change. version.txt is changed on the server with each iteration.

in this instance ATLAS deletes itself in :END after downloading the new version from the server and appending a random number to the save so that it is not deleted.
 

OneMoar

There is Always Moar
Joined
Apr 9, 2010
Messages
8,746 (1.70/day)
Location
Rochester area
System Name RPC MK2.5
Processor Ryzen 5800x
Motherboard Gigabyte Aorus Pro V2
Cooling Enermax ETX-T50RGB
Memory CL16 BL2K16G36C16U4RL 3600 1:1 micron e-die
Video Card(s) GIGABYTE RTX 3070 Ti GAMING OC
Storage ADATA SX8200PRO NVME 512GB, Intel 545s 500GBSSD, ADATA SU800 SSD, 3TB Spinner
Display(s) LG Ultra Gear 32 1440p 165hz Dell 1440p 75hz
Case Phanteks P300 /w 300A front panel conversion
Audio Device(s) onboard
Power Supply SeaSonic Focus+ Platinum 750W
Mouse Kone burst Pro
Keyboard EVGA Z15
Software Windows 11 +startisallback
you need double quotes when using set /p
e.g
set/p "choice="
also remove the space between beween set and /p like the above
 

OneMoar

There is Always Moar
Joined
Apr 9, 2010
Messages
8,746 (1.70/day)
Location
Rochester area
System Name RPC MK2.5
Processor Ryzen 5800x
Motherboard Gigabyte Aorus Pro V2
Cooling Enermax ETX-T50RGB
Memory CL16 BL2K16G36C16U4RL 3600 1:1 micron e-die
Video Card(s) GIGABYTE RTX 3070 Ti GAMING OC
Storage ADATA SX8200PRO NVME 512GB, Intel 545s 500GBSSD, ADATA SU800 SSD, 3TB Spinner
Display(s) LG Ultra Gear 32 1440p 165hz Dell 1440p 75hz
Case Phanteks P300 /w 300A front panel conversion
Audio Device(s) onboard
Power Supply SeaSonic Focus+ Platinum 750W
Mouse Kone burst Pro
Keyboard EVGA Z15
Software Windows 11 +startisallback
like so
 
Top