View unanswered posts | View active topics It is currently 25 Oct 2014 00:58



Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next
Colored Menu for starting multi task [SOLVED] 
Author Message

Joined: 26 Oct 2011 22:38
Posts: 1007
Location: Egypt
Post Colored Menu for starting multi task [SOLVED]
i'm making a batch file to install manual update to an online game so i'm missing one thing,
how can i ask to input to the location of a folder that has that update patches

This is the final Code and working fine Problem solved
Code:
@echo off
Title Fiesta Manual Update Installer V3.0
::======================================================================
SETLOCAL EnableDelayedExpansion
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
set "DEL=%%a"
)
::======================================================================
mode 60,30
color 0
echo:&echo:&echo:&echo:&echo:&echo:&echo:&echo:&echo:&echo:
echo:     ######## #### ########  ######  ########    ###   
echo:     ##        ##  ##       ##    ##    ##      ## ##   
echo:     ##        ##  ##       ##          ##     ##   ## 
echo:     ######    ##  ######    ######     ##    ##     ##
echo:     ##        ##  ##             ##    ##    #########
echo:     ##        ##  ##       ##    ##    ##    ##     ##
echo:     ##       #### ########  ######     ##    ##     ##
echo:&echo:&echo:&echo:&echo:&echo:
call :color 0f "                         Enter                            "
pause >nul
cls
color 07

::======================================================================
:loop1
echo:&echo:&echo:&echo:&echo:
call :color 07 "            ==================================" &echo:
call :color 07 "            =" & call :color 0d "Fiesta Manual Update Installer" & call :color 07 "=" & echo:
call :color 07 "            ==================================" &echo:&echo:
call :color 0f "             Select An Option" &echo:&echo:&echo:
call :color 0a "                  (1) Auto Install" &echo:&echo:
call :color 0b "                  (2) Install Patches" &echo:&echo:
call :color 0e "                  (3) Install Sharplaunchers" &echo:&echo:
call :color 08 "                  (4) Exit" &echo:&echo:&echo:
set /p "cho1=Option #"
if %errorlevel%==1 cls & goto loop1
if %cho1%==1 goto auto
if %cho1%==2 goto patches
if %cho1%==3 goto sharplaunchers
if %cho1%==4 goto EOF
echo Invalid choice.
cls
goto loop1
::======================================================================
:auto
echo:
call :color 0c "Enter sharp launchers and patches Directory "&echo:
set /p "installpath=Dir:>"
if %errorlevel%==1 cls & goto loop1
call :color 04 "Installing Sharplaunchers and Patches ..."&echo:
if exist "%temp%\log.log" del /F /Q "%temp%\log.log" >nul
ping localhost -n 2 >nul

setlocal enableextensions
set log=%temp%\log.log
for /f "tokens=*" %%c in ('dir /b /on "%installpath%\*.*"') do (
echo %installpath%\%%c >>"%log%"
)
for /f "tokens=*" %%d in (%log%) do (
start "" /w "%%d"
)
msg * Auto Installation Completed.
msg * Please Restart Your Computer so Changes can take Effect.
cls
goto loop1
::======================================================================
:sharplaunchers
echo:
call :color 0c "Enter sharplaunchers Directory "&echo:
set /p "installpath=Dir:>"
if %errorlevel%==1 cls & goto loop1
call :color 04 "Installing Sharplaunchers ..."&echo:
if exist "%temp%\log.log" del /F /Q "%temp%\log.log" >nul
ping localhost -n 2 >nul

setlocal enableextensions
set log=%temp%\log.log
for /f "tokens=*" %%c in ('dir /b /on "%installpath%\*.*"') do (
echo %installpath%\%%c >>"%log%"
)
for /f "tokens=*" %%d in (%log%) do (
start "" /w "%%d"
)
msg * SharpLaunchers Installation Completed.
msg * Please Restart Your Computer so Changes can take Effect.
cls
goto loop1
::======================================================================
:patches
echo:
call :color 0c "Enter patches Directory "&echo:
set /p "installpath=Dir:>"
if %errorlevel%==1 cls & goto loop1
call :color 04 "Installing Patches ..."&echo:
if exist "%temp%\log.log" del /F /Q "%temp%\log.log" >nul
ping localhost -n 2 >nul

setlocal enableextensions
set log=%temp%\log.log
for /f "tokens=*" %%c in ('dir /b /on "%installpath%\*.*"') do (
echo %installpath%\%%c >>"%log%"
)
for /f "tokens=*" %%d in (%log%) do (
start "" /w "%%d"
)
msg * Patches Installation Completed.
cls
goto loop1
::======================================================================
:color
echo off
<nul set /p ".="%DEL% " " >> "%~2"
findstr /v /a:%1 /R "^$" "%~2" nul
del "%~2" > nul 2>&1
goto :eof
::======================================================================


Last edited by abc0502 on 19 Apr 2012 12:06, edited 9 times in total.



17 Apr 2012 03:49
Profile

Joined: 10 Feb 2012 02:20
Posts: 4321
Post Re: specify a directory
abc0502 wrote:
i'm making a batch file to install manual update to an online game so i'm missing one thing,
how can i ask to input the location of a folder that has that update patches

i tried this to input the location but it keep run the next command directly without waiting for the input so it give errors:

:auto
Echo Enter Directory:
set "variable="
set /p "variable=install>"
if not defined variable goto :auto
Echo Installing Sharplaunchers and Patches ...
ping localhost -n 3 >nul
"%installpath%\SharpLauncher86b.exe"




17 Apr 2012 04:46
Profile

Joined: 26 Oct 2011 22:38
Posts: 1007
Location: Egypt
Post Re: specify a directory
Thanks alot foxi for your replay but not all the code worked,only this worked

:auto
Echo Enter Directory:
set /p "variable=install>"
Echo Installing Sharplaunchers and Patches ...
ping localhost -n 3 >nul
"%installpath%\SharpLauncher86b.exe"

and it will look like that:
Code:
:auto
Echo Enter Directory:
set /p "installpath=Directory>"
Echo Installing Sharplaunchers and Patches ...
ping localhost -n 3 >nul
"%installpath%\SharpLauncher86b.exe"

it geive errors for not finding the files then goto the start again
thanks :)


17 Apr 2012 05:52
Profile

Joined: 26 Oct 2011 22:38
Posts: 1007
Location: Egypt
Post Re: specify a directory [solved]
one more thing :)
is there away to get the files "exe files" names and list them in alphapit order so the command install it one by one
and i don't have to add new patches name to the batch regulary, i tried using for command to get all files names to a log file then launche them one by one but "getting there names from the log file didn't work any idea

i tried using !k's Code for renaming and change it to start files but no luck:
Code:
@echo off &setlocal enableextensions

set /a cnt=0
for /f "delims=" %%a in ('dir /b /on *.txt') do call :ren "%%a"
goto :eof

:ren
for /f "tokens=1" %%b in ('more +%cnt% log.log') do (
   ren %1 "%%b.txt"
   set /a cnt+=1 &goto :eof
)


17 Apr 2012 06:04
Profile

Joined: 26 Oct 2011 22:38
Posts: 1007
Location: Egypt
Post Re: specify a directory
I used this but getting the more is not a command error !! :?:
Code:
@echo off
cls
setlocal enableextensions
set path=%userprofile%\desktop\test
set /a cnt=0
for /f "delims=" %%a in ('dir /b /on "%path%\*.*"') do call :ren "%%a"
goto :eof

:ren
for /f "tokens=1" %%b in ('more +%cnt% log.log') do (
   "%%b.cmd"
   set /a cnt+=1 &goto :eof
)
pause


17 Apr 2012 06:35
Profile
Expert

Joined: 17 Oct 2009 08:30
Posts: 378
Location: Russia
Post Re: specify a directory
set folder=%userprofile%\desktop\test


