I have some tool that doesn't work if it runs from elevated session.
I am running elevated session (in the context of administrative intall so this is mandatory) so that is not changable.
Other then creating scheduled task and executing it, is there anything else that is faster or friendlier?
=== EDIT ===
This is the command that needs unelevated run: vboxmanage list runningvms
I tried
runas /trustlevel:0x20000 "powershell.exe -noprofile -noexit -command iex 'vboxmanage list runningvms'"
and it returns nothing
This code works:
function Run-NonElevated( [string] $cmd ) {
$task_name = "Run-NonElevated-$(New-Guid)"
schtasks /Create /RU $Env:USERNAME /TN $task_name /SC ONCE /ST 00:00 /F /TR $cmd
schtasks /run /tn $task_name
schtasks /delete /F /tn $task_name
}
Run-NonElevated "powershell -NoProfile -Command 'vboxmanage list runningvms | Out-File $Env:TEMP\re.out'"
cat C:\Users\majkinetor\AppData\Local\Temp\re.out
"test machine" {31409fff-c195-4a83-ab12-96bba020e051}
Using this function at the end:
Would still like to know solution without task scheduler.