I'm very new to using batch files and programming in cmd. After failing to find a free wallpaper program that would set a specific wallpaper at a specific time, and supported dual monitors, I decided to create a batch file that pulls the time of day (in military format) and uses if statements to set the appropriate wallpaper if it hasn't already been set. Here's a section of the code so far:
@echo off
set /A mystate=0
:start
For /f "tokens=1-2 delims=/:" %%a in ("%TIME%") do (set mytime=%%a%%b)
if %mytime% lss 800 (
if NOT %mystate% == 1 (
reg add "HKCU\Control Panel\Desktop" /v Wallpaper /f /t REG_SZ /d C:\Users\zach.norstedt\Pictures\Wallpaper\ASunrise.jpg
:: Change last number to 0 to not tile, set it to 1 to tile.
reg add "HKCU\Control Panel\Desktop" /v TileWallpaper /t REG_SZ /f /d 1
:: The following lines energize desktop.
%SystemRoot%\System32\RUNDLL32.EXE user32.dll, UpdatePerUserSystemParameters
set /A mystate=1
)
)
sleep 1
goto start
Running this file gives the error "The syntax of the command is incorrect.", so I know at least one of my commands doesn't have the right syntax but I can't figure out which one it is. Most of this code was copied and pasted from different sources across the internet. I have effectively no knowledge of correct cmd syntax.