none
MDT 2013 Update 1: Batch files are searched in C:\Windows\System32, not in application directory

    Question

  • I have multiple applications in MDT that use batch files for installation. They all do not work anymore since we upgraded to MDT 2013 Update 1 (it was still working in the preview version).

    I used Procmon and found that, when the installation command is "batchfile.cmd", BDD.EXE opens a process "c:\windows\system32\cmd.exe /c batchfile.cmd", and then that CMD process looks for

    • C:\Windows\batchfile.cmd
    • C:\Windows\System32\batchfile.cmd
    • C:\Windows\System32\wbem\batchfile.cmd
    • C:\Windows\System32\WindowsPowerShell\v1.0\batchfile.cmd

    and then exits with error code 1.

    Obviously CMD.EXE is executed in C:\Windows\System32, not in the specified working directory. It has been working in MDT 2012, MDT 2013, and MDT 2013 Update 1 Preview.

    Tuesday, August 18, 2015 9:44 AM

Answers

  • I updated my ZTIApplications.wsf file and this seems to be working for me.

    Original code

    ' // File:      ZTIApplications.wsf
    ' //
    ' // Version:   6.3.8290.1000

    	' Install the specified application
    
    		bModern = False
    		If oNode.selectSingleNode("CommandLine") is Nothing then
    			sCmd = ""
    		ElseIf oUtility.SelectSingleNodeString(oNode,"CommandLine") <> "" then
    			If UCase(Right(oUtility.SelectSingleNodeString(oNode,"CommandLine"),5)) = ".APPX" or UCase(Right(oUtility.SelectSingleNodeString(oNode,"CommandLine"),11)) = ".APPXBUNDLE" then
    				bModern = True
    			End if
    		End if
    
    
    		' Change to the current directory
    
    		If not oNode.selectSingleNode("WorkingDirectory") is nothing then
    
    			sDir = oUtility.SelectSingleNodeString(oNode,"WorkingDirectory")
    			If Trim(sDir) <> "" and Trim(sDir) <> "." then
    
    
    				If Left(sDir, 2) = ".\" then
    					If (Instr(1, sCmd, ".CMD", 1) > 0 or Instr(1, sCmd, ".BAT", 1) > 0) and oEnvironment.Item("ResourceDrive") <> "" then
    						If oEnvironment.Item("DeploymentMethod") = "MEDIA" then
    							sDir = oEnvironment.Item("ResourceRoot") & Mid(sDir, 2)
    						Else
    							sDir = oEnvironment.Item("ResourceDrive") & Mid(sDir, 2)
    						End If
    					Else
    						sDir = oEnvironment.Item("ResourceRoot") & Mid(sDir, 2)
    					End if
    				End if
    
    				sDir = oEnvironment.Substitute(sDir)
    
    				oUtility.ValidateConnection sDir
    
    				oLogging.CreateEntry vbTab & vbTab & "Change directory: " & sDir, LogTypeInfo
    				On Error Resume Next
    
    				oShell.CurrentDirectory = sDir
    
    				If Err then
    					oLogging.CreateEntry "WARNING - unable to set working directory: " & Err.Description & " (" & Err.Number & ")", LogTypeWarning
    				End if
    				On Error Goto 0
    
    			End if
    		End if
    
    
    		' Build the command line
    
    		If bModern then
    			sCmd = BuildAppxCommand(sDir, oNode)
    		Else 
    			sCmd = sBDDRun & " " & oEnvironment.Substitute(oUtility.SelectSingleNodeString(oNode,"CommandLine"))
    		End if

    Updated Code

    ' Install the specified application bModern = False If oNode.selectSingleNode("CommandLine") is Nothing then sCmd = "" ElseIf oUtility.SelectSingleNodeString(oNode,"CommandLine") <> "" then If UCase(Right(oUtility.SelectSingleNodeString(oNode,"CommandLine"),5)) = ".APPX" or UCase(Right(oUtility.SelectSingleNodeString(oNode,"CommandLine"),11)) = ".APPXBUNDLE" then bModern = True CheckAppXPolicy sCmd = "DISM.EXE /online /Add-ProvisionedAppxPackage /PackagePath:""" & oUtility.SelectSingleNodeString(oNode,"CommandLine") & """ /SkipLicense" Else sCmd = sBDDRun & " " & oEnvironment.Substitute(oUtility.SelectSingleNodeString(oNode,"CommandLine")) End if End if

    ' Build the command line

    If bModern then
    sCmd = BuildAppxCommand(sDir, oNode)
    'Else
    ' sCmd = sBDDRun & " " & oEnvironment.Substitute(oUtility.SelectSingleNodeString(oNode,"CommandLine")) End if ' Change to the current directory If not oNode.selectSingleNode("WorkingDirectory") is nothing then sDir = oUtility.SelectSingleNodeString(oNode,"WorkingDirectory") If Trim(sDir) <> "" and Trim(sDir) <> "." then If Left(sDir, 2) = ".\" then If (Instr(1, sCmd, ".CMD", 1) > 0 or Instr(1, sCmd, ".BAT", 1) > 0) and oEnvironment.Item("ResourceDrive") <> "" then If oEnvironment.Item("DeploymentMethod") = "MEDIA" then sDir = oEnvironment.Item("ResourceRoot") & Mid(sDir, 2) Else sDir = oEnvironment.Item("ResourceDrive") & Mid(sDir, 2) End If Else sDir = oEnvironment.Item("ResourceRoot") & Mid(sDir, 2) End if End if sDir = oEnvironment.Substitute(sDir) oUtility.ValidateConnection sDir oLogging.CreateEntry vbTab & vbTab & "Change directory: " & sDir, LogTypeInfo On Error Resume Next oShell.CurrentDirectory = sDir If Err then oLogging.CreateEntry "WARNING - unable to set working directory: " & Err.Description & " (" & Err.Number & ")", LogTypeWarning End if On Error Goto 0 End if End if



    • Edited by caylor Wednesday, August 19, 2015 3:55 PM
    • Proposed as answer by RSCSM Wednesday, August 19, 2015 6:22 PM
    • Marked as answer by svhelden Wednesday, August 19, 2015 6:24 PM
    Wednesday, August 19, 2015 3:43 PM

