jeudi 7 janvier 2016

Batch Script - First "IF" selection does not work, rest do

I am having trouble with my code. If I run the file and follow the prompt, enter a workstation name then select site 1, it continues to open up the cmd window to execute the psexec command, it does not do the "IF NOT EXIST" for site 1, but for other sites it comes back fine. If no file exists it will output to the prompt, if it does it continues to psexec. Any idea what I am doing wrong? Thank you.

:MAN
SET /P S=Please enter a workstation name or IP: 
ECHO.
ECHO 1 - Site 1
ECHO 2 - Site 2
ECHO 3 - Site 3
ECHO 4 - Site 4
SET /P D=Select which Site you want to deploy from: 
IF %D%==1 SET D="10.1.1.1\Folder\File.MSI"
IF %D%==2 SET D="10.1.1.1\Folder\File.MSI"
IF %D%==3 SET D="10.1.1.1\Folder\File.MSI"
IF %D%==4 SET D="10.1.1.1\Folder\File.MSI"
IF NOT EXIST %D% GOTO MSG

START CMD /K PsExec.exe @%S% -s -h cmd /c msiexec.exe /i "%D%" /qn
PAUSE
GOTO EOF
:MSG
CALL :color 1a "ERROR: MSI PACKAGE DOES NOT EXIST"

Aucun commentaire:

Enregistrer un commentaire