I want to change the serial number and product number of about 250 servers (they are not correct at the moment). I know the command that I need to use, but I need to be able to input certain options in to that command and then run it.
The options I need are:
- A prompt for selecting the update of the serial or the product number
- Multiple prompts for actual serial number, an IP address, a user name and password on having selected before the update of the serial number
- Multiple prompts for actual product number, an IP address, a user name and password on having selected before the update of the product number
The command I wish to run via the batch file is:
asu64 set SYSTEM_PROD_DATA.SysInfoSerialNum XXXXXXX --host XXX.XXX.XXX.XXX --user XXXX --password XXXX
The XXX
is a user defined input. I'd also like for completion and then go back to the initial selection menu.
Here is what I have done so far. (Please excuse the simplicity of it. I am very new to this stuff.)
@ECHO OFF
ECHO Test Code
ECHO.
ECHO 1.Serial Number
ECHO 2.Product Name
ECHO.
CHOICE /C 12 /M "Enter your choice:"
ECHO.
IF CHOICE 1 GOTO SerialNumber
IF CHOICE 2 GOTO ProductName
:SerialNumber
ECHO Serial Number
GOTO End
:ProductNumber
ECHO Product Number
GOTO End
PAUSE
Many thanks for any help you can offer.
CodePudding user response:
There could be used for this task:
@echo off
setlocal EnableExtensions DisableDelayedExpansion
set "IpAddress="
set "NameUser="
set "Password="
:MainMenu
cls
echo/
echo 1 ... Serial number
echo 2 ... Product number
echo E ... Exit
echo/
%SystemRoot%\System32\choice.exe /C 12E /N /M "Enter your choice:"
if errorlevel 3 exit /B
if not errorlevel 1 goto MainMenu
echo/
if errorlevel 2 goto ProductNumber
set "NumberText=serial"
set "NumberOption=SYSTEM_PROD_DATA.SysInfoSerialNum"
goto NumberPrompt
:ProductNumber
set "NumberText=product"
set "NumberOption=SYSTEM_PROD_DATA.SysInfoProductNum"
:NumberPrompt
set "NumberValue="
set /P "NumberValue=Please enter %NumberText% number: " || goto NumberPrompt
set "NumberValue=%NumberValue:"=%"
if not defined NumberValue goto NumberPrompt
echo/
if defined IpAddress (set "Default= [%IpAddress%]") else set "Default="
:IpPrompt
set /P "IpAddress=Please enter IP address