Solved

alternative command for choice in windows 2000

Posted on 2002-03-25
26
1,875 Views
Last Modified: 2012-05-04
We currently run bat files that use the choice command.We run these bats on windows 95. We are upgrading to windows 2000 and the choice command longer works. I tried to use the choice.com command and I am getting and error message. Do you what I should be using to get the bat files to work?

Thank you in advance for your help.
0
Comment
Question by:hixti01
  • 14
  • 7
  • 4
  • +1
26 Comments
 
LVL 7

Expert Comment

by:rin1010
Comment Utility

hixti,

CHOICE.COM should work ok under Windows 2000 ...
It does when booting to a DOS command prompt under 2K
but the problem may be that you're using the NTFS ...
What is the exact error message you're getting?
Is it like "Bad command or file name"
or something similar to that?

You mentioned trying to "use the choice.com command"... How did you try to use it?
Windows 2000 doesn't install Choice.com but it could still be on your system
depending on how you set up 2K ... (i.e., as an upgrade or otherwise.)
It may now reside in a folder named MSDOS7
or you can search your drives for it.

It's possible that Choice.com isn't currently in your Path
or the Choice.com commands in your batch files
include a specific directory for Choice ...

Locate a copy of CHOICE.COM (preferably Ver. 7 -- >= Windows 9.x)
and place it in a Path directory or in the batch file's working directory
or in the path to Choice.com as specified in the batch files.

If Choice still won't work, provide the specific error message you receive
and perhaps we can see what the problem is...
Alternatively, there are numerous small, free apps to do the same (or more)
as Choice.com and work under 2K and also different batch file methods...
So please post back if none of this helps...
 
0
 

Author Comment

by:hixti01
Comment Utility
Thanks for the info. I printed off your response and will check with the desktop support team. In the meantime I went to the command prompt in Windows 2000 and was sitting at the c prompt. I typed in choice.com and received he following message:
Choice.com is not reconized as an internal or external command,operable program or batch file.

I ran the test bat file with the following command
choice.com /n /c:12 > nul
I got the command syntax from a website. I am not sure if it correct or not.
When I ran the bat file, I received the same error message as when I typed it in from the c prompt.

Any ideas?
0
 

Author Comment

by:hixti01
Comment Utility
I just checked with the desktop support group. We are using the NTFS. The person also checked his C drive for the choice.com command and it was not there. Any ideas on how to be able to still run my bat files in this new windows 2000 environment?
0
 
LVL 7

Expert Comment

by:rin1010
Comment Utility

hixti,

That error message you're getting is the NT/2K equivalent
to the DOS COMMAND.COM error "Bad command or file name"
that's generated when the command interpreter can't find a specified program.
Under Windows 2K you may also get "The system cannot find the path specified."

Again, the problem could be that the command interpreter just can't find Choice.com ...
Note my previous comments about the Path and try to locate a copy of Choice
and then try running it from the directory it's in or include the path to it.

Your syntax for the Choice switches is fine... Sending the output to the Nul device
prevents your 'choice' (either 1 or 2 in your example) from being echoed to the screen.
But for testing you can just type 'Choice.com' and if it runs successfully
you'll get the default "[Y,N]?" and know it's working ok under Win2K.
(If so, type 'Choice/?' for brief info on its syntax and parameters.)

But because of the way the NT/2K command interpreter handles certain characters,
the syntax in your batch file could still be causing the error...
CMD.EXE doesn't process batch files the same as COMMAND.COM
does when running your batch files under Windows 9.x...
There are certainly workarounds (like enclosing the offending characters in quotes
or preceding it with a caret, etc.) but it may be easier (and/or necessary)
to rewrite your batch (or .cmd) files for use under Windows 2000
and perhaps use a method other than Choice for option branching.

I'm currently unable to test this, but there are issues with Windows 2000
pertaining specifically to Choice.com which can generate that error message
depending on how you run Choice and how Windows 2000 was installed
(e.g., upgrading as i mentioned)... Take a glance at this:

http://support.microsoft.com/default.aspx?scid=kb;EN-US;q225746

I've had other problems with (and had to modify) batch files for use under 2K
which crashed for various unexplained reasons. One was a batch file
having a call to pkzip using its ampersand switch which 2K didn't like.
Another was a batch file that wouldn't run because the name of the directory it was in
contained characters other than alphabetic letters. A couple of other processing bugs
were fixed after installing the Windows 2000 Service Packs (SP1 and SP2)
but you probably need to determine whether Choice.com is the immediate problem.

