Need help with a Script

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Superman6791
Posts: 2
Joined: 01 Aug 2010 21:37

Need help with a Script

#1 Post by Superman6791 » 01 Aug 2010 21:49

Hi, I am new on this site. I used to do a lot of batch coding, but I stopped for a while. I have just made a little script while I was bored, but there is a problem. The problem is I cannot access anything past the Main Menu. I do realize that I don't have a section that is made for the Script section, but that is not what won't work. I can't access the Wallpaper Selection Menu. The script is below.

Code: Select all

@echo off
title l-(O)-(O)-l Glasses l-(O)-(O)-l
color 0a
:start
cls
set 1=Wallpaper
set 2=Script
set 3=Exit
echo Welcome to Glasses, a program designed to make your
echo Windows experience much easier and more comforting.
echo What would you like to do?
echo.
echo Commands are listed below...
echo.
echo Wallpaper = Change the desktop wallpaper.
echo Script = Create and Run a script for Windows.
echo Exit = Exit Glasses.
echo.
set /p a =
if %a%==%1% goto Background
if %a%==%2% goto Script
if %a%==%3% goto Quit
cls
echo That is not a valid command!
echo.
echo.
pause
goto start

:Background
set FP=1
set WF=2
set JG=3
set PP=4
set KT=5
set GP=6
set RB=7
set A1=8
set SX=9
set CC=10
cls
echo We have an Archive of very select Wallpapers.
echo Select your Wallpaper...
echo.
echo.
echo 1. Fireplace
echo 2. Waterfall
echo 3. Jungle
echo 4. Puppy
echo 5. Kitten
echo 6. Music
echo 7. Rainbow
echo 8. Abstract
echo 9. Sexy
echo 10. Cancel
echo.
set /p BG =
if %BG%==%FP% goto FP
if %BG%==%WF% goto WF
if %BG%==%JG% goto JG
if %BG%==%PP% goto PP
if %BG%==%KT% goto KT
if %BG%==%GP% goto GP
if %BG%==%RB% goto RB
if %BG%==%A1% goto A1
if %BG%==%SX% goto SX
if %BG%==%CC% goto Start
echo That is not a valid selection!
echo.
pause
goto Background

:FP
reg /add HKCU\Control Panel\Desktop\WallPaper /v wallpaper /t REG_SZ /d
C:\Program Files\Glasses\Wallpapers\Fireplace.jpg
pause /nul
goto Start
:WF
reg /add HKCU\Control Panel\Desktop\WallPaper /v wallpaper /t REG_SZ /d
C:\Program Files\Glasses\Wallpapers\Waterfall.jpg
pause /nul
goto Start
:JG
reg /add HKCU\Control Panel\Desktop\WallPaper /v wallpaper /t REG_SZ /d
C:\Program Files\Glasses\Wallpapers\Jungle.jpg
pause /nul
goto Start
:PP
reg /add HKCU\Control Panel\Desktop\WallPaper /v wallpaper /t REG_SZ /d
C:\Program Files\Glasses\Wallpapers\Puppy.jpg
pause /nul
goto Start
:KT
reg /add HKCU\Control Panel\Desktop\WallPaper /v wallpaper /t REG_SZ /d
C:\Program Files\Glasses\Wallpapers\Kitten.jpg
pause /nul
goto Start
:GP
reg /add HKCU\Control Panel\Desktop\WallPaper /v wallpaper /t REG_SZ /d
C:\Program Files\Glasses\Wallpapers\Music.jpg
pause /nul
goto Start
:RB
reg /add HKCU\Control Panel\Desktop\WallPaper /v wallpaper /t REG_SZ /d
C:\Program Files\Glasses\Wallpapers\Rainbow.jpg
pause /nul
goto Start
:A1
reg /add HKCU\Control Panel\Desktop\WallPaper /v wallpaper /t REG_SZ /d
C:\Program Files\Glasses\Wallpapers\Abstract.jpg
pause /nul
goto Start
:SX
reg /add HKCU\Control Panel\Desktop\WallPaper /v wallpaper /t REG_SZ /d
C:\Program Files\Glasses\Wallpapers\Sexy.jpg
pause /nul
goto Start
:Quit
echo Made by Compromptguy(Youtube)
echo.
pause /nul
close

avery_larry
Expert
Posts: 391
Joined: 19 Mar 2009 08:47
Location: Iowa

Re: Need help with a Script

#2 Post by avery_larry » 02 Aug 2010 10:38

set a = something

That includes a space in the name of the variable:

echo %a%
is nothing.
echo %a %
is something

So change to

set /p a=

with no space before or after the "a"

Later:

if %a%==%1%

is referencing a variable named "1". I believe you want:

if "%a%"=="1" goto background

I recommend using the quotes because the script will choke if "a" is undefined. In this example, that's basically impossible -- but it's good practice.

Post Reply