OpenSCManager() fails, needs elevation?
In order to install/remove a service in Vista I am calling OpenSCManager() as follows:schSCManager = OpenSCManager(NULL, NULL,SC_MANAGER_CONNECT);This worked in Vista pre-SP1, but under SP1 it returns NULL and GetLastError() returns 5. I updated Vista to SP2 and confirmed that it still returns an error.I have found a knowledge base article which describes this behavior occuring if SC_MANAGER_ALL_ACCESS is specified, but in this app I am only requesting SC_MANAGER_CONNECTI am logged in to an adminstrator account, UAC is disabled, and I am running the service install EXE from a DOS command box. Under normal circumstances, this EXE is called from within an InstallShield script.If I open the properties on my EXE and check the "run as administrator" on the Compatibility tab then the function succeeds as expected, so clearly I need to make some sort of security enhancement to my code.I know how to build a SECURITY_DESCRIPTOR and SECURITY_ATTRIBUTES structure, but I do not know how to specify such attributes for the OpenSCManager() call.
June 22nd, 2009 6:42pm

After checking the issue, it seems this is a general develop related issue. As this forum focuses on Windows Vista specific issues, this inquiry would best be posted to MSDN forum: http://social.msdn.microsoft.com/Forums/en-US/categories The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.Sean Zhu - MSFT
Free Windows Admin Tool Kit Click here and download it now
June 23rd, 2009 11:07am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics