Rem - 17 Dec 1999

The Win32 Scripting Journal answers your questions.

Bob Wells

December 17, 1999

5 Min Read
ITPro Today logo


Do you have a scripting-related question or problem? You can send your question or problem to [email protected].

In his column "Real-World Scripting: Testing and Changing Administrator Account Passwords" (November 1999), Dick Lewis describes how to use the Win32::AdminMisc module to reset Administrator account passwords. I like the simple function-call style that this Perl module offers, but my company's standard scripting tooI is VBScript. Although Microsoft Active Directory Service Interfaces (ADSI) offers this function, ADSI seems far too complex to use. Do any other VBScript object libraries (preferably free ones) have a password-reset function?

I'm not aware of any free object libraries with this function, but you can purchase them. For example, Zaks Solutions (http://www.zaks.demon.co.uk/code/index.html) offers the NTAccess.User component, which has the ResetPassword function.

If you've never used ADSI, you might be pleasantly surprised to find that using ADSI to manage passwords isn't that difficult. The only significant difference between the Win32::AdminMisc approach and the ADSI approach is that with ADSI, as with any COM-based automation component, you must create an instance of the object prior to calling the object's methods.

For example, suppose you want to change the password for the Administrator account in the Foo domain. As Listing 1 shows, you can use ADSI to accomplish this task with only two lines of code. The first line creates an instance of an ADSI User object. The second line invokes that object's SetPassword method.

Even with the NTAccess.User component, you need to create an instance of the object you want to use because, like ADSI, NTAccess.User is a COM-based solution. As Listing 2 shows, you create an instance of the NTAccess.User object. Unlike ADSI, you must also set the Server and User properties so that the component knows the name and location of the target user account. After you set these properties, you can call the object's ResetPassword function.

By comparing Listings 1 and 2, you can see that the ADSI solution is the simpler of the two COM-based approaches. The ADSI solution is also the easiest to manage.

If you're looking for a solution that uses Windows Scripting Host (WSH) and VBScript but isn't COM-based, you can try to find a command-line utility that performs the desired task. You can then use the WSH Shell object's Run method to execute the utility.

I'm trying to create a dial-up networking connectoid in a script, but I can't find a scripting language that lets me create this connection without using the problematic SendKeys statement. How can I create a connectoid for Windows NT and Windows 9x without using SendKeys?

Currently, you can't use a script to add or modify network connectoids, and I don't know of any tool or technology that provides this capability. Windows Management Instrumentation (WMI) is an ideal technology to provide this capability, so a future release of WMI might offer it. In the meantime, I encourage you to submit your suggestion to Microsoft. You can send product-related suggestions to Microsoft at http://register.microsoft.com/contactus/contactus.asp. Select Suggesting Product Improvements in the Microsoft Products drop-down list, and click Go. You can then enter your product improvement suggestion in the online form that appears.

WSH provides two methods to create objects: CreateObject and GetObject. VBScript provides the CreateObject and GetObject functions. Furthermore, you can create objects with VBScript's New keyword and WSH 2.0's <object> element. How do you know when to use each method, keyword, and element?

To make the answer to your question as simple as possible, let's list the six object-related mechanisms you mentioned:

  • VBScript's New keyword

  • WSH's WScript.CreateObject method

  • WSH's WScript.GetObject method

  • WSH 2.0's

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like