mercredi 9 septembre 2015

Batch check for empty user input

I am struggeling with a simple check if the user input was just empty (Enter) and in case set the variable to a new value... spend an hour but it does not work. Goal is to have the entered Value beginning with a backslosh OR just an empty string if nothing was entered.

SET myTargetServerInstanceName=anyNOPEdummyValue
SET /P myTargetServerInstanceName=Enter Target Server INSTANCE Name:    
IF %myTargetServerInstanceName%==anyNOPEdummyValue SET myTargetServerInstanceName=
IF NOT %myTargetServerInstanceName% == [] SET myTargetServerInstanceName=\%myTargetServerInstanceName%

this results in error:

SET was unexpected at this time.

Aucun commentaire:

Enregistrer un commentaire