Skip to content

Suggestion: Add an option to run PS1 as system with params #43

@obuolinis

Description

@obuolinis

Since you already have Run as system and Run with params, why not go and combine them? It would be useful for those who deploy their powershell scripts with Intune or SCCM, where scripts run in System context.

For this feature the code would be the same as for PS1Params, only the final command line would be different:

$PsExec = "$Sandbox_Root_Path\psexec.exe"
$ServiceUI = "$Sandbox_Root_Path\ServiceUI.exe"
$Script:Startup_Command = "$PsExec \\localhost -accepteula -s $ServiceUI -session:1 $PSRun_File $Full_Startup_Path $Paramaters"

Here:

  • $Sandbox_Root_Path is the folder where C:\ProgramData\Run_in_Sandbox gets mapped (C:\Run_in_Sandbox in my case)
  • psexec \\localhost -s was the only way it worked for me
  • $PSRun_File needs to drop -WindowStyle Hidden and add -NoExit
    Personally I used:
    $PSRun_File = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Sta -ExecutionPolicy Bypass -NoLogo -NoExit -File"
  • Testing was done on Windows 11

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions