I'm running PowerShell scripts at logon by:
Run: gpedit.msc ->
Local Group Policy Editor ->
User Configuration ->
Windows Settings ->
Scripts (Logon/Logoff) ->
Logon ->
PowerShell Scripts ->
Add ->
Browse
In the script, I'm executing programs using Start-Process:
if (!(Get-Process "outlook" -ea SilentlyContinue)) {
Start-Process "outlook.exe"
} else { Log("Outlook already running.") }
But it seems to start these processes as administrator, which I don't want to happen.
How can I avoid this?
Are you wanting to start the program as the currently logged in user? If you're wanting to use just another account in general, the Start-Process command can take in credentials. See here . If you're just trying to have programs start when the user logs on, you'd be better off adding them to the startup programs. This can be done by either adding it to HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run
or C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\Startup
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.