All replies

  • Have you got a working directory set?

    It would be .\Applications\{applicationname}

    Open up each application and it'll be the box just below the install command line.

    Tuesday, August 18, 2015 10:08 AM
  • Of course! The working directory is set correctly, for example to ".\Applications\Adobe Reader XI". And it had always worked until I upgraded to the new version. It is also working now unless the "Quiet install command" specifies a batch file.

    Tuesday, August 18, 2015 10:11 AM
  • Same Error.

    Now I use "%DEPLOYROOT%\Applications\{applicationname}\{applicationname}.bat" and it works again.

    I thik this is a Bug.


    Tuesday, August 18, 2015 10:16 AM
  • .

    "%DEPLOYROOT%\Applications\{applicationname}\{applicationname}.bat" and it works again.



    But this means that your batch file must also use the full path, I guess?

    If the batch file calls an EXE file which is in the same directory ... I think CMD would not look for THAT file in the working directory, so you would have to call "%DEPLOYROOT%\Applications\{applicationname}\{exefile}" in the script ... right?

    Tuesday, August 18, 2015 10:20 AM
  • Yes right.

    Stupid but only way.

    Tuesday, August 18, 2015 10:22 AM
  • Ok. Well, for the moment I used WinRAR to create SFX files from these folders. So I now have an EXE file that unpacks all files to %TEMP%, runs the batch file from there, and then removes the temporary file again.

    At least we know the reason now and have two possible workarounds.

    Tuesday, August 18, 2015 10:24 AM
  • Can you give me your Script. I want to try it. Thank You
    Tuesday, August 18, 2015 10:42 AM
  • Affected users might want to upvote the bug report: https://connect.microsoft.com/ConfigurationManagervnext/feedback/details/1682714
    Tuesday, August 18, 2015 10:48 AM
  • Can you give me your Script. I want to try it. Thank You

    Which script?

    For example, for Adobe Acrobat Reader DC, I previously had a directory with these files:

    AcroRdr20151500630033_MUI.exe
    AcroRdr2015Upd1500630060_MUI.msp
    reader_silent.cmd

    As "Quiet installation command" I had specified "reader_silent.cmd", which looks like this:

    AcroRdr20151500630033_MUI.exe /sPB /rs
    %systemroot%\system32\msiexec /update AcroRdr2015Upd1500630060_MUI.msp /passive /norestart

    Since it does not work like this anymore, I used WinRAR to create a self-extracting archive that contains all three files. The SFX extracts all files to a temporary directory, runs reader_silent.cmd from there, and then deletes the temporary files again.

    Tuesday, August 18, 2015 10:55 AM
  • I have multiple applications in MDT that use batch files for installation. They all do not work anymore since we upgraded to MDT 2013 Update 1 (it was still working in the preview version).

    <snap>

    and then exits with error code 1.

    Obviously CMD.EXE is executed in C:\Windows\System32, not in the specified working directory. It has been working in MDT 2012, MDT 2013, and MDT 2013 Update 1 Preview.

    Same problem for me. I will try %DEPLOYROOT% and/or "SFX". But as mentioned it seems to be a bug and I will report it. 
    Tuesday, August 18, 2015 12:15 PM
  • To clarify, can you tell me if this is batch script called from within ZTIApplications.wsf, or are you calling the step directly as step in the Task Sequencer?

    Keith Garner - Principal Consultant [owner] - http://DeploymentLive.com

    Wednesday, August 19, 2015 12:13 AM
    Moderator
  • I am having this issue too!  BROKE ALMOST EVERY APP I DEPLOY!

    Keith:

    These are applications called using "Applications" feature, so it is not that the batch files are being called using a Command Line sequence, rather an Application sequence.

    I wish I had kept a copy of the previous version (MDT 2013 non-Update 1) of ZTIApplications.wsf, as putting the old version back might fix this problem?

    Wednesday, August 19, 2015 2:12 AM
  • I found the previous version of ZTIApplications.wsf online (version 6.2.5019.0; https://github.com/WinPEGuy/MDT-ZTIApplications/blob/master/MDT%202013%20ZTIApplications%20-%20Default.wsf) and compared it to the MDT 2013 Update 1 version, and I don't see any differences that should cause .bat and .cmd to fail.  There is additional code in the update (version 6.3.8290.1000), but it looks all related to APPX installations.

    EDIT: I need to deploy and so I am going to give the old version a try.  I pulled the old version from the \Backups folder in MDT and copied that over the new one.  I will report back if that works.


    • Edited by -veechee- Wednesday, August 19, 2015 3:29 AM
    Wednesday, August 19, 2015 2:20 AM
  • Just got to applications installation on a laptop and with the old ZTIApplications.wsf it just launched it's first batch file.

    So I would say the best solution for now if you don't need to deploy Modern apps is to copy back the old ZTIApplications.wsf into \Scripts from \Backup.  The version should be 6.2.5019.0 for coming from MDT 2013.

    Another curious thing with MDT 2013 Update 1:

    It still partitions only 300 MB for WinRE.  I had updated my ZTIDiskpart.wsf script in MDT 2013 to partition 999 MB because with 300 MB I had issues with Windows 8.1 Update, I had issues with Recovery Environment not actually working because the free space was too small, so even though the file was there, it would not run.  Also, with only 300 MB it makes it impossible to use a WinRE with DaRT.  So I have increased this to 999 MB again in MDT 2013 Update 1's version of ZTIDiskpart.wsf.

    • Proposed as answer by -veechee- Wednesday, August 19, 2015 5:24 AM
    • Unproposed as answer by svhelden Wednesday, August 26, 2015 4:48 AM
    Wednesday, August 19, 2015 4:33 AM
  • I'm not a coder, but I suspect it is something here that breaks the .bat/.cmd installations.  This is starting at line 425 in the MDT 2013 Update 1 version of ZTIApplications.wsf.

            ' Build the command line        If bModern then            sCmd = BuildAppxCommand(sDir, oNode)        Else             sCmd = sBDDRun & " " & oEnvironment.Substitute(oUtility.SelectSingleNodeString(oNode,"CommandLine"))        End if

    • Proposed as answer by itssando Wednesday, August 26, 2015 1:16 AM
    • Unproposed as answer by svhelden Wednesday, August 26, 2015 4:48 AM
    Wednesday, August 19, 2015 4:35 AM
  • Ha, there are *NO* differences between the ZTIApplications.wsf file between MDT 2013 and MDT 2013 Update 1.

    I suspect that the problem is that Stand Alone Task Sequencer is launching cmd.exe in a different directory than what was done in MDT 2013, that combined with assumptions made in batch scripts where the full path is not specified, will cause scripts to fail.

    Would love to see what

    @echo %CD% > %Temp%\cmdpath.log

    shows when added to a batch script, additionally what ztiapplications.log shows.


    Keith Garner - Principal Consultant [owner] - http://DeploymentLive.com

    Wednesday, August 19, 2015 5:09 AM
    Moderator
  • I do not call this "*NO*" differences:

    Compare: (<)C:\MDT\Deploy\Backup\Scripts\ZTIApplications.wsf (16766 bytes)
       with: (>)C:\MDT\Deploy\Scripts\ZTIApplications.wsf.broken (18019 bytes)

    14c14
    < ' // Version:   6.2.5019.0
    ---
    > ' // Version:   6.3.8290.1000
    381,386c381,382
    <             If UCase(Right(oUtility.SelectSingleNodeString(oNode,"CommandLine"),5)) = ".APPX" then
    <                 bModern = True
    <                 CheckAppXPolicy
    <                 sCmd = "DISM.EXE /online /Add-ProvisionedAppxPackage /PackagePath:""" & oUtility.SelectSingleNodeString(oNode,"CommandLine") & """ /SkipLicense"
    <             Else
    <                 sCmd = sBDDRun & " " & oEnvironment.Substitute(oUtility.SelectSingleNodeString(oNode,"CommandLine"))
    ---
    >             If UCase(Right(oUtility.SelectSingleNodeString(oNode,"CommandLine"),5)) = ".APPX" or UCase(Right(oUtility.SelectSingleNodeString(oNode,"CommandLine"),11)) = ".APPXBUNDLE" then
    >                 bModern = True
    425,431d421
    <
    <                 ' If installing a modern app, make sure the certs in the working directory are imported
    <
    <                 If bModern then
    <                     InstallCerts sDir
    <                 End if
    <
    436a425,434
    >         ' Build the command line
    >
    >         If bModern then
    >             sCmd = BuildAppxCommand(sDir, oNode)
    >         Else
    >             sCmd = sBDDRun & " " & oEnvironment.Substitute(oUtility.SelectSingleNodeString(oNode,"CommandLine"))
    >         End if
    >
    >
    >
    496,522c495,502
    <     Function CheckAppXPolicy
    <         oShell.RegWrite "HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\Appx\AllowAllTrustedApps", 1, "REG_DWORD"
    <     End function
    <
    <
    <     Function InstallCerts(sDir)
    <         Dim iRC
    <         Dim oFile
    <         Dim sCmd
    <
    <         For each oFile in oFSO.GetFolder(sDir).Files
    <             If UCase(Right(oFile.Name,4)) = ".CER" then
    <
    <                 sCmd = "certutil.exe -addstore root """ & oFile.Path & """"
    <                 oLogging.CreateEntry "Importing certificate: " & sCmd, LogTypeInfo
    <                 iRC = oShell.Run(sCmd, 0, true)
    <                 oLogging.CreateEntry "Return code from CERTUTIL = " & iRC, LogTypeInfo
    <                 
    <             End if
    <         Next
    <
    <     End function
    <
    < End class
    <
    <     </script>
    < </job>
    ---
    >     Function BuildAppxCommand(sDir, oNode)
    >         Dim sCmd
    >         Dim sWorkingDir
    >         Dim sDependencyArch
    >         Dim oFile
    >         Dim bFoundLicense
    >         Dim iRC
    >         Dim sCertCmd
    523a504,577
    >
    >         ' Make sure policy is set
    >
    >         oShell.RegWrite "HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\Appx\AllowAllTrustedApps", 1, "REG_DWORD"
    >
    >
    >         ' Build the base command line
    >
    >         sCmd = "DISM.EXE /online /Add-ProvisionedAppxPackage /PackagePath:""" & oUtility.SelectSingleNodeString(oNode,"CommandLine") & """ "
    >
    >
    >         ' Determine where to check
    >
    >         If sDir = "" then
    >             sWorkingDir = oFSO.GetParentFolderName(oUtility.SelectSingleNodeString(oNode,"CommandLine"))
    >         Else
    >             sWorkingDir = sDir
    >         End if
    >
    >
    >         ' Add dependencies
    >
    >         If oFSO.FolderExists(sWorkingDir & "\Dependencies") then
    >             For each sDependencyArch in Array("x86", "x64", ".")
    >                 For each oFile in oFSO.GetFolder(sWorkingDir & "\Dependencies\" & sDependencyArch).Files
    >                     If UCase(Right(oFile.Name,4)) = ".APPX" then
    >                         sCmd = sCmd & " /DependencyPackagePath:""" & oFile.Path & """"
    >                     End if
    >                 Next
    >             Next
    >         End if
    >
    >
    >         ' Add license
    >
    >         bFoundLicense = False
    >         If oFSO.FolderExists(sWorkingDir) then
    >             For each oFile in oFSO.GetFolder(sWorkingDir).Files
    >                 If UCase(Right(oFile.Name,3)) = ".XML" then
    >                     sCmd = sCmd & " /LicensePath:""" & oFile.Path & """"
    >                     bFoundLicense = True
    >                 End if
    >             Next
    >         End if
    >         If not bFoundLicense then
    >             sCmd = sCmd & " /SkipLicense"
    >         End if
    >
    >
    >         ' Return the command line
    >
    >         BuildAppxCommand = sCmd
    >
    >
    >         ' Install any certs that are found in the working directory
    >
    >         For each oFile in oFSO.GetFolder(sWorkingDir).Files
    >             If UCase(Right(oFile.Name,4)) = ".CER" then
    >
    >                 sCertCmd = "certutil.exe -addstore root """ & oFile.Path & """"
    >                 oLogging.CreateEntry "Importing certificate: " & sCertCmd, LogTypeInfo
    >                 iRC = oShell.Run(sCertCmd, 0, true)
    >                 oLogging.CreateEntry "Return code from CERTUTIL = " & iRC, LogTypeInfo
    >                 
    >             End if
    >         Next
    >
    >     End function
    >
    > End class
    >
    >     </script>
    > </job>
    >

    Wednesday, August 19, 2015 5:15 AM
  • Furthermore:

    BAT/CMD Install files successfully deployed with ZTIApplications.wsf version 6.3.8290.1000:

    0/34 each on 3 systems

    BAT/CMD Install files successfully deployed with ZTIApplications.wsf version 6.2.5019.0:

    34/34 on 3 systems

    So there must be an error in that file somewhere...

    Wednesday, August 19, 2015 5:24 AM
  • Whoops my bad, I was comparing the wrong versions.

    Yea, This is a bug. Wow, it's a good one.

    Someone moved the this line:

                    sCmd = sBDDRun & " " & oEnvironment.Substitute(oUtility.SelectSingleNodeString(oNode,"CommandLine"))

    to a point after this code:

    If not oNode.selectSingleNode("WorkingDirectory") is nothing then
           sDir = oUtility.SelectSingleNodeString(oNode,"WorkingDirectory")
           If Trim(sDir) <> "" and Trim(sDir) <> "." then
                  If Left(sDir, 2) = ".\" then
    
                         If (Instr(1, sCmd, ".CMD", 1) > 0 or Instr(1, sCmd, ".BAT", 1) > 0) and oEnvironment.Item("ResourceDrive") <> "" then
                               If oEnvironment.Item("DeploymentMethod") = "MEDIA" then
                                      sDir = oEnvironment.Item("ResourceRoot") & Mid(sDir, 2)
                               Else
                                      sDir = oEnvironment.Item("ResourceDrive") & Mid(sDir, 2)
                               End If
                         Else
                               sDir = oEnvironment.Item("ResourceRoot") & Mid(sDir, 2)
                         End if
                  End if
    
                  sDir = oEnvironment.Substitute(sDir)
    
                  oUtility.ValidateConnection sDir
    
                  oLogging.CreateEntry vbTab & vbTab & "Change directory: " & sDir, LogTypeInfo
                  On Error Resume Next
    
                  oShell.CurrentDirectory = sDir
    
    Work around is to use ZTIApplications.wsf from MDT 2013 if you don't use Appx files


    Keith Garner - Principal Consultant [owner] - http://DeploymentLive.com


    Wednesday, August 19, 2015 6:00 AM
    Moderator
  • Thanks, but what is the solution then? Just move the line "sCmd =..." before the line "If not oNode..."?
    Wednesday, August 19, 2015 6:06 AM
  • My three laptops completed installing all my .BAT apps using the old version, but now I have another issue:

    When the Task Sequence is done, Lite Touch install stops.  Rebooting comes up with the prompt on autologon that a deployment is not in it's expected state and do I want to start a new one or not.  So it doesn't clean itself up and tell me the install completed.  I ran LTICleanup.vbs on the laptops to manually clean things up (after verifying all apps and packages and Windows Updates did run as intended), but even that left the 'cscript LiteTouch.vbs' entry in Common Startup, so I deleted that with CCleaner and I believe I have good, usable deployments.

    I copied the logs off two of the machines to try figure out what went on.  Will post more tomorrow.



    • Edited by -veechee- Wednesday, August 19, 2015 6:44 AM
    Wednesday, August 19, 2015 6:43 AM
  •  

    Rebooting comes up with the prompt on autologon that a deployment is not in it's expected state

    Did one of your installation scripts reboot the computer (instead of using MDT's reboot option)?
    Wednesday, August 19, 2015 6:52 AM
  • I've not installed MDT 2013 update 1 myself.

    Here's a suggestion I hope someone could try. I use the Adobe Acrobat Reader as example.

    Content of install.cmd

    "%~dp0AcroRdr20151500630033_MUI.exe" /sPB /rs
    msiexec /update "%~dp0AcroRdr2015Upd1500630060_MUI.msp" /passive /norestart

    For the application silent install command line just set to .\install (or cmd.exe /c .\install) not install.cmd

    Working directory should be where the Adobe Reader .exe and .msp file are. Example
    .\Applications\Adobe Reader 2015 DC




    Wednesday, August 19, 2015 7:53 AM
  • That might work if you combine it with the other suggestion and use "%DEPLOYROOT%\Applications\{applicationname}\{applicationname}.cmd" as installation command.
    Wednesday, August 19, 2015 8:02 AM
  • To clarify, can you tell me if this is batch script called from within ZTIApplications.wsf, or are you calling the step directly as step in the Task Sequencer?

    Hi Keith,

    the batch script is called within ZTIAppliciations.wsf from my application.

    In the mean time I tried your proposal from below to use the old File ( ZTIApplications.wsf, Version:   6.2.5019.0) and for me it works (Deployment Summary: Success)! To be sure I rebooted manually my test machine and there is no extra inside common "Startup". My installation seems to be ok now.

    I am not using Appx and I have no additional Restarts in my Tasksequence.

    Wednesday, August 19, 2015 8:04 AM
  • I updated my ZTIApplications.wsf file and this seems to be working for me.

    Original code

    ' // File:      ZTIApplications.wsf
    ' //
    ' // Version:   6.3.8290.1000

    	' Install the specified application
    
    		bModern = False
    		If oNode.selectSingleNode("CommandLine") is Nothing then
    			sCmd = ""
    		ElseIf oUtility.SelectSingleNodeString(oNode,"CommandLine") <> "" then
    			If UCase(Right(oUtility.SelectSingleNodeString(oNode,"CommandLine"),5)) = ".APPX" or UCase(Right(oUtility.SelectSingleNodeString(oNode,"CommandLine"),11)) = ".APPXBUNDLE" then
    				bModern = True
    			End if
    		End if
    
    
    		' Change to the current directory
    
    		If not oNode.selectSingleNode("WorkingDirectory") is nothing then
    
    			sDir = oUtility.SelectSingleNodeString(oNode,"WorkingDirectory")
    			If Trim(sDir) <> "" and Trim(sDir) <> "." then
    
    
    				If Left(sDir, 2) = ".\" then
    					If (Instr(1, sCmd, ".CMD", 1) > 0 or Instr(1, sCmd, ".BAT", 1) > 0) and oEnvironment.Item("ResourceDrive") <> "" then
    						If oEnvironment.Item("DeploymentMethod") = "MEDIA" then
    							sDir = oEnvironment.Item("ResourceRoot") & Mid(sDir, 2)
    						Else
    							sDir = oEnvironment.Item("ResourceDrive") & Mid(sDir, 2)
    						End If
    					Else
    						sDir = oEnvironment.Item("ResourceRoot") & Mid(sDir, 2)
    					End if
    				End if
    
    				sDir = oEnvironment.Substitute(sDir)
    
    				oUtility.ValidateConnection sDir
    
    				oLogging.CreateEntry vbTab & vbTab & "Change directory: " & sDir, LogTypeInfo
    				On Error Resume Next
    
    				oShell.CurrentDirectory = sDir
    
    				If Err then
    					oLogging.CreateEntry "WARNING - unable to set working directory: " & Err.Description & " (" & Err.Number & ")", LogTypeWarning
    				End if
    				On Error Goto 0
    
    			End if
    		End if
    
    
    		' Build the command line
    
    		If bModern then
    			sCmd = BuildAppxCommand(sDir, oNode)
    		Else 
    			sCmd = sBDDRun & " " & oEnvironment.Substitute(oUtility.SelectSingleNodeString(oNode,"CommandLine"))
    		End if

    Updated Code

    ' Install the specified application bModern = False If oNode.selectSingleNode("CommandLine") is Nothing then sCmd = "" ElseIf oUtility.SelectSingleNodeString(oNode,"CommandLine") <> "" then If UCase(Right(oUtility.SelectSingleNodeString(oNode,"CommandLine"),5)) = ".APPX" or UCase(Right(oUtility.SelectSingleNodeString(oNode,"CommandLine"),11)) = ".APPXBUNDLE" then bModern = True CheckAppXPolicy sCmd = "DISM.EXE /online /Add-ProvisionedAppxPackage /PackagePath:""" & oUtility.SelectSingleNodeString(oNode,"CommandLine") & """ /SkipLicense" Else sCmd = sBDDRun & " " & oEnvironment.Substitute(oUtility.SelectSingleNodeString(oNode,"CommandLine")) End if End if

    ' Build the command line

    If bModern then
    sCmd = BuildAppxCommand(sDir, oNode)
    'Else
    ' sCmd = sBDDRun & " " & oEnvironment.Substitute(oUtility.SelectSingleNodeString(oNode,"CommandLine")) End if ' Change to the current directory If not oNode.selectSingleNode("WorkingDirectory") is nothing then sDir = oUtility.SelectSingleNodeString(oNode,"WorkingDirectory") If Trim(sDir) <> "" and Trim(sDir) <> "." then If Left(sDir, 2) = ".\" then If (Instr(1, sCmd, ".CMD", 1) > 0 or Instr(1, sCmd, ".BAT", 1) > 0) and oEnvironment.Item("ResourceDrive") <> "" then If oEnvironment.Item("DeploymentMethod") = "MEDIA" then sDir = oEnvironment.Item("ResourceRoot") & Mid(sDir, 2) Else sDir = oEnvironment.Item("ResourceDrive") & Mid(sDir, 2) End If Else sDir = oEnvironment.Item("ResourceRoot") & Mid(sDir, 2) End if End if sDir = oEnvironment.Substitute(sDir) oUtility.ValidateConnection sDir oLogging.CreateEntry vbTab & vbTab & "Change directory: " & sDir, LogTypeInfo On Error Resume Next oShell.CurrentDirectory = sDir If Err then oLogging.CreateEntry "WARNING - unable to set working directory: " & Err.Description & " (" & Err.Number & ")", LogTypeWarning End if On Error Goto 0 End if End if



    • Edited by caylor Wednesday, August 19, 2015 3:55 PM
    • Proposed as answer by RSCSM Wednesday, August 19, 2015 6:22 PM
    • Marked as answer by svhelden Wednesday, August 19, 2015 6:24 PM
    Wednesday, August 19, 2015 3:43 PM
  • caylor,

    So you just move the "Build the command line" portion further up and it's fixed?


    • Edited by -veechee- Wednesday, August 19, 2015 5:50 PM
    Wednesday, August 19, 2015 5:50 PM
  • Thank you for this. Back in business.
    Wednesday, August 19, 2015 6:22 PM
  • I did 2 things, sorry I know this can be a little confusing. 

    ADDED

    Else
      sCmd = sBDDRun & " " & oEnvironment.Substitute(oUtility.SelectSingleNodeString(oNode,"CommandLine"))

    into the following section

    If oNode.selectSingleNode("CommandLine") is Nothing then
    sCmd = ""
    ElseIf oUtility.SelectSingleNodeString(oNode,"CommandLine") <> "" then
    If UCase(Right(oUtility.SelectSingleNodeString(oNode,"CommandLine"),5)) = ".APPX" or UCase(Right(oUtility.SelectSingleNodeString(oNode,"CommandLine"),11)) = ".APPXBUNDLE" then
    bModern = True
    CheckAppXPolicy
    sCmd = "DISM.EXE /online /Add-ProvisionedAppxPackage /PackagePath:""" & oUtility.SelectSingleNodeString(oNode,"CommandLine") & """ /SkipLicense"
    Else
    sCmd = sBDDRun & " " & oEnvironment.Substitute(oUtility.SelectSingleNodeString(oNode,"CommandLine"))
    End if
    End if

    I then moved the Build the command line up and excluded the following, that's what the ' does.

    ' Else

    ' sCmd = sBDDRun & " " & oEnvironment.Substitute(oUtility.SelectSingleNodeString(oNode,"CommandLine"))

    Wednesday, August 19, 2015 8:10 PM
  • Here is the full contents of the Update ZTIApplications.wsf file from my scripts Directory

    <job id="ZTIApplications">
    	<script language="VBScript" src="ZTIUtility.vbs"/>
    	<script language="VBScript" src="ZTIConfigFile.vbs"/>
    	<script language="VBScript">
    
    ' // ***************************************************************************
    ' // 
    ' // Copyright (c) Microsoft Corporation.  All rights reserved.
    ' // 
    ' // Microsoft Deployment Toolkit Solution Accelerator
    ' //
    ' // File:      ZTIApplications.wsf
    ' // 
    ' // Version:   6.3.8290.1000
    ' // 
    ' // Purpose:   Install a list of applications
    ' // 
    ' // Usage:     cscript.exe [//nologo] ZTIApplications.wsf [/debug:true]
    ' // 
    ' // ***************************************************************************
    
    Option Explicit
    RunNewInstance
    
    
    '//----------------------------------------------------------------------------
    '//  Main Class
    '//----------------------------------------------------------------------------
    
    Class ZTIApplications
    
    	'//----------------------------------------------------------------------------
    	'//  Class instance variable declarations
    	'//----------------------------------------------------------------------------
    
    	Dim oApplications
    	Dim oInstalledApplications
    	' Dim oXMLDoc
    	Dim oXMLApps
    	Dim dAvaiableApps
    	Dim sBDDRun
    	Dim aLanguages
    	Dim oDependentApplications
    	
    	Dim g_ApplicationSuccessCodes
    	
    
    	'//----------------------------------------------------------------------------
    	'//  Constructor to initialize needed global objects
    	'//----------------------------------------------------------------------------
    
    	Private Sub Class_Initialize
    
    		g_ApplicationSuccessCodes = " 0 3010 "
    	End Sub
    	
    	
    	'//----------------------------------------------------------------------------
    	'//  Main routine
    	'//----------------------------------------------------------------------------
    
    	Function Main
    	
    		Dim iRetVal, sGuid, sCmd, bValidProcessorType
    		Dim iApplicationCount, iPercent
    		Dim sApplicationType
    
    		iRetVal = Success
    
    		' Validate that are not restarting from a failed install.
    
    		If ucase(oEnv("SystemDrive")) = "X:" Then
    			oLogging.CreateEntry "Environment Error: ManualRetry (From ZTIApplications).", LogTypeInfo
    
    			oEnvironment.Item("LTISuspend") = "LiteTouch is trying to install applications." & _
    				vbNewLine & "This cannot be performed in Windows PE." & _
    				vbNewLine & "If booting from a USB Flash Disk, please remove all drives before restarting." & _
    				vbNewLine & "Otherwise, ensure the hard disk is selected first in the BIOS boot order."
    			oEnvironment.Item("SMSTSRebootRequested") = "true"
    			oEnvironment.Item("SMSTSRetryRequested") = "true"
    			Main = SUCCESS
    			Exit Function
    		End if
    
    
    		' Prepare the Deployment Root Directory
    
    		If oEnvironment.Item("ResourceRoot") = "" then
    			oEnvironment.Item("ResourceRoot") = oFSO.GetParentFolderName(oUtility.ScriptDir)
    		End if
    
    
    		' Load the XML File
    		set oXMLApps = new ConfigFile
    		oXMLApps.sFileType = "Applications"
    		set dAvaiableApps = oXMLApps.FindAllItems
    
    		' Find our stub program
    
    		iRetVal = oUtility.FindFile("bddrun.exe", sBDDRun)
    		TestAndLog iRetVal, "Find File: BDDRun.exe"
    
    
    		if isempty(aLanguages) then
    			aLanguages = array( cstr(GetLocale), right("0000" & hex(GetLocale),4), "0x" & right("0000" & hex(GetLocale),4), _
    					cstr(GetLocale() and &h03ff), right("0000" & hex(GetLocale() and &h03ff),4), "0x" & right("0000" & hex(GetLocale() and &h03ff),4)  )
    		end if
    		oLogging.CreateEntry "Language/Locale Identified (in order of precedence): " & join(aLanguages,","), LogTypeInfo
    
    
    		' Load the list of already-installed applications (probably doesn't exist yet)
    
    		Set oInstalledApplications = oEnvironment.ListItem("InstalledApplications")
    
    		Set oDependentApplications = oEnvironment.ListItem("DependentApplications")
    
    
    		' Check that an individual application guid wasn't passed via the commmand line.
    		' This is a mandatory single install intiate by a Task Sequence action.
            
    		If oEnvironment.Item("ApplicationSuccessCodes") <> "" then
    		g_ApplicationSuccessCodes = " " & oEnvironment.Item("ApplicationSuccessCodes") & " "
    		End if
    		
    		If oEnvironment.Item("ApplicationGUID") <> "" Then
    			oLogging.CreateEntry "Mandatory Single Application install indicated. Guid: " & oEnvironment.Item("ApplicationGUID"), LogTypeInfo
    
    			iRetVal = InstallApplication(oEnvironment.Item("ApplicationGUID"), 0)
    
    			If iRetVal = 3010 then  ' Reboot requested
    
    				' Set properties to indicate a reboot is needed and this script should be re-executed
    
    				oEnvironment.Item("SMSTSRebootRequested") = "true"
    				oEnvironment.Item("SMSTSRetryRequested") = "true"
    
    				oLogging.CreateEntry "Exiting to initiate a reboot with retry (to pick up where we left off)", LogTypeInfo
    				Main = Success
    
    				Exit Function
    
    			End if
    
    			Main = 0   ' Always succeed.  The errors and warnings from above will be reported so the process can continue.
    			Exit Function
    		End If
    		
    		' Load the list of Applications stored in the enviroment. First we being by processing the MandatoryApplication
    		' and then follow with the normal user selected Applications.
    
    		For Each sApplicationType in Array("MandatoryApplications", "Applications")
    			oLogging.CreateEntry "Processing Application Type: " & sApplicationType, LogTypeInfo
    
    			Set oApplications = oEnvironment.ListItem(sApplicationType)
    
    			If oApplications.Count = 0 then
    				oLogging.CreateEntry "Application List is empty, exiting ZTIApplications.wsf", LogTypeInfo
    				Main = Success
    			Else
    
    				' Process the list
    
    				oLogging.CreateEntry "Ready to install applications: " , LogTypeInfo
    				iApplicationCount = 0
    				For each sGuid in oApplications
    
    					iApplicationCount = iApplicationCount + 1
    					iPercent = CLng(iApplicationCount / oApplications.Count * 100)
    					iRetVal = InstallApplication(sGuid, iPercent)
    
    					If iRetVal = 3010 then  ' Reboot requested
    
    						' Set properties to indicate a reboot is needed and this script should be re-executed
    
    						oEnvironment.Item("SMSTSRebootRequested") = "true"
    						oEnvironment.Item("SMSTSRetryRequested") = "true"
    
    						oLogging.CreateEntry "Exiting to initiate a reboot with retry (to pick up where we left off)", LogTypeInfo
    						iRetVal = Success
    
    						Exit Function
    
    					End if
    
    				Next
    
    			End if
    
    		Next
    
    
    		'Cleanup and Exit
    
    		Main = iRetVal
    
    	End Function
    	
    	
    		
    
    	Function InstallApplication(sGuid, iPercent)
    
    		Dim oNode
    		Dim oDependentNode
    		Dim sDependentGuid
    		Dim sDir
    		Dim sCmd
    		Dim bValidProcessorType
    		Dim iResult
    		Dim sError
    		Dim sKey
    		Dim sValueName
    		Dim sValue
    		Dim oSupportedPlatformNode
    		Dim sSupportedPlatform
    		Dim bSupportedPlaformRequired
    		Dim bSupportedPlatformFound
    		Dim bModern
    
    
    		InstallApplication = Success
    		bSupportedPlaformRequired = False
    
    
    		' Check if application has already been installed
    
    		If oInstalledApplications.Exists(sGuid) then
    			oLogging.CreateEntry "Application " & sGuid & " has already been installed, will not install again.", LogTypeInfo
    			Exit Function
    		End if
    
    
    		' Find the entry in the XML document
    
    		If not dAvaiableApps.Exists(sGuid) then
    			oLogging.CreateEntry "ERROR, application GUID " & sGuid & " not found in application list, unable to execute", LogTypeError
    			Exit Function
    		Else
    			set oNode = dAvaiableApps.Item(sGuid)
    		End if
    
    
    		' Log details of the application
    
    		oLogging.CreateEntry "################", LogTypeInfo
    		oLogging.CreateEntry "Entry: " & sGuid, LogTypeInfo
    		oLogging.CreateEntry "Name:  " & oUtility.SelectSingleNodeString(oNode,"Name"), LogTypeInfo
    		oLogging.CreateEntry "################", LogTypeInfo
    
    
    
    		' Use supported platform options to confirm application is applicable.
    
    		For each oSupportedPlatformNode in oNode.SelectNodes("SupportedPlatform")
    			sSupportedPlatform = oSupportedPlatformNode.Text
    			bSupportedPlaformRequired = True
    			bSupportedPlatformFound = False
    
    			oLogging.CreateEntry "################", LogTypeInfo
    			oLogging.CreateEntry vbTab & "Supported Platform entry: " & sSupportedPlatform, LogTypeInfo
    			oLogging.CreateEntry "################", LogTypeInfo
    
    
    			bSupportedPlatformFound = oUtility.IsSupportedPlatform(sSupportedPlatform)
    
    			If bSupportedPlatformFound = true Then
    				oLogging.CreateEntry vbTab & "Supported Platform Matched: " & sSupportedPlatform, LogTypeInfo
    				Exit For
    			End If
    		Next
    
    		If bSupportedPlaformRequired = True Then
    			If bSupportedPlatformFound <> True Then
    				oLogging.CreateEntry "Supported Plaform requirements not met, skipping this application", LogTypeInfo
    				Exit Function
    			End If
    		End If
    
    
    		' Make sure this should run for this Language Locale. If not, abort.
    
    		bValidProcessorType = TRUE
    		If not oNode.selectSingleNode("Language") is nothing then
    			sValueName = ucase(oUtility.SelectSingleNodeString(oNode,"Language"))
    			If sValueName <> "" then
    
    				' Removing logic because there is nothing in the documentation that indicates what valid values are nor are there
    				' any validations performed.  Users have typically used this as more of a comment field, so this would be a breaking
    				' change.
    				'  bValidProcessorType = FALSE
    
    				for each sValue in aLanguages
    					if ucase(sValue) = sValueName then
    						bValidProcessorType = TRUE
    						exit for
    					end if
    				next
    			End if
    		End if
    
    		If not bValidProcessorType then
    			oLogging.CreateEntry vbTab & vbTab & "Incorrect Language Type: " & oUtility.SelectSingleNodeString(oNode,"Language") & " = " &  GetLocale(), LogTypeInfo
    			Exit Function
    		End if
    
    
    		' See if the uninstall registry key already exists, indicating that the app is installed
    
    		If not oNode.selectSingleNode("UninstallKey") is Nothing then
    			sKey = oUtility.SelectSingleNodeString(oNode,"UninstallKey")
    			If oUtility.SelectSingleNodeString(oNode,"UninstallKey") <> "" then
    
    				' Check if the registry key exists
    
    				For each sValueName in Array("DisplayName", "UninstallString", "QuietUninstallString")
    
    					sValue = empty
    					on error resume next
    						sValue = oShell.RegRead("HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\" & sKey & "\" & sValueName)
    					on error goto 0
    
    					If IsEmpty(sValue) then
    						On error resume next
    							sValue = oShell.RegRead("HKLM\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\" & sKey & "\" & sValueName)
    						On error goto 0
    					End if
    
    					If not isempty(sValue) then
    						oLogging.CreateEntry "Uninstall registry key found, application is already installed.", LogTypeInfo
    						Exit Function
    					End if
    
    				Next
    
    			End if
    		End if
    
    
    		' Process any dependent programs
    
    
    		For each oDependentNode in oNode.SelectNodes("Dependency")
    
    			sDependentGuid = oDependentNode.Text
    			If oDependentApplications.Exists(sDependentGuid) then
    				oLogging.CreateEntry "Dependent Application has already been referenced, skipping application", LogTypeInfo
    			Else	
    				oDependentApplications.Add sDependentGuid, ""
    				oLogging.CreateEntry "################", LogTypeInfo
    				oLogging.CreateEntry vbTab & "Dependent entry: " & sDependentGuid, LogTypeInfo
    				oLogging.CreateEntry "################", LogTypeInfo
    				
    				iResult = InstallApplication(sDependentGuid, iPercent)
    
    				If iResult = 3010 then  ' Reboot requested
    
    					oLogging.CreateEntry "Dependent application requested a reboot", LogTypeInfo
    	
    					InstallApplication = 3010
    					Exit Function
    
    				End if
    			End If
    		Next
    
    		' Check if application has already been installed.  Could have been installed by a dependent application
    
    		If oInstalledApplications.Exists(sGuid) then
    			oLogging.CreateEntry "Application " & sGuid & " has already been installed, will not install again.", LogTypeInfo
    			Exit Function
    		End if
    
    
    
    		' Install the specified application
    
    		bModern = False
    		If oNode.selectSingleNode("CommandLine") is Nothing then
    			sCmd = ""
    		ElseIf oUtility.SelectSingleNodeString(oNode,"CommandLine") <> "" then
    			If UCase(Right(oUtility.SelectSingleNodeString(oNode,"CommandLine"),5)) = ".APPX" or UCase(Right(oUtility.SelectSingleNodeString(oNode,"CommandLine"),11)) = ".APPXBUNDLE" then
    				bModern = True
    			Else 
    				sCmd = sBDDRun & " " & oEnvironment.Substitute(oUtility.SelectSingleNodeString(oNode,"CommandLine"))
    			End if
    		End if
    
    		' Build the command line
    
    		If bModern then
    			sCmd = BuildAppxCommand(sDir, oNode)
    		' Else 
    		'	sCmd = sBDDRun & " " & oEnvironment.Substitute(oUtility.SelectSingleNodeString(oNode,"CommandLine"))
    		End if
    
    		' Change to the current directory
    
    		If not oNode.selectSingleNode("WorkingDirectory") is nothing then
    
    			sDir = oUtility.SelectSingleNodeString(oNode,"WorkingDirectory")
    			If Trim(sDir) <> "" and Trim(sDir) <> "." then
    
    
    				If Left(sDir, 2) = ".\" then
    					If (Instr(1, sCmd, ".CMD", 1) > 0 or Instr(1, sCmd, ".BAT", 1) > 0) and oEnvironment.Item("ResourceDrive") <> "" then
    						If oEnvironment.Item("DeploymentMethod") = "MEDIA" then
    							sDir = oEnvironment.Item("ResourceRoot") & Mid(sDir, 2)
    						Else
    							sDir = oEnvironment.Item("ResourceDrive") & Mid(sDir, 2)
    						End If
    					Else
    						sDir = oEnvironment.Item("ResourceRoot") & Mid(sDir, 2)
    					End if
    				End if
    
    				sDir = oEnvironment.Substitute(sDir)
    
    				oUtility.ValidateConnection sDir
    
    				oLogging.CreateEntry vbTab & vbTab & "Change directory: " & sDir, LogTypeInfo
    				On Error Resume Next
    
    				oShell.CurrentDirectory = sDir
    
    				If Err then
    					oLogging.CreateEntry "WARNING - unable to set working directory: " & Err.Description & " (" & Err.Number & ")", LogTypeWarning
    				End if
    				On Error Goto 0
    
    			End if
    		End if
    
    
    
    
    
    
    		' Launch Command
    
    		If sCmd = "" then
    			oLogging.CreateEntry vbTab & vbTab & "Run Command is missing. ", LogTypeInfo
    		Else
    			oLogging.ReportProgress "Installing " & oUtility.SelectSingleNodeString(oNode,"Name"), iPercent
    			oLogging.CreateEntry vbTab & vbTab & "Run Command: " & sCmd, LogTypeInfo
    			oLogging.CreateEvent 41031, LogTypeInfo, "ZTI installing application ", Array(sGuid, oUtility.SelectSingleNodeString(oNode,"Name"))
    
    			On Error Resume Next
    
    
    			If bModern then
    				iResult = oShell.Run(sCmd, 0, true)
    			Else
    				iResult = oUtility.RunWithHeartbeat(sCmd)
    			End if
    
    			If Err then
    				iResult = Err.number
    				sError = Err.Description
    				oLogging.CreateEvent 41032, LogTypeError, "Error installing application " & oUtility.SelectSingleNodeString(oNode,"Name") & ": " & sError, Array(sGuid, oUtility.SelectSingleNodeString(oNode,"Name"), sError)
    			ElseIf instr(1,g_ApplicationSuccessCodes," " & iResult & " ",vbTextCompare ) <> 0 then
    				oLogging.CreateEvent 41033, LogTypeInfo, "Application " & oUtility.SelectSingleNodeString(oNode,"Name") & " installed successfully", Array(sGuid, oUtility.SelectSingleNodeString(oNode,"Name"), iResult)
    				If iResult <> 3010 then
    					' Normalize the results to either 3010 or 0 if successfull.
    					iResult = 0
    				End if
    			Else
    				oLogging.CreateEvent 41034, LogTypeError, "Application " & oUtility.SelectSingleNodeString(oNode,"Name") & " returned an unexpected return code: " & iResult, Array(sGuid, oUtility.SelectSingleNodeString(oNode,"Name"), iResult)
    			End if
    
    			On Error Goto 0
    
    		End if
    
    		' Update the list of installed applications
    
    		oInstalledApplications.Add sGuid, ""
    		Set oEnvironment.ListItem("InstalledApplications") = oInstalledApplications
    
    		'See if a reboot is needed
    
    		If not oNode.selectSingleNode("Reboot") is Nothing then
    
    			If UCase(oUtility.SelectSingleNodeString(oNode,"Reboot")) = "TRUE" then
    
    				oLogging.CreateEntry "Application " & oUtility.SelectSingleNodeString(oNode,"Name") & " needs a reboot, initiating.", LogTypeInfo
    				InstallApplication = 3010  ' Reboot indicator
    				Exit Function
    
    			End if
    
    		End if
    
    
    
    	End Function
    	
    
    	Function BuildAppxCommand(sDir, oNode)
    		Dim sCmd
    		Dim sWorkingDir
    		Dim sDependencyArch
    		Dim oFile
    		Dim bFoundLicense
    		Dim iRC
    		Dim sCertCmd
    
    
    		' Make sure policy is set
    
    		oShell.RegWrite "HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\Appx\AllowAllTrustedApps", 1, "REG_DWORD"
    
    
    		' Build the base command line
    
    		sCmd = "DISM.EXE /online /Add-ProvisionedAppxPackage /PackagePath:""" & oUtility.SelectSingleNodeString(oNode,"CommandLine") & """ "
    
    
    		' Determine where to check
    
    		If sDir = "" then
    			sWorkingDir = oFSO.GetParentFolderName(oUtility.SelectSingleNodeString(oNode,"CommandLine"))
    		Else
    			sWorkingDir = sDir
    		End if
    
    
    		' Add dependencies
    
    		If oFSO.FolderExists(sWorkingDir & "\Dependencies") then
    			For each sDependencyArch in Array("x86", "x64", ".")
    				For each oFile in oFSO.GetFolder(sWorkingDir & "\Dependencies\" & sDependencyArch).Files
    					If UCase(Right(oFile.Name,4)) = ".APPX" then
    						sCmd = sCmd & " /DependencyPackagePath:""" & oFile.Path & """"
    					End if
    				Next
    			Next
    		End if
    
    
    		' Add license
    
    		bFoundLicense = False
    		If oFSO.FolderExists(sWorkingDir) then
    			For each oFile in oFSO.GetFolder(sWorkingDir).Files
    				If UCase(Right(oFile.Name,3)) = ".XML" then
    					sCmd = sCmd & " /LicensePath:""" & oFile.Path & """"
    					bFoundLicense = True
    				End if
    			Next
    		End if
    		If not bFoundLicense then
    			sCmd = sCmd & " /SkipLicense"
    		End if
    
    
    		' Return the command line
    
    		BuildAppxCommand = sCmd
    
    
    		' Install any certs that are found in the working directory
    
    		For each oFile in oFSO.GetFolder(sWorkingDir).Files
    			If UCase(Right(oFile.Name,4)) = ".CER" then
    
    				sCertCmd = "certutil.exe -addstore root """ & oFile.Path & """"
    				oLogging.CreateEntry "Importing certificate: " & sCertCmd, LogTypeInfo
    				iRC = oShell.Run(sCertCmd, 0, true)
    				oLogging.CreateEntry "Return code from CERTUTIL = " & iRC, LogTypeInfo
    				
    			End if
    		Next
    
    	End function
    
    End class
    
    	</script>
    </job>
    
    

    Wednesday, August 19, 2015 8:16 PM
  • I am running a building in VMware right now and I confirm your code fixes this issue.  Thanks a lot!

    Wednesday, August 19, 2015 8:19 PM
  • +1 and thank you for this solution.

    Just spent a few hours this morning trying to find someone who had the same issue as me after I upgraded to update 1.

    Thank you!

    Thursday, August 20, 2015 10:15 AM
  • I also used the old version of the ztiapplications.wsf and batch files are working again.

    thanks

    This version if MDT has been riddled with issues. Come on guys, how can the prod version have more issues then the preview version?


    Tech with Alberta Education

    Tuesday, September 1, 2015 3:27 PM

  • how can the prod version have more issues then the preview version?


    Good question ;) ... Seems to me like they did 2 % of the changes from MDT 2013 to MDT 2013 Update 1 Preview, and 98 % of the changes (and new bugs) from MDT 2013 Update 1 Preview to MDT 2013 Update 1.
    Tuesday, September 1, 2015 3:32 PM
  • This worked great for fixing the batch file paths, but APPX installs are not working. Anyway to fix both the CMD paths and APPX installs? 
    Friday, November 20, 2015 2:19 PM
  • The new version of MDT 2013 Update 1 should have fixed everything.
    Friday, November 20, 2015 2:31 PM
  • I am having an issue after upgrading to MDT 2013 Update 1. I have a few "Run Command Line" tasks that will not run anymore. They basically just use batch files that are stored on the local machine itself. For Example: I have it set to start in directory called "C:\IT\act" and in the Command Line input I put I enter "winact.bat" (this is a batch file that basically pulls the manufacturer license from the BIOS and activates it). This worked fine for MDT 2013 (before update) but now is not working for me. have tried using the the old ZTIapplications.wsf that people have mentioned that didn't help. Please Help!

    Thanks,
    Monday, November 30, 2015 4:19 PM
  • Have you used the new build from my previous link? The original version has exactly the problem that you mentioned.
    Monday, November 30, 2015 5:37 PM
  • Make sure you are using MDT 2013 Update 1 with build number 8298 as it fixes this issue.  The first release under the Update 1 moniker was 8290 and it had this problem.  MS pulled the old build and replaced it with 8298.  You can check which you have one of two ways:

    1) Right click on the MSI installer if you still have it, and select Properties.  Go to the Details tab and look under comments and it should say build 6.3.8298.1000 in there.

    2) In your upgraded Deployment Share, right click on some scripts and select Edit.  Look in the headers and they should say version 6.3.8298.1000.

    Monday, November 30, 2015 5:56 PM
  • Thanks for the responses. I am still having the same issue. I have verified that I have the 6.3.8298.1000. version. I have created new task sequences as well. The Deployment works fine, it just won't run My Custom Tasks that use cmd and .bat. I just downloaded MDT 2013 Update 1 last week so I know I have the rereleased build.
    Tuesday, December 1, 2015 4:22 PM
  • Perhaps the bat or cmd file isn't running in the same folder as the underlying programs?  I am not sure what changed here in MDT 2013 Update 1, but from what you are describing, that is what I think could be happening.

    All my bat files I setup as Applications (both actual applications and scripts) and the working directory is always the default, (e.g., .\Applications\CitrixReceiver) and all supporting files are in that folder or subfolders.  The odd installer needs to get passed the full path location it is running from, and when that is the case I use %~dp0 in the bat file.

    Tuesday, December 1, 2015 4:47 PM
  • This is crazy! Microsoft needs to fix this. Any idea when the next MDT update will occur?
    Tuesday, December 1, 2015 5:26 PM
  • Microsoft,

    Please be aware that this issue is not fixed and I am not being able to deploy properly because of it. Please fix Run Command Line task in MDT 2013 Update 2.

    Thanks,

    Friday, December 4, 2015 3:16 PM
  • It seems to work for anyone else, so maybe there is a different issue in your setup. You might try to reinstall everything and then update your deployment share.
    Friday, December 4, 2015 3:23 PM
  • Ok. I tried what svhelden suggested and it is still not working. I Uninstalled MDT 2013 Update 1, rebooted the server with MDT on it, Reinstalled MDT 2013 Update 1, Updated the deployment share, I even created a new task sequence, ran it, and the task sequence will not run any of my .bat files that are stored on the local machine. Here is what I am doing and it has been working fine until the update:

    1. In the task sequence under Custom Tasks, I add a General->Run Command Line task.

    2. In the "Command Line:" box I put "winact8.bat" In the "Start In:" box I put "C:\IT\act\"

    3. In the task sequence under Custom Tasks, I add a General->Run Command Line task.

    4. In the "Command Line:" box I put "ThinInstaller.exe /CM -search A -action INSTALL -noicon -includerebootpackages 3 -noreboot -showprogress" In the "Start In:" box I put "C:\Program Files\ThinInstaller\"

    They just will not run. Please help!

    Tuesday, December 8, 2015 4:27 PM
  • Actually, why are you running batch filese from local disk at all?

    Did you try to specify the full path ("c:\it\act\winact8.bat") in the command line?

    Did you try to use CMD instead of BAT files? (BAT is actually for MS-DOS command files and CMD for Windows command files.)

    Wednesday, December 9, 2015 9:15 AM
  • Ok guys I have an update to my current situation. I was able to get my commands to (sort of) work.

    1. The winact8.bat Run Command Line task was fixed by doing the following:

    Command Line: cmd /c %systemdrive%\IT\act\winact8.bat

    Start in: %systemdrive%\IT\act

    Although it does work now, it's behavior has changed. It used to create a null file in the same directory, however now it does not do that. It does activate Windows so I am ok with that.

    2. The Thininstaller.exe Run Command Line is half fixed.

    Command Line: cmd /c "%systemdrive%\Program Files\ThinInstaller\ThinInstaller.exe" /CM -search A -action INSTALL -noicon -includerebootpackages 3 -noreboot -showprogress

    Start In: %systemdrive%\Program Files\ThinInstaller

    I says this is only half fixed because while it does run, it used to run silently which makes me think I have done something wrong with the parameters. The parameters are all correct because they were copy & pasted directly from the task sequences that used to work fine before the update. Should they include something that I have not included in the Command Line box?

    Thanks,

    Thursday, December 10, 2015 1:21 PM
  • There is no enough information here to determine what is or is not going on here.

    As of right now, you can verify that MDT has correctly called your batch script, what we have not ruled out is the batch script, we can't verify that it's running correctly. My recommendation with most batch script problems is to ensure that you have the correct logging in your batch script to ensure it's performing as expected. Did your batch script correctly call the silent switch, what is the silent switch.


    Keith Garner - Principal Consultant [owner] - http://DeploymentLive.com

    Thursday, December 10, 2015 9:59 PM
    Moderator
  • I don't understand why you need to copy a batch file to a specific place on the local PC in order to do your activation.  You put a file on the local PC with the MAK key contained in it?

    To delay MAK activation in case the deployment has issues, and to make it easy to turn off in testing scenarios, I also trigger my activation via command line.  But I don't call any batch file for this as it is just two lines.  I just have two tasks in my TS as follows, under a 'Windows Licensing' folder:

    a. cscript.exe %WINDIR%\System32\slmgr.vbs /ipk XXXXX-XXXXX-XXXXX-XXXXX-XXXXX

    b. cscript.exe %WINDIR%\System32\slmgr.vbs /ato

    I set conditions on both of the above to make sure they will only run if NOT a VM and PC is domain joined.

    I don't use ThinInstaller but do deploy ThinkVantage System Update to LENOVO systems and the run it.  This was honestly one of the hardest installs for me to script with a batch/cmd file, because it does not issue proper exit codes and I had to put some ping -n 20 127.0.0.1 > NUL in it so the installer completes before the batch/cmd file does.  Even this is not perfect so I have MDT continue on errors for that install.

    I notice you are referencing Program Files for ThinInstaller startup folder, however, if it is a 64-bit system,  it would install to Program Files (x86) wouldn't it?  I know that is where TVSU installs.

    Thursday, December 10, 2015 11:25 PM
  • I don't but the key in the batch file. The key is embedded in the BIOS of the machine and the batch file calls a script that pulls the key from the BIOS and activates the Windows device. This is a 32 bit Windows Device. The Lenovo Thinkpad Tablet 2 so thininstaller is in the Program Files directory.
    Friday, December 11, 2015 1:35 PM
  • My question Keith, is why did these changes break my Run Command Line tasks. They worked perfectly in MDT 2013 (no update). The there is no batch script with the Lenovo Thininstaller. I basically just call upon this Thininstaller.exe, set some parameters in the command line /CM -search A -action INSTALL -noicon -includerebootpackages 3 -noreboot -showprogress. Once again, this worked perfectly before the update, so this should not be the programs fault, it has to be something to do with the new MDT 2013 Update. I'm not sure what was changed in the Run Command Line task program, but it would be awesome if you could bring it back.
    Friday, December 11, 2015 1:43 PM
  • I am having the same issue as jtwillenborg pertaining to run command line and I have been running MDT for years doing the same thing without an issue. I have just recently updated to MDT 2013 Update 2 and all my run command line tasks all fail that run from a folder on the local drive.
    Monday, January 11, 2016 2:44 AM
  • I am having the same issues you are having. I am have been doing this type of thing for years using the same method you are and MDT 2013 update 1 and 2 have broken it.
    Monday, January 11, 2016 2:46 AM
  • I am having the same issues you are having. I am have been doing this type of thing for years using the same method you are and MDT 2013 update 1 and 2 have broken it.
    Are you talking about applications or a run command line step in a TS? If it is a command line step the command line must be fully qualified e.g cmd.exe /c c:\blah\blah.cmd

    Logs are very important. https://keithga.wordpress.com/2014/10/24/video-mdt-2013-log-files-basics-bdd-log-and-smsts-log/ Mention any customizations you have made.


    Monday, January 11, 2016 3:39 AM
    Moderator
  • Ryan Palencik, I'm glad someone else was having the same issue as me. It seemed I was the only one in the world with the issue. What Ty Gander suggested is what I had to do to get my commands working. It didn't used to need a fully qualified command, but now it does for some reason. Really weird. Some of my old commands still don't fully work but they do what I need them to do. For example, I use a program called Thininstaller for a few of my Lenovo tablets. It used to run silently in the background, but now will show everything that it is doing. So it still works, just not the way I want it to. A shame.
    Monday, January 11, 2016 1:10 PM
  • That's what I had to do but just wanted to point out that there is an issue with Update 1 and that you are not the only one.

    Yes its a shame.

    Monday, January 11, 2016 2:13 PM
  • You guys are confusing 2 separate issues. Run Command line task sequence steps not honoring 'start in' are unrelated to ZTIApplications. I suspect the updated task sequence engine binaries have some bug.

    Logs are very important. https://keithga.wordpress.com/2014/10/24/video-mdt-2013-log-files-basics-bdd-log-and-smsts-log/ Mention any customizations you have made.


    Monday, January 11, 2016 7:53 PM
    Moderator
  • Same thing for me, it works with that command line to install MS SCEP that call an .xml config file on MDT 2013 6.3.8443.1000:

    scepinstall.exe /s /q /NoSigsUpdateAtInitialExp /policy "%DEPLOYROOT%\Applications\INSTALL - SCEP Client 4.10.207\EPAMPolicy2.xml"


    • Edited by Mncf Monday, March 27, 2017 8:00 PM
    Monday, March 27, 2017 7:57 PM