Forum Discussion
Issues with PowerShell start and end scripts
- 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.
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.
I have had a chance to test this out and the PowerShell script is still not being executed. Running Procmon I see no PowerShell process at all, only the AIStub.exe which is finding my script file in the application root. I don't think the StartingScriptWrapper.ps1 is running either, I cant find any reference to it in Procmon. The application starts with no error it just doesn't run the script and I see no PowerShell window even though I have set it to show.
- Bogdan MitracheMay 25, 2021Iron Contributor
Hi Skinheed,
I've published an update for AI Express in the store today (it should pass MS validation in a few hours).
Download this update and try the old project. It should not require the workaround I suggested in my previous answer.
Cheers,
Bogdan
- SkinheedMay 25, 2021Copper ContributorHi Bogdan,
Thanks for the update. I did manage to get an RC version from your support team and the issue is fixed.
Thanks for your help
Craig- Jul 20, 2021FYI (In case anyone runs into this issue) A fix for the issue is now up in my fork of the PSF. I'll be scheduling a pull request into the Microsoft develop branch soon.
- May 18, 2021I'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.
- SkinheedMay 18, 2021Copper ContributorHi 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.- 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.