I've been stuck on this for a few hours until I've finally managed to do it. There are already links which pointed me the right direction:
- Is it possible for the executable to ask for Administrator rights? (Windows 7)
- CreateProcess error=740, The requested operation requires elevation
But I've thought that simple overview of the problem could help someone :).
Real problem: (from Wikipedia: http://en.wikipedia.org/wiki/User_Account_Control)
(BTW, ERROR_ELEVATION_REQUIRED error == 740)
Solution: (same site)
ShellExecute(hwnd, "runas", "C:\\Windows\\Notepad.exe", 0, 0, SW_SHOWNORMAL);
This may be also helpful: (source: http://mark.koli.ch/2009/12/uac-prompt-from-java-createprocess-error740-the-requested-operation-requires-elevation.html)
Finally, this is how I've done it:
And just for completness's sake - MSDN links to ShellExecute and CreateProcess:
http://msdn.microsoft.com/en-us/library/bb762153%28v=vs.85%29.aspx
http://msdn.microsoft.com/en-us/library/ms682425%28VS.85%29.aspx