?
Solved

Creating/Disabling local user on a remote computer with VBscript

Posted on 2010-08-23
2
Medium Priority
?
855 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 2000 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them.

Question has a verified solution.

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

Recently I finished a vbscript that I thought I'd share.  It uses a text file with a list of server names to loop through and get various status reports, then writes them all into an Excel file.  Originally it was put together for our Altiris server…
Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

762 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