Skip to content

Commit

Permalink
add script
Browse files Browse the repository at this point in the history
  • Loading branch information
joergmann committed Aug 13, 2024
1 parent 8bbf0b0 commit 33399ca
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 10 additions & 2 deletions .github/actions/run-as-non-admin/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ runs:
using: composite

steps:
- name: Run local PowerShell script
shell: pwsh
run: ./script.ps1
env:
OS: ${{ runner.os }}
RUN: ${{ inputs.run }}

- name: Prepare env and run cmd as non-admin user
shell: pwsh
env:
Expand All @@ -43,11 +50,12 @@ runs:
reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /f
# create temp folder
New-Item -ItemType Directory -Path "$newHomeDir\AppData\Local\Temp" -Force -ErrorAction SilentlyContinue
New-Item -ItemType Directory -Path "$newHomeDir\AppData\Local\Temp" -Force
# make temp folder writable for nonadmin user
icacls "$newHomeDir" /grant "${username}:(OI)(CI)F" /T
# using start-process to run command as non admin user requires setting env vars
$envVars = @{
HOME = $newHomeDir
HOMEPATH = "\Users\$username"
Expand All @@ -57,7 +65,7 @@ runs:
USERPROFILE = $newHomeDir
}
# call command using non admin user
# call command using non admin user credentials
$process = Start-Process -FilePath "pwsh" `
-ArgumentList "-NoLogo", "-NonInteractive", "-NoProfile", "-Command", $env:RUN `
-Credential $credential `
Expand Down
2 changes: 2 additions & 0 deletions .github/actions/run-as-non-admin/script.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
echo "hallo"
echo $RUN

0 comments on commit 33399ca

Please sign in to comment.