Relevance substitution failed using PAUSE WHILE command (RESOLVED)

So I am working on a bit of a long action, and have posted quite a few questions today.

My action has several IF statements, but closes them out gracefully with “endif” statements. When it gets down to a point where where I want it to wait for CCMSetup.exe to close before proceeding. It works fine in the debugger (we’re on 8.2) but fails in the action:

Here are the details:
TEST PARAMETERS:
SCCM is corrupted - CCMExec has been renamed.

Actions script section failing (with minor changes for confidentiality):
pause while {(exist process “ccmsetup.exe”)}
// Install SCCM Client
prefetch g4h32g432g4kjh32g4j3g24kjg3jk23g43jk2 sha1:eb32e32ekl32legh3kleh3jk2lehl3j2 size:34232137 http://SERVER…DOMAIN.com:PORT/Uploads/g4h32g432g4kjh32g4j3g24kjg3jk23g43jk2/SMSClientInstall.tmp
extract g4h32g432g4kjh32g4j3g24kjg3jk23g43jk2
run “{pathname of system folder & “\cmd.exe”}” /Q /C “{(pathname of client folder of current site) & “__Download\InstallSMS.Bat”}”

ERROR OCCURS AT:
pause while {(exist process “ccmsetup.exe”)}

ERROR DATA FROM LOG:
Command Failed (Relevance substitution failed) pause while {(exist process “ccmsetup”)} (fixlet 2415)

Any ideas?

Try this:

pause while {(exists processes "ccmsetup.exe")}

I wouldn’t recommend a single long action. I would recommend breaking it up into many smaller chunks and then bundle all of them together into a baseline.

I tried both exist and exists without avail. I do like your idea of a baseline, but I am so close at this point I’d like to see if I can get the singular action running.

1 Like

What about with this part?

That is the part that really matters I believe.

Same failure point :frowning:

1 Like

The below works for me on 9.2.2.21, and it what @jgstew recommended. The action will run indefinitely while notepad is open, as soon as notepad is closed, it will proceed with the rest of the script. Try taking out the rest of your script and use just the Pause while piece with a single command afterward and make sure that piece is working. Ensure the process name exists as well. At least you will know if the substitution error is actually there or somewhere else in the code.

 pause while {(exists processes "notepad.exe")} 
 dos echo "hello" {now} > c:\Test\ECHO.txt
1 Like

Same failure occurred.Notepad was open. Here is the entire action it originally failed on:

run "{pathname of system folder & "\cmd.exe"}" /Q /C "C:\Windows\CCMSetup\ccmsetup.exe /uninstall"
waithidden cmd.exe /C ping 127.0.0.1 -n 10 -w 500> nul
pause while {(exists processes "ccmsetup.exe")}

Does this work without the pause while?

Shouldn’t it be:

run "{pathname of system folder & "\cmd.exe"}" /Q /C "C:\Windows\CCMSetup\ccmsetup.exe" /uninstall

Which I would try like this:

run "C:\Windows\CCMSetup\ccmsetup.exe" /uninstall

Or:

run cmd /C "C:\Windows\CCMSetup\ccmsetup.exe" /uninstall

It does work without the Pause While but we need it to wait for CCMsetup.exe to exit before continuing.

I’ll test your suggestions and post a follow up - Thanks!

1 Like

Why not use wait instead of run?
wait - The wait command behaves the same as the run command, except that it waits for the
completion of the process or program before continuing.
run - Executes the indicated program. If the process can’t be created, the action
script is terminated. Run does not wait for the process to terminate before
executing the next line of the action script. The command line contains the name
of the executable and may optionally contain parameters. If you wish to wait for
one program to finish before starting another one, use the wait command.

That works for our uninstall, but I also use the line at the end of an action that’s the inverse of this where we Install CM, which uses a batch file due to the code necessary to generate the install string.

Why not post it and let’s play?

Sure, here it is (I’ve had to redact some server information):

REM Locate the CCM Client Directory
REM Copy CU1 Client Updater to CCM Client Directory\CCMSetup so client will properly self-heal
REM Launch the Upgrade

REM Updated: 10/14/15 - Updated to handle x86 32 bit SCCM client patch.

