|
Answer» This is for use on a Windows XP/NT environment I want the file to flush the dns, prompt the user to disconnect and reconnect to the network, and then REBOOT when ready The current batch stops after the prompt for network reconnection. Not sure what I did wrong. This is edited code that I put together from online searching:
Code: [Select]@echo off IPCONFIG /FLUSHDNS pause CLS :start cls set choice1= set /p choice1=Have you disconnected and RECONNECTED to the network? (Y or N) IF NOT '%choice1%'=='' set choice1=%choice1:~0,1% If '%choice1%'=='N' goto end If '%choice1%'=='Y' goto Next cls ECHO "%choice1%" is not valid please try again ECHO. pause goto start :Next cls set choice2= set /p choice2=Your computer will restart.Do you wish to continue? (Y or N) IF NOT '%choice2%'=='' set choice2=%choice2:~0,1% If '%choice2%'=='N' shutdown -a If '%choice2%'=='Y' shutdown -r cls ECHO "%choice2%" is not valid please try again pause goto Next ECHO. :end exit Thank you so much, in advance, for the help!AS your script is at the moment, you have to hold down the shift key to answer Y or N because the IF tests are case sensitive; you can use IF /I to get around that. (I for Insensitive)
I have altered your script to make debugging easier; also I have prettied up the set /p lines to make the (Y or N) parts line up vertically to LOOK NEATER, also I have used quotes so the response is spaced away from the prompt; and I have commented out the CLS commands so you can see what is happening better
Code: [Select]@echo off echo [simulate] IPCONFIG /FLUSHDNS pause rem CLS :start rem cls set choice1= set /p choice1="Have you disconnected and reconnected to the network? (Y or N) " IF NOT '%choice1%'=='' set choice1=%choice1:~0,1% If /i '%choice1%'=='N' goto end If /i '%choice1%'=='Y' goto Next rem cls ECHO "%choice1%" is not valid please try again ECHO. pause goto start :Next rem cls set choice2= set /p choice2="Your computer will restart.Do you wish to continue? (Y or N) " IF NOT '%choice2%'=='' set choice2=%choice2:~0,1% If /i '%choice2%'=='N' echo [simulate] shutdown -a If /i '%choice2%'=='Y' echo [simulate] shutdown -r rem cls ECHO "%choice2%" is not valid please try again pause goto Next ECHO. :end echo exit pause
Code: [Select]S:\TEST>test.bat [simulate] IPCONFIG /FLUSHDNS Press any key to continue . . . Have you disconnected and reconnected to the network? (Y or N) n [simulate] exit
S:\Test>test.bat [simulate] IPCONFIG /FLUSHDNS Press any key to continue . . . Have you disconnected and reconnected to the network? (Y or N) y Your computer will restart.Do you wish to continue? (Y or N) n [simulate] shutdown -a
S:\Test>test.bat [simulate] IPCONFIG /FLUSHDNS Press any key to continue . . . Have you disconnected and reconnected to the network? (Y or N) y Your computer will restart.Do you wish to continue? (Y or N) y [simulate] shutdown -r
I cannot thank you enough!
|