I'm trying to run a batch file in a Pre-Launch run script. Running the
script from a .cmd file locally on the workstation works fine. However,
when it is inserted into an AppObject it errors on the line begining with
"FOR /F".

I've tried various methods to specify the Script Engine Location. My usual
way is to use %COMSPEC% /c but, I have also tried C:\Windows\system32
\cmd.exe and %*WINSYSDIR%\CMD.EXE /C with the same results.

For the file extension I have spcified .cmd and .bat but both result in the
same error.

The AppObject is running on Windows XP SP2 with ZFD Agent 6.5.2

Below is the relevant portion of the batch file. It errors on the line
begining with "FOR /F".
@echo off
::Creating C:\reg.log
echo reg log >c:\reg.log
echo -------------- >>c:\reg.log
echo. >>C:\reg.log

::Determine DHCP server (ZEN ImportServer)
echo Discovering ImportServer ... >>c:\reg.log
ipconfig /all | find "DHCP Server">C:\zenserv.txt
for /f "tokens=15 delims= " %%a in (C:\zenserv.txt) do set zserv=%%a
echo ImportServer should be %zserv% >>c:\reg.log

If I echo this line while running from an AppObject it returns 'for /f
"tokens=15 delims= " \zenserv.txt) do set zserv=a'. This proves it does
not handle it correctly. The same line echoed from a .cmd file locally
echoes it as 'for /f "tokens=15 delims= " %a in (C:\zenserv.txt) do set
zserv=%a' as it should be interpreted.

This same script runs fine when launching the .cmd file locally on the

I get the feeling that the scripts feature is not working as advertised. I
am under the impression that takes the script and builds a .cmd file on the
workstation and then runs this file. However, it seems that ZENworks is
interpreting the '%%a' in the script incorrectly.

It should be noted that the script finishes if I REM the FOR /F line.

** Have also tested as a Distribution Script and I get the same errors.

I'm banging my head on my keyboard. If anyone can help with I will owe you
one. :)

Kirk Rexin
Sacramento City USD