Batch errors and i just cant get this

March 19, 2010 at 03:01:38
Specs: Windows XP
Hey guys, im trying to create my fist batch file to do some installs and uninstalls, i think im screwing this all up, anyway somone can look over this and tell me what im doing wrong, I can say that i have tried but im in rut now.

I also want to add some uninstall Reg Strings to this mix later on as well....

ECHO OFF


echo:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
echo:: Brad Phillips Self Created Install/Uninstall Package     ::
echo:: 						                ::
echo:: This Utility will install McAfee		                ::
echo:: Components and also provide the options		        ::
echo:: To Un-Install other components			        ::	 
echo:: See notes within the file for component list	        ::
echo:: Version 1 Mar 2010 - Multi Menu Support 	                ::
echo:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

@echo off

pause


Echo :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Echo :: Brad Phillips Custom Install and Uninstall Menu         ::
Echo ::                                                         ::
Echo :: To Install or Uninstall the following Software          ::
Echo :: Components Please choose one of the following Options   ::
Echo :: To install McAfee FramePackage, choose A	        ::
Echo :: To install McAfee Hard Disk Encryption,choose B		::
Echo :: To install McAfee Folder Encryption,choose C	        ::
Echo :: To Exit, Choose X 					::
Echo ::							        ::
Echo :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    
pause

choice FramePkg[A], Disk Encrypt[B], Folder Encrypt[C], Exit[X]

IF ERRORLEVEL 4 goto x
IF ERRORLEVEL 3 goto c
IF ERRORLEVEL 2 goto B
IF ERRORLEVEL 1 goto A

:A
call \\wfldfp05\itcommon\_rphillips\FramePkg.exe
cls
pause


:B
call \\wfldfp05\itcommon\_rphillips\EncryptionPackages\IT-EEPC.exe
cls
pause


:C
call \\wfldfp05\itcommon\_rphillips\EncryptionPackages\EEFF-Setup.exe
cls
pause

:X
pause

:exit
cls
echo This Utility will now exit
pause




See More: Batch errors and i just cant get this

Report •

#1
March 19, 2010 at 03:26:11
After chopping out the clutter I reduced it to this:
===========================
choice FramePkg[A], Disk Encrypt[B], Folder Encrypt[C], Exit[X]

goto :%ERRORLEVEL%

:1
call \\wfldfp05\itcommon\_rphillips\FramePkg.exe

:2
call \\wfldfp05\itcommon\_rphillips\EncryptionPackages\IT-EEPC.exe

:3
call \\wfldfp05\itcommon\_rphillips\EncryptionPackages\EEFF-Setup.exe

:4

=====================================
[1] Why are you CALLing an exe?

[2] If you're just starting out it's probably a real good idea to avoid inst/uninst/reg.


=====================================
Helping others achieve escape felicity

M2


Report •

#2
March 19, 2010 at 05:59:35
-choice command is incorrectly constructed ?!
-no redirection (goto) at the end of each section (A, B, ...) usually it's not intentional
-calling file with \\servername\... syntax ?! is that supported ?

Report •

#3
March 19, 2010 at 11:05:12
yea still not working as the choice syntax isnt correct, i thought will allow the for user input to make a choice there.

and the screen just buzzes right through unless i put a pause after the choice....


i got some more research to do looks like


Report •

Related Solutions

#4
March 20, 2010 at 06:14:20
But it's not that hard ... when in doubt, first check "command /?", in this case "choice /?"

You'll want this

choice /C:abcx /N FramePkg[A], Disk Encrypt[B], Folder Encrypt[C], Exit[X]


Report •

