Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I make it stop exiting! 1

Status
Not open for further replies.

dbustamante

IS-IT--Management
Jul 12, 2010
63
US
Hey everyone I’m working on a script that I will be using for all my new IT members so configuring PC's won’t be so time consuming. so far all the commands are working fine but every time the selection is made it run’s the command then exit's and I have to start it up again when all I really want it to do is once a selection has been made it goes back to the menu for more options.

Code:
@ECHO OFF
COLOR 2
CLS
ECHO      .................................................................
ECHO      .WELCOME TO THE RIO GRANDE DETENTION IT NEW COMPUTER SET UP FILE. 
ECHO      .IN THIS FILE YOU WILL GO STEP BY STEP ON SETTING UP A NEW      .
ECHO      .COMPUTER FROM STRACH. THERE WILL BE SEVERAL OPTIONS TO CHOOSE  .
ECHO      .FROM AND IF DONE IN ORDER YOU SHOULD NOT HAVE ANY PROBLEMS.    .
ECHO      .................................................................
ECHO  	  ................................................
ECHO  	  .SELECT 1-9 START CONFIGURING PC               .
ECHO       ................................................
ECHO 1 - CHANGE WSCRIPT TO CSCRIPT
ECHO 2 - Disable Firewall
ECHO 3 - SHOW ALL NETWORK CONNECTIONS
ECHO 4 - CHANGE COMPUTER NAME
ECHO 5 - JOIN PC TO DOMAIN
ECHO 6 - COPY ALL SHORTCUTS TO All USER DESKTOPS
ECHO 7 - ENABLE REMOTE DESKTOP
ECHO 8 - OPEN VNC FOR INSTALL
ECHO 9 - EXIT
SET /P USERINP=CHOOSE A NUMBER(1-9):
SET USERINP=%USERINP:~0,1%
IF "%USERINP%"=="1" GOTO 1
IF "%USERINP%"=="2" GOTO 2
IF "%USERINP%"=="3" GOTO 3
IF "%USERINP%"=="4" GOTO 4
IF "%USERINP%"=="5" GOTO 5
IF "%USERINP%"=="6" GOTO 6
IF "%USERINP%"=="7" GOTO 7
IF "%USERINP%"=="8" GOTO 8
IF "%USERINP%"=="9" GOTO 9
:1 CHANGE WSCRIPT TO CSCRIPT
"\\RGDC\IT\SCRIPTS\change wscript to cscript.bat"
GOTO MENU
:2 disable firewall
netsh firewall set opmode disable
GOTO MENU
:3 SHOW ALL NETWORK CONNECTIONS
START "%USERPROFILE%" EXPLORER.EXE /N,::{7007ACC7-3202-11D1-AAD2-00805FC1270E} /S/Y 
GOTO MENU
:4 CHANGE COMPUTER NAME
SET /P PCNAME=Please enter your name: 
REG ADD HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName /v ComputerName /t REG_SZ /d  %PCNAME% 
GOTO MENU
:5 JOIN PC TO DOMAIN
"\\RGDC\IT\SCIPTS\JOINPCTODOMAIN.BAT"
GOTO MENU
:6 COPY ALL SHORTCUTS TO USER DESKTOPS
XCOPY \\10.37.224.10\IT\WEBSITES "C:\DOCUMENTS AND SETTINGS\ALL USERS\DESKTOP" /O /X /E /H /K
GOTO MENU
:7 Enable remote Desktop
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f
GOTO MENU
:8 OPEN VNC FOR INSTALL
"\\RGDC\iT\Applications\vnc-4_1_3-x86_win32.exe"
GOTO MENU
:9 
EXIT

This is what I have so far any help would be greatly appreciated!
 
This isn't exactly VBScript, but I'll take a stab at it.

You have a lot of GOTO MENU commands, but I don't see a MENU label for it to go to.
 
JGES the menu would be these but your right i am missing a label I've never made one where i wanted it to loop so im not sure what kind of label i need.

1 - CHANGE WSCRIPT TO CSCRIPT
2 - Disable Firewall
3 - SHOW ALL NETWORK CONNECTIONS
4 - CHANGE COMPUTER NAME
5 - JOIN PC TO DOMAIN
6 - COPY ALL SHORTCUTS TO All USER DESKTOPS
7 - ENABLE REMOTE DESKTOP
8 - OPEN VNC FOR INSTALL
9 - EXIT

