I've been wrestling with a small issue for a while, tinkering and searching for hints hasn't revealed the answer. Maybe someone can educate me directly?

I use the following function often to check for the presence of several different processes (and versions).
Code: Select all
CheckProcess()
{
local Result
for process in ComObjGet("winmgmts:").ExecQuery("Select * from Win32_Process WHERE Name LIKE 'SAMPLI%' AND ExecutablePath LIKE '%Magix%' OR Name LIKE 'SEQUOI%' AND ExecutablePath LIKE '%Magix%'")
{
Result := true
return, %Result%
}
}
In Win 10 x64 (UAC Off), this function will only return true for processes running standard (limited) elevation. This is not the case in Win 7 Pro (UAC Off). In Win 10, to return true for elevated process running as admin, I have to start the script elevated with this handy snippet I found below.
Code: Select all
full_command_line := DllCall("GetCommandLine", "str")
if not (A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)"))
{
try
{
if A_IsCompiled
Run *RunAs "%A_ScriptFullPath%" /restart
else
Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
}
ExitApp
}
But I don't really like to run the script as admin, especially for my users. Is there any other solution to detect elevated process with WMI from a standard elevation script? I've also tried using the following but it didn't work, and I don't really understand what the impersonation business means.
Code: Select all
strComputer := "."
objWMIService := ComObjGet("winmgmts:{impersonationLevel=impersonate}!\\" . strComputer . "\root\cimv2")
Any assistance greatly appreciated, thanks!