17 Apr 2012 07:16
Profile

Joined: 10 Feb 2012 02:20
Posts: 4321
Post Re: specify a directory
abc0502 wrote:
Thanks alot foxi for your replay but not all the code worked,only this worked


When faced with an issue like this, try separating the function and see if it works.

My code below works fine in a subroutine of it's own.

Code:
@echo off
:auto
Echo Enter Directory:
set "variable="
set /p "variable=install>"
if not defined variable goto :auto
echo "%variable%"
pause


Quote:
Enter Directory:
install>abc def
"abc def"



17 Apr 2012 07:29
Profile

Joined: 26 Oct 2011 22:38
Posts: 1007
Location: Egypt
Post Re: specify a directory
Thanks Foxidrive and !k for help :D :D :D
it worked and now i don't have to edit the batch on every new patches for the game
it read the folder containing the patches and make a list in alphapitc order then start every patch at a time.

i will post the code after small changes.
The batch will be in colors :evil:


19 Apr 2012 03:23
Profile

Joined: 26 Oct 2011 22:38
Posts: 1007
Location: Egypt
Post Re: specify a directory
The First Code Was Modified with the working code


Last edited by abc0502 on 19 Apr 2012 07:34, edited 3 times in total.



19 Apr 2012 06:17
Profile

Joined: 10 Feb 2012 02:20
Posts: 4321
Post Re: specify a directory [SOLVED]
You will get an error if the user enters nothing.

And %cho1% should be nulled before the set /p or it can take the value it had before the set /p, if enter was pressed.



Quote:
set /p "cho1=Option #"
if %cho1%==1 goto auto
if %cho1%==2 goto patches
if %cho1%==3 goto sharplaunchers
if %cho1%==4 goto EOF
echo Invalid choice.
cls
goto loop1



Try this:

Code:
@echo off
:auto
set "variable=zzz"
set /p "variable=press enter: "
if not defined variable goto :auto
echo "%variable%"
pause


19 Apr 2012 06:23
Profile

Joined: 26 Oct 2011 22:38
Posts: 1007
Location: Egypt
Post Re: specify a directory [SOLVED]
WOW :roll: i didn't notice that thanks alot foxidrive ,
i changed the code now it work fine
and as u said in your last post i should used it from the begining :)


19 Apr 2012 07:01
Profile

Joined: 10 Feb 2012 02:20
Posts: 4321
Post Re: specify a directory [SOLVED]
This will not run any program in %%d.

Quote:
start /w "%%d"


The first pair of quotes in a start command are used for the title.

You need this:

Code:
start "" /w "%%d"


19 Apr 2012 07:13
Profile

Joined: 26 Oct 2011 22:38
Posts: 1007
Location: Egypt
Post Re: specify a directory [SOLVED]
when i add
Code:
if not defined %installpath% goto :loop1

nothing is installed or run
when i delete it every thing start normally why?


19 Apr 2012 07:20
Profile

Joined: 26 Oct 2011 22:38
Posts: 1007
Location: Egypt
Post Re: specify a directory [SOLVED]
foxidrive wrote:
This will not run any program in %%d.

Quote:
start /w "%%d"


The first pair of quotes in a start command are used for the title.

You need this:

Code:
start "" /w "%%d"

the folder that will be specified will have only patches that will be ordered in alphapitic order then will be run one by on the patches are auto start so the code work fine with this patches


19 Apr 2012 07:32
Profile

Joined: 10 Feb 2012 02:20
Posts: 4321
Post Re: specify a directory [SOLVED]
abc0502 wrote:
when i add
Code:
if not defined %installpath% goto :loop1

nothing is installed or run
when i delete it every thing start normally why?


Quote:
if not defined installpath goto :loop1


Don't use quotes.


19 Apr 2012 07:39
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 19 posts ]  Go to page 1, 2  Next


Who is online

Users browsing this forum: Yahoo [Bot] and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Forum style by Vjacheslav Trushkin for Free Forums/DivisionCore.