You are not logged in.
Hello,
I am trying to create a batch file which can start or stop services depending on the input provided at the time of executing the script.
i tried using the below script:
@echo off
choice /n /c:12 Please choose 2 for Stopping, 1 for Starting
if errorlevel 2 goto Stop
if errorlevel 1 goto Start
:Start
net Start "VMware USB Arbitration Service"
net Start "VMware Authorization Service"
net Start "VMware DHCP Service"
net Start "VMware NAT Service"
net Start "VMware Workstation Server"
:Stop
net Stop "VMware Workstation Server"
net Stop "VMware USB Arbitration Service"
net Stop "VMware Authorization Service"
net Stop "VMware DHCP Service"
net Stop "VMware NAT Service"
Now when entered 1 upon prompting, for starting the services, it starts them but at the same time once all the services are started it stops them also (processes :Stop label a well)
Please help.
Offline
The CHOICE command was introduced in MS-DOS 6. As of Windows NT 4, CHOICE is no longer a part of the standard distribution. Roll your own with something like this:
@echo off
:Select
cls
ECHO.Start/Stop Services
set /p Selection=Enter 1 to start, 2 to stop^>
echo.
if "%Selection%"=="1" goto :Start
if "%Selection%"=="2" goto :Stop
color cf
echo.Error! Enter a valid choice.
pause
color 07
goto :Select
:Start
echo.Starting services
rem Start services here
pause
goto :eof
:Stop
echo.Stopping services
rem Stop services here
pause
goto :eof
Last edited by RG (02 Dec 2011 05:16)
Windows Shell Scripting and InstallShield
Offline
@echo off
choice /n /c:12 Please choose 2 for Stopping, 1 for Starting
if errorlevel 2 goto Stop
if errorlevel 1 goto Start
:Start
net Start "VMware USB Arbitration Service"
net Start "VMware Authorization Service"
net Start "VMware DHCP Service"
net Start "VMware NAT Service"
net Start "VMware Workstation Server"
goto :EOF
:Stop
net Stop "VMware Workstation Server"
net Stop "VMware USB Arbitration Service"
net Stop "VMware Authorization Service"
net Stop "VMware DHCP Service"
net Stop "VMware NAT Service"
goto :EOF
cmd | *sh | ruby | chef
Offline