Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: Elevated Privileges Admin Administrator
Question: Is there a way for my script to "interrogate" the currently running instance of GoldMine to find out whether it's running with elevated privileges? That way I could at least let the end-user know why it's failing; maybe avoid one more support call.
The FCL's "System.Diagnostics.Process" class comes to mind as a strait forward way to do this but it does require having a version of WinBatch with CLR support. If you do have a version with CLR support you could simple use the "Process" class to attempt to access the elevated process's "Handle" property. If your script is running as a restricted user and the targeted script is running as a full privileged admin, this will result in an COM/CLR exception error. Trap that error then you can inform the user that that they need elevated admin privileges to proceed.
If you don't have CLR support, you may be able to do something similar with WMI or perhaps there is an even easier test.
A very lightly tested rough example that may work as a starting point.
; COM version strAppName = "cmd.exe" objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2") colProcesses = objWMIService.ExecQuery( "Select * from Win32_Process Where Name = '%strAppName%'") ForEach objProcess in colProcesses strCommandLine = objProcess.CommandLine if StrLen(strCommandLine) == 0 then Pause(strName, "Is elevated but this script is not") next
Article ID: W18311
Filename: Determine if Application is Elevated.txt
File Created: 2014:03:04:09:41:54
Last Updated: 2014:03:04:09:41:54