【发布时间】:2010-09-08 21:59:23
【问题描述】:
我需要在多台计算机上远程安装windows服务,所以我使用了winapi中的CreateService()和其他服务函数。我知道我需要访问的机器的管理员密码和用户名。为了访问远程机器,我在 LogonUser 的帮助下模拟调用进程,如下所示:
//all variables are initialized correctly
int status = 0;
status = LogonUser(lpwUsername,
lpwDomain,
lpwPassword,
LOGON32_LOGON_NEW_CREDENTIALS,
LOGON32_PROVIDER_DEFAULT,
&hToken);
if (status == 0)
{
//here comes a error
}
status = ImpersonateLoggedOnUser(hToken);
if (status == 0)
{
//once again a error
}
//ok, now we are impersonated, do all service work there
所以,我可以访问域中的计算机,但有些计算机不在域中。在域外的机器上,此代码不起作用。有没有办法在域外访问机器上的服务管理器?
【问题讨论】:
标签: c++ windows windows-services