Solved

Creating/Disabling local user on a remote computer with VBscript

Posted on 2010-08-23
2
848 Views
Last Modified: 2012-05-10
Hi,

I am trying to modify couple of scripts that I have found on here http://www.activexperts.com/activmonitor/windowsmanagement/adminscripts/usersgroups/localusers/ to be executed with alternate credentials and I am having some troubles.  The alternate credentials that I want to use is a local user on a target computer.

Here are the two scripts:

'Creating user
strComputer = "MyComputer"
Set colAccounts = GetObject("WinNT://" & strComputer & "")
Set objUser = colAccounts.Create("user", "Admin2")
objUser.SetPassword "test"
objUser.SetInfo

Open in new window


'Disable User
strComputer = "MyComputer"
Set objUser = GetObject("WinNT://" & strComputer & "/Guest")
objUser.AccountDisabled = True
objUser.SetInfo

Open in new window


I found an article that talks about specifying alternate users here http://blogs.technet.com/b/heyscriptingguy/archive/2004/12/13/how-can-i-run-a-script-under-alternate-credentials.aspx but can't figure out how to user their example to modify my two scripts.

Can anyone assist?

Thanks
Alex
0
Comment
Question by:Alexey91
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 71

Accepted Solution

by:
Chris Dent earned 500 total points
ID: 33502280
Hello there,

It should go like this.

Chris
Set objNamespace = GetObject("WinNT:")
Set objComputer = objNamespace.OpenDSObject("WinNT://" & strComputer, "SomeUsername", "SomePassword", 0)
Set objUser = objComputer.Create("user", "Admin2")
objUser.SetPassword "test"
objUser.SetInfo

Open in new window

0
 
LVL 71

Expert Comment

by:Chris Dent
ID: 33502286

Missed the "where", SomeUsername and SomePassword represent the account you wish to connect to the remote system with.

Chris
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello again, all.  For those of you that have been following along, you'll know that this is my third article on this topic (though it is not Part III).  This article is sort of remedial, and probably the topic with which I should have started the s…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question