Working directory changing

I am probably just being dense but has something changed between 3.1.x and 3.6.4 in how the working directory is determined?

If I understand the documentation the working directory should be set to the Files subdirectory. I am executing the toolkit from an SCCM application and placing my files, in this case a VBS script called “SetConfig.vbs”, in the Files subdir. I am adding the whole deployment directory structure as content for an SCCM application. Here is the installation portion of the script:

<pre class="lang:ps decode:true " >##===============================================
##
INSTALLATION
##*===============================================
[string]$installPhase = ‘Installation’

	## Handle Zero-Config MSI Installations
	If ($useDefaultMsi) { Execute-MSI -Action 'Install' -Path $defaultMsiFile }
	
	## &lt;Perform Installation tasks here&gt;
	Execute-Process -FilePath "c:\windows\system32\cscript.exe" -Parameters "SetConfig.vbs SecurityChip Active"</pre> 

But when the script executes on the client the working directory is getting changed to “C:\Windows\system32” and fails because (I presume) it cannot locate the SetConfig.vbs script because the working dir has changed.

<pre class="lang:ps decode:true " >[Pre-Installation] :: Displaying custom installation prompt with the non-default parameters: [-ButtonMiddleText “OK” -Icon “Information” -Message “Hello, Sandvine IT is deploying an update your laptop. This update will require a reboot of your computer to complete. Please save any unsaved work and click on OK to continue with the update. You will also have the option to defer the installation to a later time.” -Title “Sandvine Update Installation”]. 1/1/1601 12:00:00 AM 0 (0x0000)
[Pre-Installation] :: Get deferral history… 1/1/1601 12:00:00 AM 0 (0x0000)
[Pre-Installation] :: Return fully qualified registry key path [Registry::HKEY_LOCAL_MACHINE\SOFTWARE\PSAppDeployToolkit\DeferHistory\ActivateTPMSecurity-Lenovo_EN_01]. 1/1/1601 12:00:00 AM 0 (0x0000)
[Pre-Installation] :: Registry key [Registry::HKEY_LOCAL_MACHINE\SOFTWARE\PSAppDeployToolkit\DeferHistory\ActivateTPMSecurity-Lenovo_EN_01] does not exist. 1/1/1601 12:00:00 AM 0 (0x0000)
[Pre-Installation] :: User has [2] deferrals remaining. 1/1/1601 12:00:00 AM 0 (0x0000)
[Pre-Installation] :: User has the option to defer. 1/1/1601 12:00:00 AM 0 (0x0000)
[Pre-Installation] :: User selected to continue… 1/1/1601 12:00:00 AM 0 (0x0000)
[Pre-Installation] :: Display balloon tip notification with message [Installation started.]. 1/1/1601 12:00:00 AM 0 (0x0000)
[Pre-Installation] :: Spin up progress dialog in a separate thread with message: [Installation in progress. Please wait…]. 1/1/1601 12:00:00 AM 0 (0x0000)
[Installation] :: [cscript.exe] successfully resolved to fully qualified path [C:\windows\system32\cscript.exe]. 1/1/1601 12:00:00 AM 0 (0x0000)
[Installation] :: Working Directory is [C:\windows\system32]. 1/1/1601 12:00:00 AM 0 (0x0000)
[Installation] :: Executing [C:\windows\system32\cscript.exe SetConfig.vbs SecurityChip Active]… 1/1/1601 12:00:00 AM 0 (0x0000)
[Installation] :: Execution failed with exit code [1]. 1/1/1601 12:00:00 AM 0 (0x0000)
[Installation] :: Close the installation progress dialog. 1/1/1601 12:00:00 AM 0 (0x0000)

This worked fine under 3.1.x but since upgrading to 3.6.4 I’m seeing this new behavior. What am I missing?

Great tool! Thanks!

For some reason the crayon option isn’t keeping the script formatting.

Let’s try this again using the code block button.

Script:

#*===============================================
##* INSTALLATION
##*===============================================
[string]$installPhase = ‘Installation’

## Handle Zero-Config MSI Installations
If ($useDefaultMsi) { Execute-MSI -Action ‘Install’ -Path $defaultMsiFile }

## <Perform Installation tasks here>
Execute-Process -FilePath “c:\windows\system32\cscript.exe” -Parameters “SetConfig.vbs SecurityChip Active”

Error:

[Pre-Installation] :: Displaying custom installation prompt with the non-default parameters: [-ButtonMiddleText “OK” -Icon “Information” -Message “Hello, Sandvine IT is deploying an update your laptop. This update will require a reboot of your computer to complete. Please save any unsaved work and click on OK to continue with the update. You will also have the option to defer the installation to a later time.” -Title “Sandvine Update Installation”].	1/1/1601 12:00:00 AM	0 (0x0000)
[Pre-Installation] :: Get deferral history…	1/1/1601 12:00:00 AM	0 (0x0000)
[Pre-Installation] :: Return fully qualified registry key path [Registry::HKEY_LOCAL_MACHINE\SOFTWARE\PSAppDeployToolkit\DeferHistory\ActivateTPMSecurity-Lenovo_EN_01].	1/1/1601 12:00:00 AM	0 (0x0000)
[Pre-Installation] :: Registry key [Registry::HKEY_LOCAL_MACHINE\SOFTWARE\PSAppDeployToolkit\DeferHistory\ActivateTPMSecurity-Lenovo_EN_01] does not exist.	1/1/1601 12:00:00 AM	0 (0x0000)
[Pre-Installation] :: User has [2] deferrals remaining.	1/1/1601 12:00:00 AM	0 (0x0000)
[Pre-Installation] :: User has the option to defer.	1/1/1601 12:00:00 AM	0 (0x0000)
[Pre-Installation] :: User selected to continue…	1/1/1601 12:00:00 AM	0 (0x0000)
[Pre-Installation] :: Display balloon tip notification with message [Installation started.].	1/1/1601 12:00:00 AM	0 (0x0000)
[Pre-Installation] :: Spin up progress dialog in a separate thread with message: [Installation in progress. Please wait…].	1/1/1601 12:00:00 AM	0 (0x0000)
[Installation] :: [cscript.exe] successfully resolved to fully qualified path [C:\windows\system32\cscript.exe]. 1/1/1601 12:00:00 AM	0 (0x0000)
[Installation] :: Working Directory is [C:\windows\system32].	1/1/1601 12:00:00 AM	0 (0x0000)
[Installation] :: Executing [C:\windows\system32\cscript.exe SetConfig.vbs SecurityChip Active]…	1/1/1601 12:00:00 AM	0 (0x0000)
[Installation] :: Execution failed with exit code [1].	1/1/1601 12:00:00 AM	0 (0x0000)
[Installation] :: Close the installation progress dialog.	1/1/1601 12:00:00 AM	0 (0x0000)

Taking a closer look at the documentation it may be that since I’m specifying the -Filepath parameter to cscript.exe that is why the working directory is being changed. But this never happened with the previous version of the toolkit I was using. Even if I just specify Execute-Process -FilePath cscript.exe -Parameters “SetConfig.vbs SecurityChip Active” it still ends up changing the working directory to c:\windows\system32 because that is where cscript.exe lives.

Looks like I’ve solved the issue by adding the $dirFiles variable into the path for the parameters:

Execute-Process -FilePath cscript.exe -Parameters “$dirFiles\SetConfig.vbs SecurityChip Active”

1 Like