Jump to content
MSFN is made available via donations, subscriptions and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. ×

need some help for batfile


suos
 Share

Recommended Posts

Hello,

ik would like to make a batfile to install a progie.

ik have a batfile that runs a unattended install, but ik would like to give the user the option to cancel install or go back to the menu. So that the user can choose for another program.

i have make a batfile but its do not run if the user hits the "y" or "n" button. but i am stuck now, so ik hope someone can help me.

i am a newby

an example is below

===============================

@echo off

:start

echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»

echo º Main Menu º

echo ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹

echo º 1. INSTALL Java 6 update 3. º

echo º 2. INSTALL Real Alternative 1.60 º

echo º 3. QUIT PROGRAM º

echo ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ

ECHO.

CHOICE /C:123

if errorlevel 3 GOTO QUIT PROGRAM

if errorlevel 2 GOTO Real Alternative 1.60.INSTALL

if errorlevel 1 GOTO Java 6 update 3.INSTALL

:Real Alternative 1.60.INSTALL

echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»

ECHO ºName: Real Alternative º

ECHO ºRelease Date: Wednesday, September 12, 2007 º

ECHO ºVersion: 1.60 º

ECHO ºOperating Systems: Windows 95, º

ECHO º Windows 98, º

ECHO º Windows 98 SE, º

ECHO º Windows ME, º

ECHO º Windows NT, º

ECHO º Windows 2000, º

ECHO º XP, 2003 and Vista º

ECHO ºLicense: Freeware º

echo ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ

echo.

echo Do you want to install Real Alternative?

choice /n /c:ync Yes, No, Cancel

if errorlevel c GOTO :c

if errorlevel n GOTO :n

if errorlevel y GOTO :y

:y

@realalt160.exe /verysilent /norestart /LoadInf=".\realalt.ini"

goto :end

:n

echo operation cancelled

goto :end

:c

goto :start

:end

===============

thanks a lot

greetings Ton

Link to comment
Share on other sites


check out my example...

modify to your needs...

:MAIN_MENU
title MAIN MENU
CLS
ECHO ********************
ECHO WHAT DO YOU WANNA DO?
ECHO 1 - IPCONFIG/FLUSHDNS
ECHO 2 - IPCONFIG /RELEASE
ECHO 3 - IPCONFIG /RENEW
ECHO 4 - IPCONFIG
ECHO 5 - EXIT

CHOICE /C:12345
IF ERRORLEVEL 5 GOTO EXIT
IF ERRORLEVEL 4 GOTO IPCONFIG
IF ERRORLEVEL 3 GOTO RENEW
IF ERRORLEVEL 2 GOTO RELEASE
IF ERRORLEVEL 1 GOTO FLUSHDNS


:IPCONFIG
TITLE IPCONFIG
IPCONFIG
PAUSE
GOTO MAIN_MENU


:FLUSHDNS
TITLE FLUSHING DNS
IPCONFIG /FLUSHDNS
PAUSE
GOTO MAIN_MENU

:RELEASE
TITLE RELEASING DNS
IPCONFIG /RELEASE
PAUSE
GOTO MAIN_MENU

:RENEW
TITLE RENEWING YOUR IP
IPCONFIG /RENEW
PAUSE
GOTO MAIN_MENU

:EXIT
EXIT

Link to comment
Share on other sites

Those files cannot work because this is the XP forum and the 'choice' command is not part of that OS. It is an outdated tool which is not only unsafe to use in a cmd console, it has been replaced by newer built-in commands

@ECHO OFF
SETLOCAL

:Menu
CLS
SET "_="
ECHO/ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
ECHO/º Main Menu º
ECHO/ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
ECHO/º 1. INSTALL Java 6 update 3. º
ECHO/º 2. INSTALL Real Alternative 1.60 º
ECHO/º 3. QUIT PROGRAM º
ECHO/ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
ECHO/
SET/p "_=Please choose a Menu Number [1,2,3] "
IF %_% GEQ 1 IF %_% LEQ 3 GOTO Item%_%
GOTO Menu

:Item1
CALL :Msg1
ECHO/your JRE6U3 command
PING -n 6 127.0.0.1>NUL
GOTO Menu

:Item2
ECHO/ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
ECHO/º Name: Real Alternative º
ECHO/º Release Date: Wednesday, September 12, 2007 º
ECHO/º Version: 1.60 º
ECHO/º Operating Systems: º
ECHO/º Windows 95, 98, 98 SE, ME º
ECHO/º Windows NT, 2000, XP, 2003 º
ECHO/º Windows Vista º
ECHO/º License: Freeware º
ECHO/ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
ECHO/
SET/p "_=Do you want to install Real Alternative? [y/n] "
IF /i %_:~0,1% NEQ Y GOTO Menu
CALL :Msg1
START "" /wait REALALT160.EXE /verysilent /norestart /LoadInf=".\realalt.ini"
GOTO Menu

