This project is read-only.

Possible bug in Execute-Process function

Topics: Archive - General
Feb 20, 2014 at 5:13 AM
Edited Feb 20, 2014 at 5:14 AM
So, when I ran an install with the Execute-Process function, I got an error about the working directory not existing.

Upon closer review, I noticed that the function is similar to the Execute-MSI function.

The different I noticed was in the Param "[string] $WorkingDirectory" (line 1301). I made the following changes and it worked perfectly.

Line 1301 changed from:
[string] $WorkingDirectory = (Split-Path $FilePath -Parent),
[string] $WorkingDirectory,
After line 1311 I added:
# Set the working directory of the Process
$WorkingDirectory = Split-Path $FilePath -Parent
We may have to add a "If (!$WorkingDirectory)" in there have not done extended testing.

Feb 20, 2014 at 10:14 PM

I can't reproduce this, the script should continue even if you don't set working directory.

Can you send the log file and screenshot of the error you see?

Feb 25, 2014 at 5:13 AM
See Below:

Command line I use to call the installer application (exe):
Execute-Process -FilePath "Driver\Installer\Setup_for_WinXP_Vista_7_x64.exe" -Arguments "/S /v/qn" -WindowStyle Hidden

Log file:
[24-02-2014 20:58:00] [Initialization] StarMicronics_StarPrinterDriver_5.5_EN_01 setup started.
[24-02-2014 20:58:00] [Initialization] Script [C:\Windows\ccmcache\3\AppDeployToolkit\AppDeployToolkitExtensions.ps1] dot-source invoked by [C:\Windows\ccmcache\3\AppDeployToolkit\AppDeployToolkitMain.ps1]
[24-02-2014 20:58:00] [Initialization] Script [C:\Windows\ccmcache\3\AppDeployToolkit\AppDeployToolkitMain.ps1] dot-source invoked by [C:\Windows\ccmcache\3\Deploy-Application.ps1]
[24-02-2014 20:58:00] [Initialization] StarMicronics_StarPrinterDriver_5.5_EN_01 script version is [1.0.0]
[24-02-2014 20:58:00] [Initialization] Deploy Application script version is [3.0.12]
[24-02-2014 20:58:00] [Initialization] The following non-default parameters were passed to [Deploy Application]: [-DeploymentType Install]
[24-02-2014 20:58:00] [Initialization] App Deploy Toolkit Main script version is [3.0.12]
[24-02-2014 20:58:00] [Initialization] App Deploy Toolkit Extensions version is [1.0.0]
[24-02-2014 20:58:00] [Initialization] PowerShell version is [4.0 x64]
[24-02-2014 20:58:00] [Initialization] PowerShell host is [ConsoleHost version 4.0]
[24-02-2014 20:58:00] [Initialization] OS version is [Microsoft Windows 8.1 Pro 64-bit 6.3.9600]
[24-02-2014 20:58:00] [Initialization] Hardware platform is [Virtual:VMWare]
[24-02-2014 20:58:00] [Initialization] Computer name is [WIN81-CLIENT2]
[24-02-2014 20:58:00] [Initialization] Current user is [FYLCP\WIN81-CLIENT2$]
[24-02-2014 20:58:00] [Initialization] Current Culture is [en-US] and UI language is [EN]
[24-02-2014 20:58:00] [Initialization] Deployment type is [Installation]
[24-02-2014 20:58:01] [Initialization] Installation is running in [Interactive] mode.
[24-02-2014 20:58:01] [Pre-Installation] Displaying custom installation prompt with the non-default parameters: [(Message=Make sure the Star Receipt printer is plugged in before continuing install.) (ButtonRightText=Continue) (ButtonLeftText=Cancel)]...
[24-02-2014 20:58:06] [Pre-Installation] Spinning up Progress Dialog in a separate thread with message: [Installation of Star Printer Driver (5.5) in progress...]
[24-02-2014 20:58:08] [Pre-Installation] Getting information for installed Application Name [{50F8DCCB-8011-47E4-8D91-8321794BF014}]...
[24-02-2014 20:58:09] [Installation] Updating Progress Message: [Installation of Star Printer Driver (5.5) in progress...]
[24-02-2014 20:58:09] [Installation] Executing [C:\Windows\ccmcache\3\Files\Driver\Installer\Setup_for_WinXP_Vista_7_x64.exe /S /v/qn]...
[24-02-2014 20:58:09] [Installation] Working Directory is [Driver\Installer]
[24-02-2014 20:58:10] [Installation] Execution failed: The directory name is invalid
[24-02-2014 20:58:10] [Installation] StarMicronics_StarPrinterDriver_5.5_EN_01 Installation completed with exit code [999].
[24-02-2014 20:58:10] [Installation] ----------------------------------------------------------------------------------------------------------
Feb 25, 2014 at 2:56 PM
Hey Paul,

I've just pushed an update to the Git source. The issue is because you used a subfolder without using the $dirFiles variable. If you're line looked like this:
Execute-Process -FilePath "$dirFiles\Driver\Installer\Setup_for_WinXP_Vista_7_x64.exe" -Arguments "/S /v/qn" -WindowStyle Hidden
It should work. To make this more robust, I've modified it so that $WorkingDirectory will try to resolve the full path if it's not been specified. Can you pull the latest source and check to verify if your script works now?

Thanks, Dan
Mar 1, 2014 at 4:26 AM
I pulled the latest source. It works without the $dirfiles there now as well. It does not show a working directory in the log though:
[28-02-2014 20:10:29] [Installation] Working Directory is []
Mar 3, 2014 at 2:41 PM
Hey Paul,

I've just pushed another small tweak - can you check this again? Hopefully will be solved now.

Thanks, Dan