Forum Discussion
Skinheed
May 10, 2021Copper Contributor
Issues with PowerShell start and end scripts
I think there is a problem with the PSFLauncher.exe. It appears to be using the working directory of the application shortcut to find the StartingScriptWrapper.ps1. This is breaking PowerShell suppor...
- May 13, 2021
Hi Skinheed
I am Bogdan, from the Advanced Installer team. Thanks for reporting this issue. Just wanted to let you know that until a fix is included by MSFT in the official PSF repo we will include a custom fix directly inside our next version.
Until then, you have a workaround in Advanced Installer:
Advanced Installer allows you to update the working directory and application parameters (that you would usually specify in the "Application Details" view) directly from the PS1 script.
For your scenario, please follow these steps.- Go to "Application Details > Working directory" and make sure this field (Working Directory) is empty.
- Use a PS script that updates the Working directory, attached is a sample.
This sample PS script (from the attached zip) updates the Working directory to the first argument it receives (its value should be relative to APPDIR).
IMPORTANT, when using the above script:
- change the script to include your own ApplicationID.
- set the desired working directory path (relative to APPDIR) in the 'scriptArguments' field.
The Working Dir argument can also be changed directly from inside your PS1 script, if you wish to hardcode it inside the script. - set the 'waitForScriptToFinish' field to 'true'
Let me know if this helps.
May 18, 2021
I'm not 100% sure this isn't a config issue. Can you show the Json file? I would also recommend that you use SysInternals DebugView for debugging this type of issue. The PsfLauncher code that handles the scripts outputs the information you need to see about script launching to the debug console.
Skinheed
May 18, 2021Copper Contributor
Hi Tim,
Here is config.json from the Advanced installer package. I did manage to get it working with the PSFTooling after changing the config.json to use a relative path.
{
"processes": [
{
"executable": ".*",
"fixups": [
{
"dll": "FileRedirectionFixup",
"config": {
"redirectedPaths": {
"packageRelative": [
{
"base": "program",
"patterns": [
"__pycache__"
]
},
{
"base": "program\\python-core-3.5.7\\lib",
"patterns": [
".*"
]
},
{
"base": "share\\extensions\\dict-en\\pythonpath",
"patterns": [
"__pycache__"
]
},
{
"base": "share\\uno_packages",
"patterns": [
".*"
]
}
]
}
}
},
{
"dll": "AiShims",
"config": {
"dllDirectory": [
""
]
}
},
{
"dll": "CreateProcShim",
"config": {
"redirectedPaths": {}
}
},
{
"dll": "TraceFixup",
"config": {}
}
]
}
],
"applications": [
{
"id": "LibreOffice",
"startScript": {
"scriptArguments": "-Start -AppIDs LibreOffice,LibreOffice1,LibreOfficeClalc,LibreOfficeDraw,LibreOfficeImpress,LibreOffice,LibreOfficeMath,LibreOfficeWriter -WDSubDir Program",
"showWindow": true,
"waitForScriptToFinish": true,
"scriptPath": "Roam.ps1",
"timeout": 3000
},
"endScript": {
"showWindow": true,
"waitForScriptToFinish": true,
"scriptPath": "Roam.ps1",
"timeout": 3000
}
},
{
"id": "LibreOfficeWriter",
"startScript": {
"scriptArguments": "-Start -AppIDs LibreOffice,LibreOffice1,LibreOfficeClalc,LibreOfficeDraw,LibreOfficeImpress,LibreOffice,LibreOfficeMath,LibreOfficeWriter -WDSubDir Program",
"showWindow": true,
"waitForScriptToFinish": true,
"scriptPath": "Roam.ps1",
"timeout": 3000
},
"endScript": {
"showWindow": true,
"waitForScriptToFinish": true,
"scriptPath": "Roam.ps1",
"timeout": 3000
}
},
{
"id": "LibreOfficeCalc",
"startScript": {
"scriptArguments": "-Start -AppIDs LibreOffice,LibreOffice1,LibreOfficeClalc,LibreOfficeDraw,LibreOfficeImpress,LibreOffice,LibreOfficeMath,LibreOfficeWriter -WDSubDir Program",
"showWindow": true,
"waitForScriptToFinish": true,
"scriptPath": "Roam.ps1",
"timeout": 3000
},
"endScript": {
"showWindow": true,
"waitForScriptToFinish": true,
"scriptPath": "Roam.ps1",
"timeout": 3000
}
},
{
"id": "LibreOfficeDraw",
"startScript": {
"scriptArguments": "-Start -AppIDs LibreOffice,LibreOffice1,LibreOfficeClalc,LibreOfficeDraw,LibreOfficeImpress,LibreOffice,LibreOfficeMath,LibreOfficeWriter -WDSubDir Program",
"showWindow": true,
"waitForScriptToFinish": true,
"scriptPath": "Roam.ps1",
"timeout": 3000
},
"endScript": {
"showWindow": true,
"waitForScriptToFinish": true,
"scriptPath": "Roam.ps1",
"timeout": 3000
}
},
{
"id": "LibreOfficeMath",
"startScript": {
"scriptArguments": "-Start -AppIDs LibreOffice,LibreOffice1,LibreOfficeClalc,LibreOfficeDraw,LibreOfficeImpress,LibreOffice,LibreOfficeMath,LibreOfficeWriter -WDSubDir Program",
"showWindow": true,
"waitForScriptToFinish": true,
"scriptPath": "Roam.ps1",
"timeout": 3000
},
"endScript": {
"showWindow": true,
"waitForScriptToFinish": true,
"scriptPath": "Roam.ps1",
"timeout": 3000
}
},
{
"id": "LibreOfficeImpress",
"startScript": {
"scriptArguments": "-Start -AppIDs LibreOffice,LibreOffice1,LibreOfficeClalc,LibreOfficeDraw,LibreOfficeImpress,LibreOffice,LibreOfficeMath,LibreOfficeWriter -WDSubDir Program",
"showWindow": true,
"waitForScriptToFinish": true,
"scriptPath": "Roam.ps1",
"timeout": 3000
},
"endScript": {
"showWindow": true,
"waitForScriptToFinish": true,
"scriptPath": "Roam.ps1",
"timeout": 3000
}
},
{
"id": "LibreOffice1",
"startScript": {
"scriptArguments": "-Start -AppIDs LibreOffice,LibreOffice1,LibreOfficeClalc,LibreOfficeDraw,LibreOfficeImpress,LibreOffice,LibreOfficeMath,LibreOfficeWriter -WDSubDir Program",
"showWindow": true,
"waitForScriptToFinish": true,
"scriptPath": "Roam.ps1",
"timeout": 3000
},
"endScript": {
"showWindow": true,
"waitForScriptToFinish": true,
"scriptPath": "Roam.ps1",
"timeout": 3000
}
}
]
}
Thanks for the DebugView tip I will try that out now.
Here is config.json from the Advanced installer package. I did manage to get it working with the PSFTooling after changing the config.json to use a relative path.
{
"processes": [
{
"executable": ".*",
"fixups": [
{
"dll": "FileRedirectionFixup",
"config": {
"redirectedPaths": {
"packageRelative": [
{
"base": "program",
"patterns": [
"__pycache__"
]
},
{
"base": "program\\python-core-3.5.7\\lib",
"patterns": [
".*"
]
},
{
"base": "share\\extensions\\dict-en\\pythonpath",
"patterns": [
"__pycache__"
]
},
{
"base": "share\\uno_packages",
"patterns": [
".*"
]
}
]
}
}
},
{
"dll": "AiShims",
"config": {
"dllDirectory": [
""
]
}
},
{
"dll": "CreateProcShim",
"config": {
"redirectedPaths": {}
}
},
{
"dll": "TraceFixup",
"config": {}
}
]
}
],
"applications": [
{
"id": "LibreOffice",
"startScript": {
"scriptArguments": "-Start -AppIDs LibreOffice,LibreOffice1,LibreOfficeClalc,LibreOfficeDraw,LibreOfficeImpress,LibreOffice,LibreOfficeMath,LibreOfficeWriter -WDSubDir Program",
"showWindow": true,
"waitForScriptToFinish": true,
"scriptPath": "Roam.ps1",
"timeout": 3000
},
"endScript": {
"showWindow": true,
"waitForScriptToFinish": true,
"scriptPath": "Roam.ps1",
"timeout": 3000
}
},
{
"id": "LibreOfficeWriter",
"startScript": {
"scriptArguments": "-Start -AppIDs LibreOffice,LibreOffice1,LibreOfficeClalc,LibreOfficeDraw,LibreOfficeImpress,LibreOffice,LibreOfficeMath,LibreOfficeWriter -WDSubDir Program",
"showWindow": true,
"waitForScriptToFinish": true,
"scriptPath": "Roam.ps1",
"timeout": 3000
},
"endScript": {
"showWindow": true,
"waitForScriptToFinish": true,
"scriptPath": "Roam.ps1",
"timeout": 3000
}
},
{
"id": "LibreOfficeCalc",
"startScript": {
"scriptArguments": "-Start -AppIDs LibreOffice,LibreOffice1,LibreOfficeClalc,LibreOfficeDraw,LibreOfficeImpress,LibreOffice,LibreOfficeMath,LibreOfficeWriter -WDSubDir Program",
"showWindow": true,
"waitForScriptToFinish": true,
"scriptPath": "Roam.ps1",
"timeout": 3000
},
"endScript": {
"showWindow": true,
"waitForScriptToFinish": true,
"scriptPath": "Roam.ps1",
"timeout": 3000
}
},
{
"id": "LibreOfficeDraw",
"startScript": {
"scriptArguments": "-Start -AppIDs LibreOffice,LibreOffice1,LibreOfficeClalc,LibreOfficeDraw,LibreOfficeImpress,LibreOffice,LibreOfficeMath,LibreOfficeWriter -WDSubDir Program",
"showWindow": true,
"waitForScriptToFinish": true,
"scriptPath": "Roam.ps1",
"timeout": 3000
},
"endScript": {
"showWindow": true,
"waitForScriptToFinish": true,
"scriptPath": "Roam.ps1",
"timeout": 3000
}
},
{
"id": "LibreOfficeMath",
"startScript": {
"scriptArguments": "-Start -AppIDs LibreOffice,LibreOffice1,LibreOfficeClalc,LibreOfficeDraw,LibreOfficeImpress,LibreOffice,LibreOfficeMath,LibreOfficeWriter -WDSubDir Program",
"showWindow": true,
"waitForScriptToFinish": true,
"scriptPath": "Roam.ps1",
"timeout": 3000
},
"endScript": {
"showWindow": true,
"waitForScriptToFinish": true,
"scriptPath": "Roam.ps1",
"timeout": 3000
}
},
{
"id": "LibreOfficeImpress",
"startScript": {
"scriptArguments": "-Start -AppIDs LibreOffice,LibreOffice1,LibreOfficeClalc,LibreOfficeDraw,LibreOfficeImpress,LibreOffice,LibreOfficeMath,LibreOfficeWriter -WDSubDir Program",
"showWindow": true,
"waitForScriptToFinish": true,
"scriptPath": "Roam.ps1",
"timeout": 3000
},
"endScript": {
"showWindow": true,
"waitForScriptToFinish": true,
"scriptPath": "Roam.ps1",
"timeout": 3000
}
},
{
"id": "LibreOffice1",
"startScript": {
"scriptArguments": "-Start -AppIDs LibreOffice,LibreOffice1,LibreOfficeClalc,LibreOfficeDraw,LibreOfficeImpress,LibreOffice,LibreOfficeMath,LibreOfficeWriter -WDSubDir Program",
"showWindow": true,
"waitForScriptToFinish": true,
"scriptPath": "Roam.ps1",
"timeout": 3000
},
"endScript": {
"showWindow": true,
"waitForScriptToFinish": true,
"scriptPath": "Roam.ps1",
"timeout": 3000
}
}
]
}
Thanks for the DebugView tip I will try that out now.
- SkinheedMay 18, 2021Copper ContributorHi Tim,
I get the following in DebugView:
[4132] StartingScript commandString=Powershell.exe -file StartingScriptWrapper.ps1 "Powershell.exe -file '.\Roam.ps1' -Start -AppIDs LibreOffice,LibreOffice1,LibreOfficeClalc,LibreOfficeDraw,LibreOfficeImpress,LibreOffice,LibreOfficeMath,LibreOfficeWriter -WDSubDir Program"
[4132] StartingScript currentDirectory=C:\Program Files\WindowsApps\LibreOffice.org.LibreOffice_6.2.8.0_x64__6pj9mnfdq70vt
[4132] StartingScript waitForScriptToFinish=true
It looks correct but still no PowerShell process appearing in Procmon while capturing the debug output. I would use my PSFTooling package that I have fixed but I can't get the MSPT to accept the package manifest after adding the fonts captured by PSFTooling.- May 18, 2021PsfTooling provides you text to copy into the manifest, but must do so before the manifest exists so we had to guess how much to provide. It provides the minimal syntax that works for many packages, but depending on what else is in the package there may need to be more editing of the manifest to make the schema happy. For example, your package application may or may not have an <Application><Extensions> element to place the uap4:Extension into. But most of the time people have trouble because the app didn't reference the schema needed (UAP4) at the top of the file.
But even with what you have in AdvancedInstaller, if you just add a extra copy of the StartingScriptWrapper.ps1 into the working directory for the application you'll be fine. This is, essentially what PsfTooling is doing.