久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在沒有管理員權限的情況下從應用程序啟動 Win

Start Windows Service From Application without Admin right(c++)(在沒有管理員權限的情況下從應用程序啟動 Windows 服務 (c++))
本文介紹了在沒有管理員權限的情況下從應用程序啟動 Windows 服務 (c++)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我編寫了一個 Windows 服務(并且運行良好).現在我有一個單獨的應用程序,我想從中啟動此服務,但如果沒有管理員權限,這似乎是不可能的.

I wrote a windows service (and it runs fine). Now i have a separate app where I want to start this service from, but it seems this is not possible without administrator rights.

用戶可以啟動/停止服務(例如從托盤或應用程序)的正確解決方案是怎樣的

How would a proper solution look like that a user can start/stop the service (e.g. from a tray or application)

恕我直言,應用程序必須始終以管理員權限啟動是不好的.

IMHO its bad that the application must always be started with administrator rights.

推薦答案

您只需要更改服務對象的權限,最好在安裝的同時更改.

You just need to change the permissions on the service object, preferably at the same time you install it.

wchar_t sddl[] = L"D:"
  L"(A;;CCLCSWRPWPDTLOCRRC;;;SY)"           // default permissions for local system
  L"(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)"   // default permissions for administrators
  L"(A;;CCLCSWLOCRRC;;;AU)"                 // default permissions for authenticated users
  L"(A;;CCLCSWRPWPDTLOCRRC;;;PU)"           // default permissions for power users
  L"(A;;RP;;;IU)"                           // added permission: start service for interactive users
  ;

PSECURITY_DESCRIPTOR sd;

if (!ConvertStringSecurityDescriptorToSecurityDescriptor(sddl, SDDL_REVISION_1, &sd, NULL))
{
   fail();
}

if (!SetServiceObjectSecurity(service, DACL_SECURITY_INFORMATION, sd))
{
   fail();
}

我在這里假設您已經打開了服務句柄.您需要 WRITE_DAC 權限.

I'm assuming here you've already opened the service handle. You need WRITE_DAC permission.

如果您還希望非管理員用戶能夠停止服務,請添加 WP 權限,即

If you also want non-admin users to be able to stop the service, add the WP right, i.e.,

L"(A;;RPWP;;;IU)"                           
  // added permissions: start service, stop service for interactive users

服務權限的 SDDL 代碼可以在 Wayne Martin 的博客條目中找到,非管理員的服務控制管理器安全.

SDDL codes for service rights can be found in Wayne Martin's blog entry, Service Control Manager Security for non-admins.

這篇關于在沒有管理員權限的情況下從應用程序啟動 Windows 服務 (c++)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

What is the fastest way to transpose a matrix in C++?(在 C++ 中轉置矩陣的最快方法是什么?)
Sorting zipped (locked) containers in C++ using boost or the STL(使用 boost 或 STL 在 C++ 中對壓縮(鎖定)容器進行排序)
Rotating a point about another point (2D)(圍繞另一個點旋轉一個點 (2D))
Image Processing: Algorithm Improvement for #39;Coca-Cola Can#39; Recognition(圖像處理:Coca-Cola Can 識別的算法改進)
How do I construct an ISO 8601 datetime in C++?(如何在 C++ 中構建 ISO 8601 日期時間?)
Sort list using STL sort function(使用 STL 排序功能對列表進行排序)
主站蜘蛛池模板: 五月天婷婷网站| 成 人 黄 色 片 在线播放 | √8天堂资源地址中文在线 av网址在线免费观看 | 免费毛片网 | 五月婷婷开心 | 国产永久视频 | 中国特级毛片 | 99一区二区| 日本三级中文字幕 | 日韩欧美一区二区三区久久婷婷 | 一级片aa | 三级黄色片网站 | 日韩精品视频免费播放 | 在线色 | 国产精品毛片久久久久久久 | 国产成人+综合亚洲+天堂 | 日本中文在线观看 | 九九影视理伦片 | 91看片在线观看 | 国产一级在线 | 欧美激情一区二区三区 | 日本久久久久 | 香蕉视频导航 | 亚洲天堂偷拍 | 美女国产精品 | 色啪视频 | 欧美a级大片 | 中文在线字幕免费观 | 亚洲美女爱爱 | 国产精品999| 国产资源在线播放 | 亚洲黄色网址 | 久久成人在线 | 日韩国产一区二区 | 国产性色av | 国产乱码精品一区二区三 | 男女交配网站 | 日韩久久久 | 一级免费黄色片 | 国产日韩欧美综合 | 涩涩久久 |