Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: batch goto issue
05-13-2007, 12:32 AM #1
- Join Date
- Nov 2004
- Thanked 0 Times in 0 Posts
batch goto issue
im working on getting a batch file for a autoinstall after windows installes its self.
for updates and open office.
i have got everything done except the goto dose not work.
this is what i have so far.
@echo on @set /P SDDRIVELETTER=Please enter the driveletter for your flash drive: @cd %SDDRIVELETTER%:\ @pause @if exist C:\office.txt goto error @if not exist C:\office.txt goto office @:error @echo office is allready installed @goto update @:office @set /P YESNO=do u want to install open office(y/n): @If /I %YESNO% == 'y' then goto setup @pause @:update @echo running updates>>C:\updates.txt @if exist C:\1.txt goto 2 @echo running kb00001>>C:\1.txt @goto 2 @:2 @if exist C:\2.txt goto 3 @echo running kb00002>>C:\2.txt @echo Windows Registry Editor Version 5.00 >>C:\test.reg @echo [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\RunOnce]>>C:\test.reg @echo "batch"="%SDDRIVELETTER%:\\1.bat">>C:\test.reg @regedit /s C:\test.reg @shutdown.exe -r -t 10 -f @:3 @echo all updates are done @pause @goto end @:setup @echo running openoffice install>>C:\office.txt @pause @goto update @:end
@set /P YESNO=do u want to install open office(y/n):
@If /I %YESNO% == 'y' then goto setup
what am i missing?
05-14-2007, 01:06 AM #2
- Join Date
- Apr 2003
- Thanked 13 Times in 13 Posts
Is the syntax of that if correct? Batch uses something likeCode:
if condition ( do something ) else ( do something else )
I think you are over complicating the whole thing, you can probably cut the whole thing down to very few lines and may be able to completely remove the GOTOs and the labels.
Also, you have completely misused the @s. "echo on" says from now on print all the commands to the console as it runs. @ at the start of a line says "hide this line".
@echo on @do something @do something elseCode:
@do something @do something elseCode:
@echo off do something do something else