Geates we have multiple locations that have some user’s going back and forth so it’s easier to change 3 or 4 things instead of all of them.
 
I'd try something like this:
Code:
...
ECHO       ................................................
:MENU
ECHO 1 - CHANGE WSCRIPT TO CSCRIPT
...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Also, if you call a batch file from within a batch file, and you want execution to return to the original batch file, you have to use the "CALL" command. For example:

Code:
:5 JOIN PC TO DOMAIN
[highlight #FCE94F]CALL[/highlight] "\\RGDC\IT\SCIPTS\JOINPCTODOMAIN.BAT"
 
PHV that worked like a charm!! its ding everything i want it to now! Thank you!

I really appreciate your ‘alls help on this something it so simple I couldn’t figure it out here is the finial product!

Code:
@ECHO OFF
COLOR 2
CLS
ECHO      .................................................................
ECHO      .WELCOME TO THE RIO GRANDE DETENTION IT NEW COMPUTER SET UP FILE. 
ECHO      .IN THIS FILE YOU WILL GO STEP BY STEP ON SETTING UP A NEW      .
ECHO      .COMPUTER FROM STRACH. THERE WILL BE SEVERAL OPTIONS TO CHOOSE  .
ECHO      .FROM AND IF DONE IN ORDER YOU SHOULD NOT HAVE ANY PROBLEMS.    .
ECHO      .................................................................
ECHO  	  ................................................
ECHO  	  .SELECT 1-9 START CONFIGURING PC               .
ECHO      ................................................
:MENU
ECHO 1 - CHANGE WSCRIPT TO CSCRIPT
ECHO 2 - Disable Firewall
ECHO 3 - SHOW ALL NETWORK CONNECTIONS
ECHO 4 - CHANGE COMPUTER NAME
ECHO 5 - JOIN PC TO DOMAIN
ECHO 6 - COPY ALL SHORTCUTS TO All USER DESKTOPS
ECHO 7 - ENABLE REMOTE DESKTOP
ECHO 8 - OPEN VNC FOR INSTALL
ECHO 9 - EXIT
SET /P USERINP=CHOOSE A NUMBER(1-9):
SET USERINP=%USERINP:~0,1%
IF "%USERINP%"=="1" GOTO 1
IF "%USERINP%"=="2" GOTO 2
IF "%USERINP%"=="3" GOTO 3
IF "%USERINP%"=="4" GOTO 4
IF "%USERINP%"=="5" GOTO 5
IF "%USERINP%"=="6" GOTO 6
IF "%USERINP%"=="7" GOTO 7
IF "%USERINP%"=="8" GOTO 8
IF "%USERINP%"=="9" GOTO 9
:1 CHANGE WSCRIPT TO CSCRIPT
"\\RGDC\IT\SCRIPTS\change wscript to cscript.bat"
GOTO MENU
:2 disable firewall
netsh firewall set opmode disable
GOTO MENU
:3 SHOW ALL NETWORK CONNECTIONS
START "%USERPROFILE%" EXPLORER.EXE /N,::{7007ACC7-3202-11D1-AAD2-00805FC1270E} /S/Y 
GOTO MENU
:4 CHANGE COMPUTER NAME
SET /P PCNAME=Please enter your name: 
REG ADD HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName /v ComputerName /t REG_SZ /d  %PCNAME% 
GOTO MENU
:5 JOIN PC TO DOMAIN
"\\RGDC\IT\SCIPTS\JOINPCTODOMAIN.BAT"
GOTO MENU
:6 COPY ALL SHORTCUTS TO USER DESKTOPS
XCOPY \\10.37.224.10\IT\WEBSITES "C:\DOCUMENTS AND SETTINGS\ALL USERS\DESKTOP" /O /X /E /H /K
GOTO MENU
:7 Enable remote Desktop
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f
GOTO MENU
:8 OPEN VNC FOR INSTALL
"\\RGDC\iT\Applications\vnc-4_1_3-x86_win32.exe"
GOTO MENU
:9 
EXIT
 
Guitarzan thanks I just added it to all the ones calling all my other .bat files aswell.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top