Pass Credentials to WMI Call in VBScript

谁说胖子不能爱 提交于 2019-12-01 04:42:42

It looks like the SWbemLocator.ConnectServer Method allows you to specify a username and password when connecting to remote computers. It looks like the syntax that you need to use is similar, you just need to create your objWMIService object differently:

Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator") 
Set objWMIService = objSWbemLocator.ConnectServer("MachineName", "root\cimv2", "Username", "Password")

More documentation is available if you search for "WbemScripting.SWbemLocator" on Google

As a domain admin, you would be able to add an additional right to your account, which would allow you to start processes as any other user. This right in AD is called "Allow User to be Trusted for Delegation". It is extremely powerful. It is the only legitimate way to run your task as another user. See this link to set the right:

http://support.microsoft.com/kb/932455

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!