:Msg1
ECHO/Installing please wait...

:Item3

You will need to replace the items under the Item1 label with you actual JRE stuff.

Link to comment
Share on other sites

Here is another way of doing what you want. I have tested this so there is no run time errors,

you will have to add the path and swithes to install your apps. The input is not case sensitive.

@Echo Off
:MainMenu
CLS && Color F3 && Mode 69,11
Echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
Echo º Main Menu º
Echo ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
Echo º 1. INSTALL Java 6 update 3. º
Echo º 2. INSTALL Real Alternative 1.60 º
Echo º 3. QUIT PROGRAM º
Echo ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
Echo.

SET UC=
SET /P UC=Type In Your Reply Then Press Enter ^>
IF /I '%UC%'=='1' GOTO MainMenuItem1
IF /I '%UC%'=='2' GOTO MainMenuItem2
IF /I '%UC%'=='3' GOTO QuitApp

:: Catch Incorrect Input
CLS && Color F4 && Mode 55,5
ECHO.
ECHO This was not valid ^> %UC%
ping -n 5 127.0.0.1>nul
GOTO MainMenu

::Start Main Menu Item 1
:MainMenuItem1
CLS && Color 3F && Mode 69,5
Echo.
Echo -^> Installing Java Update 3
::Uncomment Below With The Path And Switches Used
::start /w "PLACE_THE_PATH_TO_THE_APP_PLACE_SWITHES_HERE"
ping -n 4 127.0.0.1>nul
GoTo MainMenu

::Start Main Menu Item 2
:MainMenuItem2
CLS && Color 3F && Mode 69,23
Echo.
Echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
Echo º Name: Real Alternative º
Echo º Release Date: Wednesday, September 12, 2007 º
Echo º Version: 1.60 º
Echo º License: Freeware º
Echo ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
Echo.
Echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
Echo º Operating Systems º
Echo º Windows 95 º
Echo º Windows 98 º
Echo º Windows 98 SE º
Echo º Windows ME º
Echo º Windows NT º
Echo º Windows 2000 º
Echo º XP º
Echo º Server 2003 º
Echo º Vista º
Echo ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
Echo.
Echo Type Yes or No Or Quit
SET RA=
SET /P RA=Type In Your Reply Then Press Enter ^>
IF /I '%RA%'=='Yes' GOTO Item1
IF /I '%RA%'=='No' GOTO Item2
IF /I '%RA%'=='Quit' GOTO QuitApp

:: Catch Incorrect Input
CLS && Color F4 && Mode 55,5
ECHO.
ECHO This was not valid ^> %RA%
ping -n 5 127.0.0.1>nul
GOTO MainMenuItem2

::Item 1
:Item1
CLS && Color 3F && Mode 69,5
Echo.
Echo -^> Installing Real Alternative
::Uncomment Below With The Path And Switches Used
::start /w "PLACE_THE_PATH_TO_THE_APP_PLACE_SWITHES_HERE"
ping -n 4 127.0.0.1>nul
GoTo MainMenu

::Item 2
:Item2
GoTo MainMenu

::Exit The Script
:QuitApp
Goto EOF
Exit

Edited by gunsmokingman
Link to comment
Share on other sites

Yes, colours, (note the correct English spelling, not American), are nice at times, but as is the case with most VBScripters, they seem to write far too much in order to get the job done! -_-

GSM has added half a dozen lines of code for colour changes, but used twice as many lines as mine for the same task, and mine wasn't optimized for size either!

Link to comment
Share on other sites

Hello Guys,

i have the first script change the "Y" "N" to 1,2.3 and it is working.

@echo off
COLOR 0F
:MAIN_MENU
title Unattended install made by .....

CLS

echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
echo º Main Menu º
echo ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
ECHO º 1 - install QuickTime Alternative 1.90 º
ECHO º 2 - install Java 6 update 3 º
ECHO º 3 - install K-Lite Codec Pack 3.4.5 º
ECHO º 4 - install Real Alternative 1.60 º
ECHO º 5 - EXIT º
ECHO ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
ECHO º Fullscreen? press ALT-ENTER º
ECHO ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
CHOICE /C:12345

IF ERRORLEVEL 5 GOTO EXIT
IF ERRORLEVEL 4 GOTO Real
IF ERRORLEVEL 3 GOTO K-lite
IF ERRORLEVEL 2 GOTO Java
IF ERRORLEVEL 1 GOTO QuickTime