CD /D C:\Program Files (x86)\BigFix Enterprise\BES Client\__BESData\actionsite\__Download

@echo On 
@echo *** Started Cache and Install CU1 > %TEMP%\INSTALLR2SP1CU1.Log
Setlocal

SET OVERRIDE=%1

REM Determine processor type
IF EXIST %WINDIR%\SYSWOW64\CMD.EXE (set bit=x64) else (set bit=x86)

IF "%BIT%"=="x64" GOTO :x64
IF "%BIT%"=="x86" GOTO :x86
@echo *** Failed to determine x86 or x64 processor, exiting >> %TEMP%\INSTALLR2SP1CU1.Log
Exit 9

:x64
@Echo Detected x64 Client
@Echo Detected x64 Client >> %TEMP%\INSTALLR2SP1CU1.LOG

REM Set Default value if Registry blank
SET CCMPATH=%WINDIR%\CCM

REM Force Install
If "%OVERRIDE%"=="1" GOTO INSTx64

REM Force Install if Client Not Detected
IF NOT EXIST "%CCMPATH%\TSCore.dll" GOTO INSTx64
@ECHO Started INSTALLR2SP1CU1.BAT > %TEMP%\INSTALLR2SP1CU1.LOG
If Exist %windir%\sysnative\cmd.exe for /f "tokens=5*" %%x in ('%windir%\sysnative\reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SMS\Client\Configuration\Client Properties" /v "Local SMS Path"') do set CCMPATH=%%x
If Not Exist %windir%\sysnative\cmd.exe %~dp0junction -accepteula %WinDir%\syswow64x c:\Winnt\System32
If Not Exist %windir%\sysnative\cmd.exe for /f "tokens=5*" %%x in ('%WinDir%\syswow64x\reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SMS\Client\Configuration\Client Properties" /v "Local SMS Path"') do set CCMPATH=%%x
If Not Exist %windir%\sysnative\cmd.exe %~dp0junction -accepteula -d %WinDir%\syswow64x
IF %CCMPATH:~-1%==\ SET CCMPATH=%CCMPATH:~0,-1%
@Echo CCM Client Path: %CCMPATH%
@Echo CCM Client Path: %CCMPATH% >> %TEMP%\INSTALLR2SP1CU1.LOG

FOR /F "tokens=1-3" %%i in ('%~dp0patch\x64\Sigcheck.exe "%CCMPATH%\TSCore.dll" -accepteula') DO ( IF "%%i %%j"=="File version:" SET CCMver=%%k )

@Echo SCCM Client version installed: %CCMVer%
@ECHO SCCM Client version installed: %CCMVer% >> %TEMP%\INSTALLR2SP1CU1.LOG

If "%CCMVer%"=="5.00.8239.1203 " GOTO x64Inst
If "%CCMVer%"=="5.00.8239.1000 " GOTO x64CU1

REM Require R2 SP1 and Patch to CU1
:INSTx64

@ECHO Installing R2 SP1 and patch to CU1 - Version of Client currently Installed: %CCMVer%
@echo Installing R2 SP1 and patch to CU1 - Version of Client currently Installed: %CCMVer% >> %TEMP%\INSTALLR2SP1CU1.Log

SET CCMSETUPPATH=%CCMPATH%SETUP
REM For Some Server installs the CCM Directory is %WINDIR%\ProgramFiles\SMS_CCM but the CCMSETUP is always on %WINDIR%
If Not "%CCMSETUPPATH%"=="%WINDIR%\CCMSETUP" SET CCMSETUPPATH=%WINDIR%\CCMSETUP
@Echo CCMSETUPPATH: %CCMSETUPPATH%
@Echo CCMSETUPPATH: %CCMSETUPPATH% >> %TEMP%\INSTALLR2SP1CU1.Log

If not exist "%CCMSETUPPATH%" GOTO x64Err1
copy "%~dp0cmtrace.exe" %CCMSETUPPATH% /y
copy "%~dp0patch\x64\configmgr2012ac-sp2r2sp1-kb3074857-x64.msp" %CCMSETUPPATH% /y
If ErrorLevel 1 GOTO x64Err2
If ErrorLevel 0 GOTO x64COPY1

:x64Copy1
@ECHO File Copied successfully, calling CCMSETUP to Install...
@ECHO File Copied successfully, calling CCMSETUP to Install... >> %TEMP%\INSTALLR2SP1CU1.LOG
Start %~dp0ccmsetup.exe /UsePKICert SMSSITECODE=CM1 /skipprereq:silverlight.exe FSP=[SERVER_REDACTED].[DOMAIN_REDACTED].com DNSSUFFIX=[DOMAIN_REDACTED] CCMHOSTNAME=[SERVER_REDACTED].[DOMAIN_REDACTED].com CCMLOGMAXSIZE=52488000 CCMLOGMAXHISTORY=5 SMSCACHESIZE=16384 PATCH="%CCMSETUPPATH%\configmgr2012ac-sp2r2sp1-kb3074857-x64.msp"
If ErrorLevel 1 GOTO x64Err3
If ErrorLevel 0 GOTO x64Good
EXIT 0

:x64CU1
@ECHO Installing CU1 - Version of Client currently Installed: %CCMVer%
@echo Installing CU1 - Version of Client currently Installed: %CCMVer% >> %TEMP%\INSTALLR2SP1CU1.Log

SET CCMSETUPPATH=%CCMPATH%SETUP
REM For Some Server installs the CCM Directory is %WINDIR%\ProgramFiles\SMS_CCM but the CCMSETUP is always on %WINDIR%
If Not "%CCMSETUPPATH%"=="%WINDIR%\CCMSETUP" SET CCMSETUPPATH=%WINDIR%\CCMSETUP
@Echo %CCMSETUPPATH%

If not exist "%CCMSETUPPATH%" GOTO x64Err1
copy "%~dp0cmtrace.exe" %CCMSETUPPATH% /y
copy "%~dp0patch\x64\configmgr2012ac-sp2r2sp1-kb3074857-x64.msp" %CCMSETUPPATH% /y
If ErrorLevel 1 GOTO x64Err2
If ErrorLevel 0 GOTO x64Copy2

:x64Copy2
@ECHO File Copied successfully, calling MSIExec to Apply CU1...
@ECHO File Copied successfully, calling MSIExec to Apply CU1... >> %TEMP%\INSTALLR2SP1CU1.LOG
Start msiexec.exe /p %CCMSETUPPATH%\configmgr2012ac-sp2r2sp1-kb3074857-x64.msp /L*v %TEMP%\configmgr2012ac-sp2r2sp1-kb3074857-x64.msp.LOG /q REINSTALL=ALL REINSTALLMODE=mous
If ErrorLevel 1 GOTO x64Err3
If ErrorLevel 0 GOTO x64Good
EXIT 0

:x64Good
@ECHO Successfully Installed R2 SP1 CU1 Update.
@ECHO Successfully Installed R2 SP1 CU1 Update. >> %TEMP%\INSTALLR2SP1CU1.LOG
EXIT 0

:x64Err1
@Echo Missing CCMSetup directory: %CCMSETUPPATH%
@ECHO Missing CCMSetup directory: %CCMSETUPPATH%. >> %TEMP%\INSTALLR2SP1CU1.LOG
Exit 1

:x64Err2
@Echo Copy CU1 to %CCMSETUPPATH% Failed.
@ECHO Copy CU1 to %CCMSETUPPATH% Failed. >> %TEMP%\INSTALLR2SP1CU1.LOG
Exit 2

:x64Err3
@Echo CU1 Install from Path:  %CCMSETUPPATH% - Failed!
@ECHO CU1 Install from Path:  %CCMSETUPPATH% - Failed! >> %TEMP%\INSTALLR2SP1CU1.LOG
Exit 3

:x64Inst
@ECHO Version R2 SP1 CU1 already installed: %CCMVER%
@ECHO Version R2 SP1 CU1 already installed: %CCMVER% >> %TEMP%\INSTALLR2SP1CU1.LOG

:Exit
Exit 0

:x86
@Echo Detected x86 Client
@Echo Detected x86 Client >> %TEMP%\INSTALLR2SP1CU1.LOG

REM Set Default value if Registry blank
SET CCMPATH=%WINDIR%\CCM

REM Force Install
If "%OVERRIDE%"=="1" GOTO INSTx86

REM Force Install if Client Not Detected
IF NOT EXIST "%CCMPATH%\TSCore.dll" GOTO INSTx86

@ECHO Started INSTALLR2SP1CU1.BAT > %TEMP%\INSTALLR2SP1CU1.LOG
for /f "tokens=5*" %%x in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SMS\Client\Configuration\Client Properties" /v "Local SMS Path"') do set CCMPATH=%%x
IF %CCMPATH:~-1%==\ SET CCMPATH=%CCMPATH:~0,-1%
@Echo CCM Client Path: %CCMPATH%
@Echo CCM Client Path: %CCMPATH% >> %TEMP%\INSTALLR2SP1CU1.LOG

FOR /F "tokens=1-3" %%i in ('%~dp0patch\i386\Sigcheck.exe "%CCMPATH%\TSCore.dll" -accepteula') DO ( IF "%%i %%j"=="File version:" SET CCMver=%%k )

@Echo SCCM Client version installed: %CCMVer%
@ECHO SCCM Client version installed: %CCMVer% >> %TEMP%\INSTALLR2SP1CU1.LOG

If "%OVERRIDE%"=="1" GOTO INSTx86
If "%CCMVer%"=="5.00.8239.1203 " GOTO x86Inst
If "%CCMVer%"=="5.00.8239.1000 " GOTO x86CU1

REM Require R2 SP1 and Patch to CU1
:INSTx86

@ECHO Installing R2 SP1 and patch to CU1 - Version of Client currently Installed: %CCMVer%
@echo Installing R2 SP1 and patch to CU1 - Version of Client currently Installed: %CCMVer% >> %TEMP%\INSTALLR2SP1CU1.Log

SET CCMSETUPPATH=%CCMPATH%SETUP
REM For Some Server installs the CCM Directory is %WINDIR%\ProgramFiles\SMS_CCM but the CCMSETUP is always on %WINDIR%
If Not "%CCMSETUPPATH%"=="%WINDIR%\CCMSETUP" SET CCMSETUPPATH=%WINDIR%\CCMSETUP

@Echo CCMSETUPPATH: %CCMSETUPPATH%
@Echo CCMSETUPPATH: %CCMSETUPPATH% >> %TEMP%\INSTALLR2SP1CU1.Log

If not exist "%CCMSETUPPATH%" GOTO x86Err1
copy "%~dp0cmtrace.exe" %CCMSETUPPATH% /y
copy "%~dp0patch\i386\configmgr2012ac-sp2r2sp1-kb3074857-i386.msp" %CCMSETUPPATH% /y
If ErrorLevel 1 GOTO x86Err2
If ErrorLevel 0 GOTO x86Copy

:x86Copy
@ECHO File Copied successfully, calling CCMSETUP to Install...
@ECHO File Copied successfully, calling CCMSETUP to Install... >> %TEMP%\INSTALLR2SP1CU1.LOG
Start %~dp0ccmsetup.exe /UsePKICert SMSSITECODE=CM1 /skipprereq:silverlight.exe FSP=[SERVER_REDACTED].[DOMAIN_REDACTED].com DNSSUFFIX=[DOMAIN_REDACTED].com CCMHOSTNAME=[SERVER_REDACTED].[DOMAIN_REDACTED].com CCMLOGMAXSIZE=52488000 CCMLOGMAXHISTORY=5 SMSCACHESIZE=16384 PATCH="%CCMSETUPPATH%\configmgr2012ac-sp2r2sp1-kb3074857-i386.msp"
If ErrorLevel 1 GOTO x86Err3
If ErrorLevel 0 GOTO x86Good
EXIT 0

:x86CU1
@ECHO Installing CU1 - Version of Client currently Installed: %CCMVer%
@echo Installing CU1 - Version of Client currently Installed: %CCMVer% >> %TEMP%\INSTALLR2SP1CU1.Log

