我需要在多台计算机上远程安装windows服务,所以我使用了winapi的CreateService()和其他服务功能。我知道我需要访问的机器的管理员密码和用户名。为了访问远程计算机模仿我调用进程的LogonUser与帮助是这样的:远程安装windows服务
//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
所以,我访问机器的域名,但某些计算机是出域。在超出域的机器上,此代码不起作用。有没有办法在域外访问机器上的服务管理器?