Windows Scripting
  Home arrow Windows Scripting arrow 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


    (Page 1 of 4 )

    Scripting, by nature, is a limited form of programming. As a result of these limitations it is sometimes necessary to employ workarounds in order to produce a desired effect. I showed you some of the workarounds that I commonly use in the first volume of this series. Today, I return with volume two to demonstrate more workarounds that you may find useful in your scripting endeavors.

    While I have discovered many of these workarounds on my own, some of them are not my own creation.  Some of these can be found on the Rube Goldberg Memorial Scripting Page.  I apologize for others in this series that may go uncredited as I'm unaware of their origins.  In any case, let's get started.

    Display a File Copy Dialog

    The most common scripting method for copying files and folders in WSH is by means of the FileSystemObject (Scripting.FileSystemObject).  As you may have noticed, this is a silent process that does not display any form of progress dialog.  While there are workarounds in existence that can produce a functional command-line version, there is a way to produce the real thing.

    A file copy progress dialog box is displayed any time that you copy files or folders using Windows Explorer.  This can be demonstrated by dragging and dropping files in My Computer.  It stands to reason that this is a feature of the Windows Explorer Shell.  In scripting, we do not have access to these specific Explorer APIs; however, we do have access to Explorer's scriptable interface through the use of the Windows Shell object.  Since this object employs the native APIs, a progress dialog is displayed whenever the object is used to move or copy files and folders.

    strSourceFolder = "C:Folder 1"

    strDestFolder = "C:Folder 2"

     

    Set objShell = CreateObject("Shell.Application")

     

    Set objSourceFolder = objShell.NameSpace(strSourceFolder)

    Set objDestFolder = objShell.NameSpace(strDestFolder)

     

    result = objDestFolder.CopyHere(objSourceFolder.Items)

    This simple example uses the Windows Shell object to perform a file copy procedure.  The Shell object's NameSpace method is first used to create Folder objects for the source and destination folders.  (The Items property returns a collection of File and Folder objects contained in a Folder).  The CopyHere method is then used to initiate the copy process.  You may also use the MoveHere method instead if you wish to perform a Move or Rename operation.

    Const sFOF_SILENT                = 4    'Do not display a progress dialog box.

    Const sFOF_RENAMEONCOLLISION     = 8    'Rename if target file already exists.

    Const sFOF_NOCONFIRMATION        = 16   'Respond with "Yes to All" for any dialog box that is displayed.

    Const sFOF_ALLOWUNDO             = 64   'Preserve undo information, if possible.

    Const sFOF_FILESONLY             = 128  'Perform the operation on files only (not on folders) if wildcard (*.*) is specified.

    Const sFOF_SIMPLEPROGRESS        = 256  'Display a progress dialog box without showing file names.

    Const sFOF_NOCONFIRMMKDIR        = 512  'Create destination directory if required.

    Const sFOF_NOERRORUI             = 1024 'Do not display a user interface if an error occurs.

    Const sFOF_NOCOPYSECURITYATTRIBS = 2048 'Do not copy the security attributes of the file.

    Const sFOF_NORECURSION           = 4096 'Only operate in the local directory. Don't operate recursively. (Default behavior)

    Const sFOF_NO_CONNECTED_ELEMENTS = 9182 'Do not copy connected files as a group. Only copy the specified files.  (Win 98SE and higher)

    The MoveHere and CopyHere methods also accept a second parameter that specifies shell settings to be used during the operation.  These constants must be added to your script if you do not wish to use the default settings.

    More Windows Scripting Articles
    More By Nilpo


     

    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-2010 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek