I have a Windows service built with ATL to expose a LocalServer32 COM interface for a set of admin commands used for configuring the service, and these can be used from VBScript for example:
Set myObj = WScript.CreateObject("MySvc.Administrator")
myObj.DoSomething()
I want DoSomething to run elevated, and I would like the UAC prompt to come up automatically when this is called by the VBScript. Is this possible?
I know I can run the script in an elevated command shell, and that I can use
objShell.ShellExecute WScript.FullName, Chr(34) & WScript.ScriptFullName & Chr(34), vbNullString, "runas"
for example, to run the VBScript itself elevated, and either of those work fine -- the COM method finds itself elevated.
However, AFAIK getting an elevated Explorer window on the desktop is convoluted (it's not as simple as right-clicking Start/Accessories/Windows Explorer/Run as Administrator, which doesn't actually elevate, or at least, the COM method doesn't find itself elevated.) I want a user in the local admin group to be able to drag-and-drop files and folders onto the script, and then have the script call the admin COM interface with those pathnames as arguments, and the COM method to be elevated. (And I am hoping for something simpler than monkeying around with the args and using ShellExecute "runas".)
I've tried setting UAC Execution Level to requireAdministrator in the service EXE's manifest, and setting Elevated/Enabled = 1 and LocalizedString in the registry for the MySvc.Administrator class, and these don't do the trick.
EDIT:
When I wrote that the COM method finds itself elevated, what I really meant was the security token of the incoming COM request shows that it came from an admin. I'm checking this token to see if the request is allowed. The Windows service process where the COM object lives is probably running as LocalSystem.