Change to a directory containing a copy of Choice.com and type 'Choice'
and see what happens. Then browse to that directory in Explorer
and launch Choice.com or try it from a "Run..." dialog.
Hopefully some of this will indicate whether Choice is going to work for you
so you don't waste a lot of time with it and can look for alternatives if necessary.
Please post back with your results and whatever else you discover...
 
0
 
LVL 7

Accepted Solution

by:
rin1010 earned 50 total points
Comment Utility

Was writing the above and didn't see your last post before submitting...
You might want to try getting a copy of Choice.com from another system
(such as Windows 9.x) and copying it to a drive and then testing it.
(Also, whoever searched their drive for it may have overlooked it
depending on the search method used.)

Regarding how to run your batch files under Windows 2000 ...
That would definitely depend on the particular batch files
and probably numerous other variables,
most importantly what they're designed to do.
And the NTFS can certainly be a problem.
Are there many and are they similar in function?
Perhaps provide a couple of examples
and we can see what you're dealing with
and what might need to be done...
 
0
 

Author Comment

by:hixti01
Comment Utility
the bat files that I have created for the finance department are really simple. They basically ftp files from
a nivell drive to a UNIX directory. This is easier than having the finance people doing FTP commands. Here is one of the bat files they we use. If I can not get arounf it, I was thinking about creating separate bat files to do each process.


rem  *****************************************************************************
rem  *This batch file will copy ADP payroll files from the payroll secure        *
rem  *folder to a non secure folder where a unix script can FTP them to UX76PRD4 *
rem  *to be processed into the Oracle Financial General Ledger System            *
rem  *****************************************************************************

u:
echo ****************************************************
echo *            FTP Financial Reports to the Web      *      
echo ****************************************************
:Start1

rem echo Are there files to be Processed
rem echo .                                                  
rem echo     1 - Refresh directory      
rem echo     2 - Continue process
choice.com /n /c:12 > nul
rem for %%x in (1,2) do if errorlevel %%x goto Start%%x
rem :Start2
echo month to be processed is %1
echo files to be processed is %2
echo Enter the Level of report you are sending.
echo .                                                  
echo     1 - HIGH LEVEL  (First character of selected report begins with H)
echo     2 - LOW LEVEL   (First character of selected report begins with L)      
choice /n /c:12 > nul
for %%x in (1,2) do if errorlevel %%x goto copy%%x
:copy1
echo ..................................    
echo High Level report transfer.
echo user gldev gl_dev > fsgftp.dat
echo cd /export/home/gldev/html/web/finance/highreports/%1 >> fsgftp.dat
echo prompt off >> fsgftp.dat
echo ascii >> fsgftp.dat
echo mput %2*.HTM >> fsgftp.dat
echo binary >> fsgftp.dat
echo mput %2*.XLS >> fsgftp.dat
echo bye >> fsgftp.dat
ftp -n -s:fsgftp.dat sl76dev2
goto check  
:copy2
echo ..................................    
echo High Level report transfer.
echo user gldev gl_dev > fsgftp.dat
echo cd /export/home/gldev/html/web/finance/reports/current/month/%1 >> fsgftp.dat
echo prompt off >> fsgftp.dat
echo ascii >> fsgftp.dat
echo mput %2*.HTM >> fsgftp.dat
echo binary >> fsgftp.dat
echo mput %2*.XLS >> fsgftp.dat
echo bye >> fsgftp.dat
ftp -n -s:fsgftp.dat sl76dev2
goto check  
:check
echo ..................................      
echo Was the FTP of the file successful?
echo .                                                  
echo     1 - Yes
echo     2 - No
choice /n /c:12 > nul
for %%x in (1,2) do if errorlevel %%x goto resp%%x
:resp1
echo file will be moved
rename %2NAV.HTM %2NAV_done.HTM
:resp2
echo .................................      
echo end of process
0
 
LVL 7

Expert Comment

by:rin1010
Comment Utility

I'm unable to test your script as is but don't see much wrong...
Just glancing at it I notice you remmed one instance of Choice
and are now calling it only a couple of other places...
Perhaps you can eliminate those as well and
maybe pass the batch file another replaceable parameter
to indicate High or Low Level...
And maybe automatically verify a successful file transfer
using ls or similar to test the uploaded file...
I'd have to rewrite your script to run it but couldn't debug it specifically...
I could help with some suggestions but you'll probably encounter
a few more glitches under 2K once you get past the Choice thing...
So you're probably better off redoing it as you say,
now that the os has changed, etc...
I'll look at it again sometime tomorrow and
maybe you'll know then how you want to proceed with it...
Also have a couple of small utilities similar to Choice
which I'll provide if you want to test them on your system.
One is 128 bytes and returns an errorlevel like Choice...
It's on a server where you can download it if interested...
 
0
 
LVL 5

Expert Comment

by:Jason_S
Comment Utility
Have you coppied choice.com to your local drive in the path?
0
 

Author Comment

by:hixti01
Comment Utility
I finally got my 2000 machine and extracted the choice.com from a 95 machine. I will copy it to my machine and try it. A problem I foresee is that our bat files are stored on a Novell server with shortcuts on the users desktops. I don;t know if the network support folks will put choice.com on the srver. Isn't  there any replacement for the choice command in 2000?

How does anyone who used to use the choice command do the processes now in a 2000 environment?

Is there some other process which will allow the users to ftp files to UNIX without having them type in the commands?

 
0
 

Author Comment

by:hixti01
Comment Utility
I checked with desktop support on bat file being stored on the server. They said that when the bat file is stored on the server with shortcuts. it still uses the environment that is running the bat file. So all we have to do install the choice.com on every machine that is going to use the bat files.
I installed the choice.com in my WINNT/system32 directory. At the dos command prompt I typed choice and got the [Y/N]
display. I am testing my bat file and it is not working. I will try some more things.
0
 

Author Comment

by:hixti01
Comment Utility
I can't seem to get the choice command to work. Is there anything else I can look at or try?
0
 
LVL 7

Expert Comment

by:rin1010
Comment Utility

Hi hixti,

Just a note to say i received notification of your last post...
I'd about forgotten this one... Please allow me a short while
to review the thread and to see where we are with it
and I'll soon post a reply and try to help...
 
0
 

Author Comment

by:hixti01
Comment Utility
Thanks...
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:hixti01
Comment Utility
Have you had a chance to look at this yet? I don't want to be a pain but we are in the process of upgrading our finance team to 2000 and they soon will will need something to use. If I cannot get this to work, I will have to figure out another way to do this process.

0
 
LVL 5

Expert Comment

by:Jason_S
Comment Utility
Choice.exe (not Choice.com) is probably what you want.  It is available in the NT resource kit.  Can't say for sure if it is in the 2000 resource kit.
0
 

Author Comment

by:hixti01
Comment Utility
Thanks.....
I will ask our desktop support group if they have the resource kits.

If they don't, is there a place to download the choice.exe program?
0
 
LVL 5

Expert Comment

by:Jason_S
Comment Utility
No.  It is only available through the resource kit.
0
 

Author Comment

by:hixti01
Comment Utility
I am including my test bat file. Maybe you can figured out what is happening. This bat file works with the choice.com and the choice.exe.

@echo off
:Start1
echo     1 - Refresh directory      
echo     2 - Continue process
choice /c:12
rem --------------------------------------------------------
rem this statement does not work
rem for %%x in (1,2) do if errorlevel %%x goto Start%%x
rem --------------------------------------------------------
rem this statement does work
for %%x in (2,1) do if errorlevel %%x goto Start%%x
rem --------------------------------------------------------
:Start2
echo doing the Start2 process

The first for statement will always go to the Statr1 paragraph no matter what the response it.
The second for statement will go to the correct paragraph.

Do you have any idea what is causing this?
0
 
LVL 7

Expert Comment

by:rin1010
Comment Utility

hixti,

Apologies for the delayed response... Was hoping you'd post a copy
of your modified batch file to see where branching was necessary
and perhaps find a method of user input or automated selection
according to the file type and to test for a successful transfer.

Also confused as to whether you meant Choice.com is working.
You'd mentioned successfully running Choice but then said
you were unable to get it to work. Is it functioning now?

I was working on a small .com as a replacement for Choice.com
that might be useful if needed for your script branching.
I'll place it where you can get it if interested
and post a sample script.

Regarding you current question; when using errorlevel parameters
like that in a batch script, you typically list them in decreasing order.
DOS considers the If statement to be true if the errorlevel returned by Choice
(or any program) is greater than or equal to the parameter
you specify with the If command.

