Solved

Creating/Disabling local user on a remote computer with VBscript

Posted on 2010-08-23
2
853 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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

Welcome back!  My apologies for taking so long to write part two of this series; it's been a long time coming!  As I promised in Part 1, this article will focus on how to locate those elusive AD properties that you are searching for.  Why is this us…
This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

724 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