Windows Scripting
  Home arrow Windows Scripting arrow Set the Autologon Script using WMI
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Moblin 
JMSL Numerical Library 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
WINDOWS SCRIPTING

Set the Autologon Script using WMI
By: aspfree
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 9
    2003-03-29

    Table of Contents:

    Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Another great code-tip from ASPFree


    This script will set the appropriate registry keys to auto-logon a server.  This would be handy when wanting to do something that would require the server to auto-logon, run a script and reboot.  This script could also be used to disable auto-logon, just set the AutoLogonCount=0.  Be very careful when running this script, as the dis-claimer, backup your registry before running.  If your not comfortable in how or why to use this script, don't use it then.   This can be saved in a file (autologon.vbs computer1 computer2 etc..) This accepts any number of arguments.   The argument would set the DefaultDomainName to the local computer name, login as the local Administrator and run the script.   Definitely test out the script on a development machine before using. 

    Option Explicit
    On Error Resume Next
    Err.Clear

    dim StdOut, objReg, strKeyPath, strStringValueName, strSetStringValue, strEntryName, strValue, strLoginPath
    dim Wshshell, ArgObj, sArgCount, x

    Set WshShell = WScript.CreateObject("WScript.Shell")

    const HKEY_LOCAL_MACHINE = &H80000002
    Set StdOut = WScript.StdOut

    strSetStringValue = "c:\winnt\system32\wscript.exe c:\someWSHFile.vbs"
    strStringValueName = "Description of the process"

    Set ArgObj = WScript.Arguments
    sArgCount = ArgObj.Count

    For x = 0 to sArgCount - 1
        Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
        ArgObj(x) & "\root\default:StdRegProv")

        strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce\ANewRegistryKey"
        strLoginPath = "Software\Microsoft\Windows NT\CurrentVersion\Winlogon"
        objReg.CreateKey HKEY_LOCAL_MACHINE,strKeyPath
        objReg.SetStringValue HKEY_LOCAL_MACHINE, strLoginPath, "AutoAdminLogon", "1"
        objReg.SetStringValue HKEY_LOCAL_MACHINE, strLoginPath, "DefaultUserName", "Administrator"
        objReg.SetStringValue HKEY_LOCAL_MACHINE, strLoginPath, "DefaultPassword", "Password"
        objReg.SetStringValue HKEY_LOCAL_MACHINE, strLoginPath, "AutoLogonCount", "1"
        objReg.SetStringValue HKEY_LOCAL_MACHINE, strLoginPath, "DefaultDomainName", ArgObj(x)
        objReg.SetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strStringValueName, strSetStringValue
        set objReg = Nothing
    Next

    set wshshell = nothing
    set argobj = nothing

    Sub ErrorHandler(byVal errornum, byVal errorDesc)
        theDesc = "Error Number: " & errornum & " Error Description: " & errorDesc
        WshShell.LogEvent 1, theDesc
        err.clear
    End Sub


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

    More Windows Scripting Articles
    More By aspfree

     

    IBM® developerWorks developerWorks - FREE Tools!


    NEW! Applying lean thinking to the governance of software development

    Effective governance for lean development isn’t about command and control. Instead, the focus is on enabling the right behaviors and practices through collaborative and supportive techniques. Hear from Scott Ambler on how it is far more effective to motivate people to do the right thing than it is to force them to do so. Learn how to form a lightweight, collaboration-based framework that reflects the realities of modern IT organizations.
    FREE! Go There Now!


    NEW! Discovering the value of WebSphere Process Server

    WebSphere Process Server delivers a unique integration framework that simplifies existing IT resources. Often, as IT assets grow to support business demand, so too does their complexity and manageability. In this webcast, we’ll discuss how WebSphere Process Server helps deliver an SOA infrastructure that provides a common model to orchestrate, mediate, connect, map, and execute the underlying IT functions. Discover how WebSphere Process Server simplifies integration of business processes by leveraging existing IT assets as reusable services without the complexities of traditional integration methodologies.
    FREE! Go There Now!


    NEW! Download the free Web Application Security eKit

    Discover how IBM Rational AppScan Standard Edition can help you detext vulnerabilities in your web applications in the Web Application Security eKit. IBM Rational AppScan is a leading suite of automated web application security solutions that scan and test for common Web application vulnerabilities. The new Web Application Security eKit provides you with valuable resources, including white papers, demos, and additional information on the benefits of testing your Web applications.
    FREE! Go There Now!


    NEW! Evaluate Rational Business Developer V7.1

    Visit IBM developerWorks to download a free trial version of IBM Rational Business Developer V7.1. Rational Business Developer offers rapid and simplified development of business applications and services through Enterprise Generation Language (EGL) tools, generating Java or mainframe solutions while shielding developers from technical complexities.
    FREE! Go There Now!


    NEW! IBM Enterprise Modernization Sandbox for System z

    IBM Enterprise Modernization solutions help organizations evolve core IT systems towards modern architectures and technologies—reducing the burden of maintenance and freeing up resources to develop new business requirements and capabilities. With the IBM Enterprise Modernization Sandbox for System z you can evaluate IBM Enterprise Modernization solutions focused on five key areas: Assets, Architectures, Skills, Processes and Infrastructures, and Investment. Each solution is based upon real customer experiences and offers a proven path to get you started with your modernization projects.
    FREE! Go There Now!


    NEW! Rational 'Talks to You' Teleconference Series

    This Fall, IBM Rational talks to you directly through a special teleconference series giving you access to the best minds in IBM Rational - product experts and market thought leaders who will answer your questions during these pre-scheduled telephone conference calls. Register today!
    FREE! Go There Now!


    NEW! Run your first CICS application on a PC using TXSeries for Windows

    Learn the basics of the IBM Customer Information Control System (CICS). With a hands-on exercise, learn how to get your first CICS application up and running on your desktop using TXSeries V6.1 for Windows. The tutorial shows you how to download and install a free trial version of TXSeries V6.1.
    FREE! Go There Now!


    NEW! Understanding Web application security challenges

    As businesses grow increasingly dependent upon Web applications, these complex entities grow more difficult to secure. Most companies equip their Web sites with firewalls, Secure Sockets Layer (SSL), and network and host security, but the majority of attacks are on applications themselves – and these technologies cannot prevent them. This paper explains what you can do to help protect your organization, and it discusses an approach for improving your organization’s Web application security.
    FREE! Go There Now!


    NEW! Webcast: Accelerating Software Innovation with System z

    Attend this launch webcast with Scott Hebner, Vice President of IBM Rational Marketing and Strategy, where he will overview Rational’s new offerings and programs to help customers accelerate software innovation on System z. He will discuss how these solutions help organizations extend their core business processes toward modern architectures such as SOA and web technologies to deliver business improvements that stand the test of time.
    FREE! Go There Now!


    NEW! Webcast: Introducing the new Information Server and Solutions community: LeverageInformation

    User communities play an important role in communication and collaboration around products, solutions and other areas of special interest to members. Successful communities are able to provide the right mix of content and services to deliver a value proposition that resonates with each audience. Join Tom Inman, VP of Marketing for Information and Platform Solutions as he introduces the new LeverageINFORMATION community. During this webcast, learn about the value provided by the community and how customers and partners derive value from the community in addressing their own technical and business challenges.
    FREE! Go There Now!



    All FREE IBM® developerWorks Tools!

    WINDOWS SCRIPTING ARTICLES

    - Screen Capturing via GDI+ and GDI
    - Understanding Procedures in VBScript
    - Printing Documents in WSH
    - Generating Outlook Signatures Based on Activ...
    - VBScript: Converting and Formatting with Fun...
    - VBScript: Conversion and Format Functions
    - VBScript: Array Functions
    - VBScript: Strings, You Can`t Function withou...
    - VBScript: More String Functions
    - VBScript: Functioning with Strings
    - Working with the Windows Registry in C++
    - Understanding Objects
    - HTML Applications: Giving WSH a User Interfa...
    - Modifying Computer Objects with Active Direc...
    - Logon Script to Send Email Notifications





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway