Inter-session SetPriority use works in PS, fails elsewhere


i'm curious possible explanation oddities discussed in scripting guys thread vbs script change process priority doesn't work on other users processes . here's nutshell description , ps oddity.

problem: the original poster running wsh script administrative privileges. script instances of msaccess.exe, set priority realtime using win32_process' setpriority() . correctly elevate administrative user's msaccess.exe priority, not instances belonging other users. when had him capture setpriority return value, 5 attempts modify user's process priority (which translates "access denied" if that's bubbled-up classic error value).

i ran test code on win7 admin elevation, , whether using wscript or cscript, 32-bit or 64-bit, got same results op did: worked fine processes in own session, , silently failed in other sessions confirmed returned error 5 , visual inspection in task manager. tried dinking bit authlevel , adding couple of privileges in wmi string didn't anywhere.

powershell oddity: here's strange thing. using setpriority elevated powershell session worked fine. in fact, test wsh script worked fine powershell session.

i'm rooted in privileges issue, original poster happy using powershell launch pad, , think i've had enough fun problem already. :d

anyone know why works in ps, not directly elevated command prompt?

whoami /priv

1) powershell - sedebugprivilege -enable

2) cmd - sedebugprivilege -disable

add priv debug:

const real_time = 256 strcomputer = "." set objwmiservice = getobject("winmgmts:" _     & "{impersonationlevel=impersonate , (debug)}!\\" & strcomputer & "\root\cimv2") set colprocesses = objwmiservice.execquery _     ("select * win32_process name = 'notepad.exe' ") each objprocess in colprocesses     objprocess.setpriority(real_time)  next

, works fine.


Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Error: 0x80073701 when trying to add Print Services Role in Windows 2012 Standard

difference between wuauclt1.exe and wuauclt.exe

Windows 2016 RDS event 1306 Connection Broker Client failed to redirect the user... Error: NULL