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

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

Open
obuolinis opened this issue Jul 2, 2023 · 1 comment
Open

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

obuolinis opened this issue Jul 2, 2023 · 1 comment

Comments

@obuolinis
Copy link

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
@Joly0
Copy link
Contributor

Joly0 commented Jul 2, 2023

You are right, that might be useful. I will look into it. Thank you

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

No branches or pull requests

2 participants