Today, my colleague wrote a program to get the Window service with Sigar, and found that several services could not get out anyway.
I looked at the code and got it using OpenService, so I wrote a Demo using VC, but I still couldn’t get it.
But the error code is this 5, check MSDN is access problem.
Take a look at the permission bits obtained by Sigar, compare MSDN, Sigar USES ALL_ACCESS, but in Windows Scardspace, how to report an error.
http://www.cpp-home.com/forum/viewtopic.php?f=1& t=16325
http://social.msdn.microsoft.com/forums/en-US/vclanguage/thread/8c28faac-9056-4e72-9839-1f475079adc4
http://msdn.microsoft.com/en-us/library/windows/desktop/bb540474(v=vs.85).aspx
http://bbs.pediy.com/showthread.php?t=115649
After searching a few articles, the question was not completely solved, but fortunately we just want to get the status, not start and stop service, so we changed the source code, add a read permission bit (see MSDN), so
Even the bypass solves the problem.
Read More:
- SC OpenService failed 5: Access denied
- ER_ACCESS_DENIED_ERROR: Access denied for user ‘root‘@‘localhost‘ (using password: NO)
- 【docker】 denied: requested access to the resource is denied
- HTTP Basic: Access denied
- MySQL Access denied
- Git report HTTP Basic: Access denied
- Idea access denied for user ‘xxx’ @ ‘localhost’ solution
- Error in Git operation: http basic: access denied solution
- Use sc command under CMD, report openservice failed 1060 error
- HTTP Error 401.1 – Unauthorized:Access is denied due to invalid credentials
- git remote: HTTP Basic: Access denied error resolution
- com.qcloud.cos.exception.CosServiceException Access Denied
- ERROR 1045 (28000): Access denied for user’ODBC’@localhost (using password: NO)209150;’211503;’
- Error 1045 (28000): solution to access denied for user ‘root’ @’localhost ‘(using password: no)
- MySQL connection error access denied for user ‘root’ @ ‘localhost‘
- Error 1045 (28000): access denied for user ‘root’ @’localhost ‘(using password: no)
- Solve MySQL error 1698 (28000): access denied for user ‘root’ @’localhost ‘
- Login failed with an access denied error.
- Win32 Disk Imager Error 5: Access is Denied solution
- NPM ERR! Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules’