| 1. |
Solve : user input of data to a command? |
|
Answer» hello all, hi, thanks. yeah that works, (without the user name and password bit) as that just brings up "the santax of the command is" and then DETAILS of how to use net use. I've removed that bit, but yes that will work. I'll tweak it a bit and get to stop or start the service later. I'll post the results here either later tonight or TOMORROW at work. Many thanks!!!!right the finished thing. if you know of a way to make look a bit neater, please let me know. @echo off :loop echo. echo. echo. Welcome to the KFC Remote services Program echo. echo. echo. A. Enter a IP address echo. echo. B. Enter a Service to be re-started echo. echo. Q. Quit echo. echo. echo. :getchoice SET Choice= SET /P Choice=Choose your option and then press Enter (A,B or Q): IF NOT "%Choice%"=="" SET Choice=%Choice:~0,1% ECHO. IF /I "%Choice%"=="A" GOTO IP IF /I "%Choice%"=="B" GOTO Service IF /I "%Choice%"=="Q" GOTO End ECHO "%Choice%" is not valid. Please try again. goto getchoice ECHO. :IP set /p IP="Enter IP Address of remote Pc: " net use \\%IP% /user:end21 82mass30 goto next :service set /p Service="Enter a service to be re-started: " sc \\%IP% stop %service% sc \\%IP% start %service% goto loop :next echo. echo. echo. echo. echo. Welcome to the KFC Remote services Program echo. echo. echo. echo. echo. echo. echo. A. Enter a IP address echo. echo. B. Enter a Service to be re-started echo. echo. Q. Quit echo. echo. echo. :getchoice SET Choice= SET /P Choice=Choose your option and then press Enter (A,B or Q): IF NOT "%Choice%"=="" SET Choice=%Choice:~0,1% ECHO. IF /I "%Choice%"=="A" GOTO IP IF /I "%Choice%"=="B" GOTO Service IF /I "%Choice%"=="Q" GOTO End ECHO "%Choice%" is not valid. Please try again. goto getchoice ECHO. :end exitI don't understand why you have the Welcome to the KFC Remote services Program" section and the :getchoice section appearing twice. You can't have the :getchoice label twice anyway. Usually, if the same code appears more than once, it's time to stop typing and start thinking. i've put that in twice so that when the command is run the "command compleated susscefly" is at the top if the command prompt. ( the second one has a few extra echo. on it. it also makes it look a bit neater. I should say the th user name and password isn't the real thing and i have sub'ed it for the end21 and 82mass30 for sercerity reasons. thanks for all your help. I'm very pleased with the way it works.Quote from: blastman on July 31, 2007, 12:15:27 AM i've put that in twice so that when the command is run the "command compleated susscefly" is at the top if the command prompt. ( the second one has a few extra echo. on it. I meant why did you put all this in a second time? Is it even needed? How does the code know which :getchoice label to GO to? Quote echo. i see what u mean. It does work but maybe this would be better; echo. echo. echo. echo. echo. Welcome to the KFC Remote services Program echo. echo. echo. echo. echo. echo. echo. A. Enter a IP address echo. echo. B. Enter a Service to be re-started echo. echo. Q. Quit echo. echo. echo. SET Choice= SET /P Choice=Choose your option and then press Enter (A,B or Q): IF NOT "%Choice%"=="" SET Choice=%Choice:~0,1% ECHO. IF /I "%Choice%"=="A" GOTO IP IF /I "%Choice%"=="B" GOTO Service IF /I "%Choice%"=="Q" GOTO End ECHO "%Choice%" is not valid. Please try again. goto getchoice ECHO. remove the second :getchoice label to allow it to return to the first one. I have put it in the 2nd time because when it is run, considering that the "command completed" line appears in the window, the 2nd one has a few extra (echo.) to move the "command completed" line to the top of the window making it easier for users to see if it has worked. what do u reakon?? or do u think that a better laied out first menu would SUIT???Writing the same code twice is bad programming. |
|