Page 1 of 1

[SOLVED] PowerShell command import .xml Start menu

Published: August 6, 2022 - 8:57 PM
by adgm11
Hello, I'm trying to import an XML file to modify the start menu
The PowerShell command works fine, but not the package command

Code: Select all

def install():
run_powershell_('Import-StartLayout -LayoutPath "V:\StartLayout(calc,note,map).xml" -MountPath "C:\"')
This is giving me an error.
"PathNotFound,Microsoft.Windows.StartLayout.Commands.ImportStartLayoutCommand_x000D__x000A_ <S S="Error">_x000D__x000A_</s></Objs> \n']] "

I placed the file on a shared drive (V:), but ideally I'd like to put it directly into the package. What would the command look like in that case? And why is my command

Re: PowerShell command to import .xml from the Start Menu

Published: August 24, 2022 - 5:16 PM
by dcardon
See Python; you need to add an 'r' if there's a backslash, otherwise you need to double it.

And you shouldn't put scripts on shared drives (the LOCAL SYSTEM account will most likely not have access), and there isn't necessarily a network connection when the package is installed upon shutdown (network with VPN, 802.1x, etc.). It is highly recommended to use self-contained packages.

Sincerely,

Denis

Re: PowerShell command to import .xml from the Start Menu

Published: August 29, 2022 - 01:23
by adgm11
Okay, thank you. I created this package, but a LayoutModification.xml file sometimes already exists in the directory.
How can I add a way to force a copy and replace the existing one?

Code: Select all

def install():
    mkdirs(r'C:\Users\Default\AppData\Local\Microsoft\Windows\Shell')
    filecopyto(r'Layoutmodification.xml',r'C:\Users\Default\AppData\Local\Microsoft\Windows\Shell')

Re: PowerShell command to import .xml from the Start Menu

Published: August 30, 2022 - 10:15
by adgm11
The `filecopyto` command appears to overwrite the old file, so it's OK with this package

Re: [SOLVED] command powershell import .xml start menu

Published: August 30, 2022 - 10:18
by dcardon
Okay, thanks for the feedback, I'm marking the topic as RESOLVED.
Denis