#5
March 20, 2010 at 14:53:20
maybe build a "menu" then put choice at bottom:
echo FramePkg          [A]
echo Disk Encrypt      [B]
echo Folder Encrypt   [C]
echo Exit                 [X]
choice /C:ABCX /N Selection:[

might depend on what version of choice you have (i have 3 diff ones on my system: choice.com as 1k and 5k, and choice.exe)


Report •

#6
March 20, 2010 at 23:09:09
We still don't know what errors there are.

LOL


=====================================
Helping others achieve escape felicity

M2


Report •

#7
March 20, 2010 at 23:43:34
Here is the Message im getting now

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Brad Phillips Custom Install Menu                       ::
::                                                         ::
:: To Install or Uninstall the following Software          ::
:: Components Please choose one of the following Options   ::
:: To install McAfee FramePackage, choose A                ::
:: To install McAfee Hard Disk Encryption,choose B         ::
:: To install McAfee Folder Encryption,choose C            ::
:: To Exit, Choose X                                       ::
::                                                         ::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
ERROR: Invalid argument/option - 'DiskEncrypt[b],'.
Type "CHOICE /?" for usage.
Press any key to continue . . .

Here is what i have as the code

@echo off

Echo :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Echo :: Brad Phillips Custom Install Menu                       ::
Echo ::                                                         ::
Echo :: To Install or Uninstall the following Software          ::
Echo :: Components Please choose one of the following Options   ::
Echo :: To install McAfee FramePackage, choose A	           ::
Echo :: To install McAfee Hard Disk Encryption,choose B	   ::
Echo :: To install McAfee Folder Encryption,choose C	           ::
Echo :: To Exit, Choose X 				           ::
Echo ::							   ::
Echo :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    


choice /C:abcx /M FramePkg[a], DiskEncrypt[b], FolderEncrypt[c], Exit[x]

IF ERRORLEVEL 4 goto x
IF ERRORLEVEL 3 goto c
IF ERRORLEVEL 2 goto B
IF ERRORLEVEL 1 goto A

:A
call \\wfldfp05\itcommon\_rphillips\FramePkg.exe
cls
pause


:B
call \\wfldfp05\itcommon\_rphillips\EncryptionPackages\IT-EEPC.exe
cls
pause


:C
call \\wfldfp05\itcommon\_rphillips\EncryptionPackages\EEFF-Setup.exe
cls
pause

:X
pause

:exit
cls
echo This Utility will now exit
pause


Report •

#8
March 20, 2010 at 23:59:34
I don't know what /M is trying to do. My version of choice doesn't have /M.

If I leave out /M it works.


=====================================
Helping others achieve escape felicity

M2


Report •

#9
March 21, 2010 at 10:25:25
yea even taken the /m out i still get the same message.

ERROR: Invalid argument/option - 'FramePkg[a],'.
Type "CHOICE /?" for usage.
Press any key to continue . . .



Report •

#10
March 21, 2010 at 11:12:58
yeah, same result as M2: removed the /M and it worked fine, all three versions. I cut/pasted straight out of the forum (your script), no errors...
i would get another copy of "choice"

Report •

#11
March 21, 2010 at 15:37:34
Nbrane, I'm just guessing that there may be more than 3 versions of CHOICE ... but it does not matter (this is to threadstarter) : run "choice /?" and read what he shows. The only thing that I can think of, is to remove special characters like
[
and
]

... maybe they cause issues. Maybe not. Hard to tell from here, because it depends on YOUR version of "choice"


Report •

#12
March 21, 2010 at 15:44:31
OK i figured it out with you guys guidance, plus i didnt realise that i was running this on my Win7 box while at home and my xp box at work.

here is what works on my Win7 box possibly because they changed the choice options in vista and 7

@echo off

Echo :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Echo :: Brad Phillips Custom Install Menu                       ::
Echo ::                                                         ::
Echo :: To Install or Uninstall the following Software          ::
Echo :: Components Please choose one of the following Options   ::
Echo :: To install McAfee FramePackage, choose A	           ::
Echo :: To install McAfee Hard Disk Encryption,choose B	   ::
Echo :: To install McAfee Folder Encryption,choose C	           ::
Echo :: To Exit, Choose X 				           ::
Echo ::							   ::
Echo :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
    


choice /C abcx /m "Please Make your Selection from the Above Options"

IF ERRORLEVEL 4 goto x
IF ERRORLEVEL 3 goto c
IF ERRORLEVEL 2 goto B
IF ERRORLEVEL 1 goto A

:A
call \\wfldfp05\itcommon\_rphillips\FramePkg.exe
cls



:B
call \\wfldfp05\itcommon\_rphillips\EncryptionPackages\IT-EEPC.exe
cls


:C
call \\wfldfp05\itcommon\_rphillips\EncryptionPackages\EEFF-Setup.exe
cls


:X


:exit
cls
echo This Utility will now exit
pause



Report •

#13
March 21, 2010 at 19:48:56
Lol! yeah, i figured it boiled down to choice.??? version, combined with op.sys version. everytime someone submits a script that uses it, the same issues arise and get discussed.
@Tvc: who knows how many versions are out there? i just happened to have three. Hell, a person could even have a home-made cobble and not know it unless they knew to scrutinize it in debug or something.

Report •

#14
March 23, 2010 at 15:12:59
Hey guys thanks for all the Input, now that i have that one figured out and cusomized like i like it im having a issue with a uninstall one that im creating all them work except the ones that have to make a call to a specific folder for a uninstall and i cant seem to figure this one out,

Like i said all of them work except choices C and E

Echo ***************************************************************
Echo * *** Custom Uninstall Menu for IT Only ***
Echo *
Echo * To Uninstall McAfee Site Advisor, Choose A
Echo *
Echo * To Uninstall Host Intrusion Protection Services, Choose B
Echo *
Echo * To Uninstall McAfee Anti Spyware, Choose C
Echo *
Echo * To Uninstall McAfee Virus Scan Enterprise, Choose D
Echo *
Echo * To Uninstall McAfee File Folder Encryption,choose E
Echo *
Echo * To Uninstall McAfee ePO Frame Package, Choose F
Echo *
Echo * To Exit, Choose X
Echo *
Echo ****************************************************************
Echo:
choice /C abcdefx /m "Please Make your Selection from the Above Options"

IF ERRORLEVEL 7 goto x
IF ERRORLEVEL 6 goto F
IF ERRORLEVEL 5 goto E
IF ERRORLEVEL 4 goto D
IF ERRORLEVEL 3 goto c
IF ERRORLEVEL 2 goto B
IF ERRORLEVEL 1 goto A

:A
call MsiExec.exe /X{00FC3F65-86EB-475E-881F-A5B1CF731320} REMOVE=ALL
cls
goto menu

:B
call MsiExec.exe /X{B332732A-4958-41DD-B439-DDA2D32753C5} REMOVE=ALL
cls
goto menu

:C
call C:\Program Files\McAfee\VirusScan Enterprise\scan32.exe" /UninstallMAS
cls
goto menu

:D
call msiexec /x {147BCE03-C0F1-4C9F-8157-6A89B6D2D973} REMOVE=ALL
cls
goto menu

:E
call C:\Program Files\McAfee\Endpoint Encryption for Files and Folders\SbCeSetup.Exe -Uninstall -Confirm "-AppName:McAfee Endpoint Encryption for Files and Folders"
cls
goto menu

:F
call MsiExec.exe /X{362678B4-6ED5-46E9-A6B2-53EF22159151} REMOVE=ALL
cls
goto menu

:X
:exit
cls
echo This Utility will now exit
pause



Report •

#15
March 23, 2010 at 22:45:30
"C" looks like unbalanced dbl-quote: remove it or balance it.
also, both lines attempt to "call" a .exe executable, which (last time i looked) don't work!
to invoke a .exe, just put the .exe name, f/e: \work\myexec.exe:
\work\myexec arg1 arg2
call only works to invoke another bat, and then only needs "call" if you want to return to your main batch caller.

Report •

#16
March 24, 2010 at 13:41:24
that dosent work

this command needs to run from a command line,

C:\Program Files\McAfee\VirusScan Enterprise\scan32.exe" /UninstallMAS

so how would i make a call to navigate this and run this if this has to be done from a command line


Report •

#17
March 24, 2010 at 13:50:29
Yep, CALL calls another bat and waits for it.

An exe doesn't need CALL. When you run the exe the bat waits for it.


=====================================
Helping others achieve escape felicity

M2


Report •

#18
March 24, 2010 at 14:28:38
except this fails, as this command needs to be run form a CMD line to actually perform the uninstall, thats what im trying to figure out, is how to run this in a batch file and have that command run itself in a CMD line

something like

call CMD /c type cd C:\Program Files\McAfee\VirusScan Enterprise\scan32.exe /UninstallMAS

now of course this dosent work but something along those lines. im not sure if im making sense or not so tell me if i am not.


Report •

#19
March 24, 2010 at 14:52:30
Something else must be wrong (besides your continued instance in using CALL to run .EXE files). Batch scripts run in CMD.

Report •

#20
March 24, 2010 at 15:11:29
The other thing wrong is OP's insistance on not using appropriat quotes.

"C:\Program Files\McAfee\VirusScan Enterprise\scan32.exe" /UninstallMAS


=====================================
Helping others achieve escape felicity

M2


Report •

#21
March 24, 2010 at 15:30:50
figured it out thanks guys

Report •

Ask Question