Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Execute-ProcessAsUser still not working properly in new v3.6.4 release #38

Closed
appPackager opened this issue May 21, 2015 · 3 comments
Closed

Comments

@appPackager
Copy link

A double-quote is missing from the end of the PSAppDeployToolkit-ExecuteAsUser.vbs which results in error: "Unterminated string constant". The fix is to add a double-quote to the end of the vbscript (i.e. ; Exit $LastExitCode }"). My PSAppDeployToolkit code is as follows:

Execute-ProcessAsUser -Path "$PSHOME\powershell.exe" -Parameters "-Command & { & `"C:\Temp\Script.ps1`"; Exit `$LastExitCode }" -Wait

The resulting PSAppDeployToolkit-ExecuteAsUser.vbs is as follows:

strCommand = chr(34) & "C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe" & chr(34) & " -Command & { & " & chr(34) & "C:\Temp\Script.ps1" & chr(34) & "; Exit $LastExitCode }
set oWShell = CreateObject("WScript.Shell")
intReturn = oWShell.Run(strCommand, 0, true)
WScript.Quit intReturn
@appPackager appPackager changed the title Execute-ProcessAsUser still not working properly in newer v3.6.4 release Execute-ProcessAsUser still not working properly in new v3.6.4 release May 21, 2015
@mmashwani
Copy link
Contributor

Well now I'm confused. I removed a double quote because of this other ticket last time around:
#22

However, you're saying that it needs to be put back. Can you confirm?

Did you change your script to the below?

[string]$executeProcessAsUserParametersVBS = 'chr(34) & ' + "`"$($Path)`"" + ' & chr(34) & ' + '" ' + ($Parameters -replace '"', "`" & chr(34) & `"" -replace ' & chr\(34\) & "$','') + '"'

@appPackager
Copy link
Author

I think the root cause of the issue reported in #22 was the help example was wrong as reported in #28. The fix that was applied as a result of #22 was unnecessary.

I replaced the line within Execute-ProcessAsUser as you suggested and Execute-ProcessAsUser now generates a good .vbs resulting in a successful execution.

@mmashwani
Copy link
Contributor

OK, makes sense. I've reverted the change made in the last release so since the example was already fixed, both issues should now be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants