Link to home
Start Free TrialLog in
Avatar of Jack Dee
Jack Dee

asked on

Batch Files: Running variables after an .exe

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.dll GOTO END
IF NOT EXIST %system%\system32\PPEc32.dll 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.dll GOTO END
IF NOT EXIST %system%\system32\PPEc9x.dll 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.
Avatar of Jack Dee
Jack Dee

ASKER

The program runs fun manually with those switches. = The program runs fine manually with those switches.
cd b:
 
b: is a drive not a directory correct?

i think you want
b:
cd\
to change prompt from  c:\blahblah\  to   b:\

try turning @echo on in the beggining
so you can see more details
alsue insert alot of pauses to see exactly what command is chokeing
lol
i just tried cd b:
=======
C:\Documents and Settings\Eric>cd ..

C:\Documents and Settings>cd d:
D:\

C:\Documents and Settings>cd f:
F:\

C:\Documents and Settings>

===========

is it me or is that weird?  it says d:\ but does not actually do anything :|
CD B:
CD PPE

change it to

b:
cd \ppe

if ppe is in the root of b:, otherwise give the absolute path to the cd command.

cd \path\ppe
IF NOT %OS% == Windows_NT WIN98

should be

IF NOT %OS% == Windows_NT GOTO WIN98

right?
net use B: /d GOTO END

should be

net use B: /d
GOTO END
also, be careful when you use the word "hangs".  This program is not hanging, it is failing.  hanging is when you lose control over the system input because the CPU is caught in some kinda loop
ok good crissand agrees with that cd B: issue.. im not crazy
because I tested it and it does not work.

Sometimes the os does'n't allow you to use the B: letter, since it is a legacy from the times when computers use to have two floppy drives. The drive change can also fail if the network mapping is not working.
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Wow!  Thanks for all the replies.  

The script seems to run much better, but for some reason it does not want to copy the file over from the network share.  It appears like it copies it over.  There are no errors except the initial "network connection could not be found" when there is no B: drive to delete before mapping the B: drive.  When I check the C:\Windows\System32 directory on my WinXP test machine, there is no PPEc32.dll file in there.  I did a search of the entire C: drive with "show hidden files" option checked and could not find it anywhere.  Here is what I have:

@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:
if not "%OS%"=="Windows_NT" set TargetPath=%WinDir%\System
if not "%OS%"=="Windows_NT" set PPEDLL=PPEc9x.dll

REM *** If it's NT, change the settings accordingly:
if "%OS%"=="Windows_NT" set TargetPath=%Systemroot%\system32
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: \\servername\Share
if errorlevel 1 goto err_Mapping
cd\
B:
cd B:\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
C:
net use B: /d
goto leave

:err_Mapping
echo Error mapping network drive.
pause

:leave
cd B:\PPE


should be

cd \PPE

don't specify drives in "cd" commands
OKay.  I changed that, but still have the same symptoms.
what does the echo show on the command line during the copy?
oh wait, you're only testing for NT, you have no if statements for 9x
sorry, i didn't see the "not"s in there.  nevermind
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Here is the output before the PAUSE:

C:\temp>caah01ppe
The network connection could not be found.

More help is available by typing NET HELPMSG 2250.

The command completed successfully.

copy PPEc32.dll "C:\WINDOWS\system32\PPEc32.dll"
ClntIns.exe INSTALL ppeclnt.cfg /q
Press any key to continue . . .

After pressing enter:

B: was deleted successfully.

C:\>
take out the echo's!
That did the trick on the local machine.  I'll be out of the office on Friday, returning Monday.  I'll post again when I am back in and after I have tested everything fully from the server group policy.  I may have to split some points for at least two of you since you all have been so helpful.  :-)
Thanks again.
Works like a charm!  Thanks for all the awesome input.