:QuickTime
TITLE INSTALL QuickTime Alternative 1.90
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
ECHO ºName: QuickTime Alternative º
ECHO ºRelease Date: Friday, September 14, 2007 º
ECHO ºVersion: 1.90 º
ECHO ºOperating Systems: Windows 2000 º
ECHO º Windows XP º
ECHO º Windows 2003 º
ECHO º Windows Vista º
ECHO ºLicense: Freeware º
echo ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
echo.
beep
ECHO.
echo Do you want to install QuickTime Alternative 1.90?
echo 1 - yes
echo 2 - no (Go back to menu)
ECHO.
choice /c:12

IF ERRORLEVEL 1 GOTO y
IF ERRORLEVEL 2 GOTO n

:y
@quicktimealt190.exe /verysilent /norestart /LoadInf=".\qtalt.ini"
PAUSE
GOTO MAIN_MENU

:n
GOTO MAIN_MENU

But the script of Yzowl is better.

And the script from gunsmokingman is the best. wow thats great. real like a pro.

But.... can i handle it. i am just beginning user.

i go testing.

thanks to you all for the input.

Greetings Ton

Link to comment
Share on other sites

Hello,

i have 1 question,

i put the files into a folder + the batfile. (se code below)

i run the bat file,

i click on nr: 1

i see the mainmenuitem 1. "Name: Real Alternative"

then i can see "Installing Java 6 update 3" but it wil not install.

@Echo Off
:MainMenu
title Unattended install
CLS && Color F3 && Mode 69,11
Echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
Echo º Main Menu º
Echo ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
Echo º 1. install Java 6 update 3. º
Echo º 2. install Real Alternative 1.60 º
Echo º 3. install QuickTime Alternative 1.90 º
Echo º 4. QUIT PROGRAM º
Echo ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
Echo.

SET UC=
SET /P UC=Type In Your Reply Then Press Enter ^>
IF /I '%UC%'=='1' GOTO MainMenuItem1
IF /I '%UC%'=='2' GOTO MainMenuItem2
IF /I '%UC%'=='3' GOTO MainMenuItem3
IF /I '%UC%'=='4' GOTO QuitApp

:: Catch Incorrect Input
CLS && Color F4 && Mode 55,5
ECHO.
ECHO This was not valid ^> %UC%
ping -n 5 127.0.0.1>nul
GOTO MainMenu

::Start Main Menu Item 1
:MainMenuItem1
CLS && Color 3F && Mode 69,23
Echo.
Echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
Echo º Name: Real Alternative º
Echo º Release Date: Wednesday, 12 September, 2007 º
Echo º Version: 1.60 º
Echo º License: Freeware º
Echo ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
Echo.
Echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
Echo º Operating Systems º
Echo ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
Echo º Windows 95 º
Echo º Windows 98 º
Echo º Windows 98 SE º
Echo º Windows ME º
Echo º Windows NT º
Echo º Windows 2000 º
Echo º Windows XP º
Echo º Windows Vista º
Echo º Server 2003 º
Echo ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
Echo.
Echo Type Yes or No Or Quit
SET RA=
SET /P RA=Type In Your Reply Then Press Enter ^>
IF /I '%RA%'=='Yes' GOTO Item1
IF /I '%RA%'=='No' GOTO Item0
IF /I '%RA%'=='Quit' GOTO QuitApp

:: Catch Incorrect Input
CLS && Color F4 && Mode 55,5
ECHO.
ECHO This was not valid ^> %RA%
ping -n 5 127.0.0.1>nul
GOTO MainMenuItem1


::Item 1
:Item1
CLS && Color 3F && Mode 69,5
Echo.
Echo -^> Installing Java 6 update 3
::Uncomment Below With The Path And Switches Used
::start /w "jre-6u3-windows-i586-p-s.exe /qb-! Reboot=ReallySuppress Reboot=Suppress /norestart /passive /quiet IEXPLORER=1 MOZILLA=1 JAVAUPDATE=0 WEBSTARTICON=0 SYSTRAY=0""
ping -n 4 127.0.0.1>nul
GoTo MainMenu


::Item 0
:Item0
GoTo MainMenu

::Exit The Script
:QuitApp
Goto EOF
Exit

can you help me ?

Link to comment
Share on other sites

Did you uncomment the command as suggested in the code which you posted yourself?

I have the impression that you don't know enough about batch to make scripts of this complexity, so I would suggest making simple scripts first, instead of trying things the hard way straight from the start.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    No registered users viewing this page.


×
×
  • Create New...