Testing the errorlevel with For continues to process the other values
even after the branching. Considering you're concerned with only
two errorlevel values, you can just test for the higher number.
So you could do it similar to this:


@echo off

:Start1
cls
echo.
echo     1 - Continue Process
echo     2 - Refresh Directory
echo.
choice /c:12

if errorlevel 2 goto Start1

:Start2
cls
echo.
echo     Doing the Start2 Process...
echo.



If you need the "Refresh Directory" option to be first as you had it,
you can reverse the Choice prompts like this:


@echo off

:Start1
cls
echo.
echo     1 - Refresh Directory
echo     2 - Continue Process
echo.
choice /c:21

if errorlevel 2 goto Start1

:Start2
cls
echo.
echo     Doing the Start2 Process...
echo.


There are other methods, including placing the labels at specific locations
and using a 'goto end' statement for branching. Your original question
has lead to others and now you may be able to prompt the user
to run the script with a replaceable parameter to indicate
a High or Low Level file type transfer.

Please post back with current results and I'll put together notes
on this prompt program in case you have further Choice problems...
 
0
 

Author Comment

by:hixti01
Comment Utility
Thanks for the response. First I was testing the choice.com and I was not getting the right results. I thought that it was a choice.com problem, that's why I got a copy of choice.exe from out network support team and replace choice.com with choice.exe as you recommended. Once I found out that if I switched the parameters around and it worked, I tried the same process using choice.com and that worked also.
Now that I know how the error level checking works I don"t think I will need the small.com program.

Thanks alot for all your help.
0
 
LVL 7

Expert Comment

by:rin1010
Comment Utility

hixti,

In addition to the suggestion of using DOS and FTP commands
for successful file transfer verification, here's an example of
using DOS batch commands to prompt the user
for the High or Low Level Report ...

Perhaps you can include some of this in your script and
completely eliminate Choice or other external apps.
This is merely an outline and can be modified
to accept a "1" and "2" or other characters.
Your original script contained remarked
references to Choice so I don't know
what branching is now necessary.

So this is a simple example and not much to it.
It accepts only the specified characters as valid
but also don't know how you launch your script.
If you want to test, edit, debug this or whatever,
save it as a batch file with any name you want...



@echo off
cls
for %%r in (L l H h) do if "%1"=="%%r" goto %%r
echo.
echo     Use either the H or L parameter
echo     to specify High or Low Level...
echo.
echo     Example:   %0  H
echo.
goto end
:L
:l
echo.
echo     Level "%1" specified...
echo.
echo     Processing Low Level...
echo.
goto end
:H
:h
echo.
echo     Level "%1" specified...
echo.
echo     Processing High Level...
echo.
:end


 
0
 

Author Comment

by:hixti01
Comment Utility
Thanks for the response. I will try his. we have changed out bat file to errorlevel check in decending order and that seems to work.

Again, thanks for all your help.
0
 
LVL 4

Expert Comment

by:EricWestbo
Comment Utility
** PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER **

It appears that this question has been abandoned.  Please take a moment to finalize the question & reward your points as appropriate.  If this question is not finalized within 7 days, Community Support will be requested to force close it.  Unless there is objection or further activity,  it will also be requested that points be awarded to the following expert(s) for their comments:

rin1010; jason_s

If you feel that your question was not properly addressed, or that none of the comments received were appropriate answers, please post a request in Community support (with a link to this page) to refund your points.  The link to the Community Support area is: http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt


/EW

** PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER **
0
 

Author Comment

by:hixti01
Comment Utility
I am not sure what I have to do. I got the answers I was looking for and thanked everyone for their help. I do not know how to close this or how to assign points? If you tell me what to do or where the instructions are to finalized this, I will be more than than happy to do this. You guys have been a great help and if I have any problems in the future, I would like to think that I could come here for answers and/or path fowards.

0
 
LVL 5

Expert Comment

by:Jason_S
Comment Utility
See http://www.experts-exchange.com/jsp/cmtyQuestAnswer.jsp for details.

In short:
You can accept, and grade one of the comments above as the answer to your question.  This will close the question, and award the points to that user.  Do look through, and make sure the comment you select was the one that lead you to the answer.

In any case, I am glad to help.
0
 

Author Comment

by:hixti01
Comment Utility
Thanks for all our help
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
This video discusses moving either the default database or any database to a new volume.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now