SET CCMSETUPPATH=%CCMPATH%SETUP
REM For Some Server installs the CCM Directory is %WINDIR%\ProgramFiles\SMS_CCM but the CCMSETUP is always on %WINDIR%
If Not "%CCMSETUPPATH%"=="%WINDIR%\CCMSETUP" SET CCMSETUPPATH=%WINDIR%\CCMSETUP

@Echo %CCMSETUPPATH%

If not exist "%CCMSETUPPATH%" GOTO x86Err1
copy "%~dp0cmtrace.exe" %CCMSETUPPATH% /y
copy "%~dp0patch\i386\configmgr2012ac-sp2r2sp1-kb3074857-i386.msp" %CCMSETUPPATH% /y
If ErrorLevel 1 GOTO x86Err2
If ErrorLevel 0 GOTO x86Copy2

:x86Copy2
@ECHO File Copied successfully, calling MSIExec to Apply CU1...
@ECHO File Copied successfully, calling MSIExec to Apply CU1... >> %TEMP%\INSTALLR2SP1CU1.LOG
Start msiexec.exe /p %CCMSETUPPATH%\configmgr2012ac-sp2r2sp1-kb3074857-i386.msp /L*v %TEMP%\configmgr2012ac-sp2r2sp1-kb3074857-i386.msp.LOG /q REINSTALL=ALL REINSTALLMODE=mous
If ErrorLevel 1 GOTO x86Err3
If ErrorLevel 0 GOTO x86Good
EXIT 0

:x86Good
@ECHO Successfully Installed R2 SP1 CU1 Update.
@ECHO Successfully Installed R2 SP1 CU1 Update. >> %TEMP%\INSTALLR2SP1CU1.LOG
EXIT 0

:x86Err1
@Echo Missing CCMSetup directory: %CCMSETUPPATH%
@ECHO Missing CCMSetup directory: %CCMSETUPPATH%. >> %TEMP%\INSTALLR2SP1CU1.LOG
Exit 1

:x86Err2
@Echo Copy CU1 to %CCMSETUPPATH% Failed.
@ECHO Copy CU1 to %CCMSETUPPATH% Failed. >> %TEMP%\INSTALLR2SP1CU1.LOG
Exit 2

:x86Err3
@Echo CU1 Install from Path:  %CCMSETUPPATH% - Failed!
@ECHO CU1 Install from Path:  %CCMSETUPPATH% - Failed! >> %TEMP%\INSTALLR2SP1CU1.LOG
Exit 3

:x86Inst
@ECHO Version R2 SP1 CU1 already installed: %CCMVER%
@ECHO Version R2 SP1 CU1 already installed: %CCMVER% >> %TEMP%\INSTALLR2SP1CU1.LOG

:Exit
Exit 0

You can use a wait command for both the uninstall.exe and the BAT file.

The only reason to use run is if it NEVER exits and you have to kill it manually, or if you for some reason need to do 2 things in parallel.

It sounds like just using wait will solve your issues. In general, you should always use wait unless you have a very specific reason why it won’t work.

1 Like

Thanks jgstew.

However, the bath simply terminates after the lines of code are ran, before the install completes.

Did you try start /wait within your bat on the msiexec line?

2 Likes

I guess I missed that option. You are correct, if the parent process exits but the subprocess is still running, then the execution will move past the wait command even though things are not finished.

Even so, you can still use the wait command in actionscript, but you will likely need a pause while like you are using.

@JonL does make an interesting suggestion which may cause the BAT to wait the same way the actionscript would if you use start /wait to execute the installer from within the BAT file.

I’m not certain why you are having so much trouble with the pause while statement. I’d have to do some playing around with it.

The approach works for us in select situations.

In batch file:

start /wait cmd /K "<path>\prog.exe -arg -arg -arg"

In actionscript:

wait <path>\batch.bat

With some really finicky installers (ahem Oracle …), sometimes it is necessary to include the working path or other items as arguments for start. Proper quoting is also essential.

My SCOM admin uses a Powershell instead of batch to install SCOM. He runs it with the -wait parameter in Powershell. The Powershell itself is executed via wait in actionscript.

1 Like

Thanks all for the replies!

We resolved this by modifying the batch file with a wait loop.