I am trying to run a batch file that will install the client piece of software. However, it hangs when I try to run th exe because of variables that are behind it. It is does not matter if you are not familiar with the software in the REMark below. Here is what I have so far:
--------------------------
----------
----------
----------
----------
----------
----------
----------
----------
----------
----------
----------
----------
----------
----------
----------
----------
---------
@ECHO off
REM Silent Install for Password Policy Enforcer client. 08-18-04
REM
http://www.anixis.com/products/ppe/default.htm
net use B: /d
IF %OS% == Windows_NT GOTO WINXP
IF NOT %OS% == Windows_NT WIN98
:WINXP
IF EXIST %system%\system32\PPEc32.d
ll GOTO END
IF NOT EXIST %system%\system32\PPEc32.d
ll GOTO STARTXP
:STARTXP
net use B: /d
net use B: \\servername\share
CD\
CD B:
CD B:\PPE
COPY PPEc32.dll %system%\system32
ClntIns.exe install ppeclnt.cfg /q
net use B: /d GOTO END
:WIN98
IF EXIST %system%\system32\PPEc9x.d
ll GOTO END
IF NOT EXIST %system%\system32\PPEc9x.d
ll GOTO START98
:START98
net use B: /d
net use B: \\servername\share
CD\
CD B:
CD PPE
COPY PPEc9x.dll %system%\system32
ClntIns.exe install ppeclnt.cfg /q
net use B: /d GOTO END
:END
net use B: /d
EXIT
--------------------------
----------
----------
----------
----------
----------
----------
----------
----------
----------
----------
----------
----------
----------
----------
----------
----------
---------
Here is the output:
The network connection could not be found.
More help is available by typing NET HELPMSG 2250.
The network connection could not be found.
More help is available by typing NET HELPMSG 2250.
The command completed successfully.
B:\
The system cannot find the file specified.
'ClntIns.exe' is not recognized as an internal or external command,
operable program or batch file.
A command was used with conflicting switches.
More help is available by typing NET HELPMSG 3510.
B: was deleted successfully.
The command completed successfully.
B:\
The system cannot find the file specified.
'ClntIns.exe' is not recognized as an internal or external command,
operable program or batch file.
A command was used with conflicting switches.
More help is available by typing NET HELPMSG 3510.
Press any key to continue . . .
--------------------------
----------
----------
----------
----------
----------
----------
----------
----------
----------
----------
----------
----------
----------
----------
----------
----------
--------
Here is the part that concearns me: It hangs at "ClntIns.exe install ppeclnt.cfg /q". The error message I get is "'ClntIns.exe' is not recognized as an internal or external command, operable program or batch file. A command was used with conflicting switches. The program runs fun manually with those switches. It appears that DOS does not like them. Is there anyway around this? Thanks.
One of the net use B: /d commands will be enough; that's what causes the two "The network connection could not be found." errors; you're deleting the drive at the very beginning and then again right before mapping it.
This will fail in Win9x, because the %OS% variable isn't defined, and because you missed the "goto" in the Win98 line:
> IF %OS% == Windows_NT GOTO WINXP
> IF NOT %OS% == Windows_NT WIN98
You need quotation marks around the %OS% and Windows_NT.
The target paths are completely wrong; in Win9x, it's %WinDir%\system, in NT it's %Systemroot%\system32:
> IF EXIST %system%\system32\PPEc32.d
This command is not necessary, neither is the label; if the file exists, the former command will already have jumped out.
> IF NOT EXIST %system%\system32\PPEc32.d
> :STARTXP
As stated before, the path change is incorrect, this needs to be "B:" followed by "cd \PPE":
> CD B:
> CD B:\PPE
The target path is wrong again:
> COPY PPEc32.dll %system%\system32
And this command fails, because you're not on the B: drive:
> ClntIns.exe install ppeclnt.cfg /q
As stated before, this needs to be separated into two lines. Because it isn't, the script will just continue with the Win9x part (that's the "A command was used with conflicting switches." error):
> net use B: /d GOTO END
> :WIN98
As before, the target path is incorrect, and the second line as well as the label are not necessary:
> IF EXIST %system%\system32\PPEc9x.d
> IF NOT EXIST %system%\system32\PPEc9x.d
> :START98
As before, incorrect directory change:
> CD\
> CD B:
> CD PPE
And the incorrect target path again:
> COPY PPEc9x.dll %system%\system32
The failing command again, because you're not on the B: drive:
> ClntIns.exe install ppeclnt.cfg /q
And the missin gline break:
> net use B: /d GOTO END
And another unnecessary network drive removal:
> net use B: /d
Try this instead; it's currently in test mode, so it will only display the commands it would otherwise run. To run it for real, remove the "ECHO"s and the "PAUSE" command where indicated.
@echo off
REM Silent Install for Password Policy Enforcer client. 08-19-04
REM http://www.anixis.com/products/ppe/default.htm
REM *** Set the defaults for Win9x:
set TargetPath=%WinDir%\System
set PPEDLL=PPEc9x.dll
REM *** If it's NT, change the settings accordingly:
if "%OS%"=="Windows_NT" set TargetPath=%Systemroot%\sy
if "%OS%"=="Windows_NT" set PPEDLL=PPEc32.dll
REM *** Leave if the dll already exists:
if exist "%TargetPath%\%PPEDLL%" goto leave
REM *** Installation necessary; map the network drive and start the install:
net use B: /d
net use B: \\Server\Share
if errorlevel 1 goto err_Mapping
B:
cd \PPE
REM *** Test mode: Remove the "ECHO" in front of the following line to run the script for real:
ECHO copy %PPEDLL% "%TargetPath%\%PPEDLL%"
ECHO ClntIns.exe INSTALL ppeclnt.cfg /q
REM *** Test mode: Remove the "PAUSE" line to continue automatically after the installation:
PAUSE
net use P: /d
goto leave
:err_Mapping
echo Error mapping network drive.
pause
:leave