Windows Scripting
  Home arrow Windows Scripting arrow Page 4 - More Windows Scripting Workarounds from Ni...
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  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
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

More Windows Scripting Workarounds from Nilpo
By: Nilpo
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2009-02-25

    Table of Contents:
  • More Windows Scripting Workarounds from Nilpo
  • Implementing Password Masking
  • Masking Passwords without ScriptPW
  • More on Password Masking without ScriptPW

  • 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


    More Windows Scripting Workarounds from Nilpo - More on Password Masking without ScriptPW


    (Page 4 of 4 )

    Next, we'll take a look at the VBS code that uses this HTML page.  It's a simple login script that requires the user to enter a password using the HTML page you've just created.

    strPath = Left(WScript.ScriptFullName, Len(WScript.ScriptFullName) - Len(WScript.ScriptName))

    To begin, we're going to need to know the path to the HTML page.  Assuming it's in the same directory as the current script, this line is a very efficient way of finding that path.

    On Error Resume Next

     

    Set objIE = WScript.CreateObject("InternetExplorer.Application", "IE_")

    objIE.Navigate "file:///" & strPath & "Password.htm"

    objIE.ToolBar = 0

    objIE.StatusBar = 0

    objIE.Width = 400

    objIE.Height = 350

    objIE.Left = 300

    objIE.Top = 200

    objIE.Visible = 1

    Next, we're going to create an instance of Internet Explorer and load the HTML page.  I've added the On Error Resume Next statement to prevent any problems if outside errors occur.  Now we need the script to wait for the user to enter information in the form.

    Do While (objIE.Document.Body.All.OKClicked.Value = "")

       WScript.Sleep 250

    Loop

    This Do loop does that quite nicely.  It checks the value of the OKClicked element and loops around a Sleep statement until that value is not empty.  (If you look back at the HTML, we're assigning a distinct value for both button responses.  If OKClicked is empty, it's because neither button has been clicked yet.)

    strPassword = objIE.Document.Body.All.UserPassword.Value

    strButton = objIE.Document.Body.All.OKClicked.Value

    objIE.Quit

    WScript.Sleep 250

    With the form submitted, it's time to retrieve the contents of the password field.  Notice that I'm also retrieving the OKClicked value.  This will allow me to determine if the user clicked the Cancel button.

    If strButton = "Cancelled" Then

       WScript.Quit

    Else

       WScript.Echo strPassword

    End If

    Finally, a simple check against OKClicked determines whether the user canceled or entered a password.  Of course, in a production environment, you wouldn't stop here.  You would want to verify that the password field isn't empty and validate it.

    But that's enough for today, and that also wraps up the second volume of Nilpo's Scripting Secrets.  Stick around for even more great scripting tips.  Until next time, keep coding!


    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.

     

    WINDOWS SCRIPTING ARTICLES

    - More Windows Scripting Workarounds from Nilpo
    - Overloading Methods and More in VBScript
    - Improving MFC for Windows Vista
    - Regular Expressions in VBScript
    - Working with Dates in WMI
    - Completing Calendars with VBScript Date Func...
    - Building Calendars with VBScript Date Functi...
    - Working With Dates and Times in VBScript
    - Designing WCF DataContract Classes Using the...
    - Understanding Dates and Times in VBScript
    - Working With Arrays in VBScript
    - Compressed Folders in WSH
    - Using .NET Interops in VBScript
    - Nilpo`s Scripting Secrets, Vol I
    - Database operations using Silverlight 2.0 WC...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek