click to expand
WSH                              
*     Microsoft Stuff
  1/23/21   WSH
                                 
   
  Home https://www.makeuseof.com/tag/batch-windows-scripting-host-tutorial/
  How To's
  Misc Available languages include JScript, VBA, and VBscript.
  Networking It's also possible to write scripts in Perl, Python, PHP, Ruby or even Basic
  Windows  if you have the right implementation with the right scripting engine.
  Glossary
  Excell helloworld.vbs
  Examples wscript.echo   "Hello World"
  Outlook wscript.quit
  Paint Shop Pro
  Skype For the most flexibility, place <job> and <script language="VBScript"> (or whatever language you choose) 
  WSH around each segment of code in your file, and save it as a .wsf file. see Hello_World.wsf
    This way, so long as you enclose the code in the defined script language tags, you can use multiple languages in the same file.
   
   
    https://flylib.com/books/en/2.442.1/                   Part I - Introducing the WSH and VBScript
   
    Getting Started with the WSH and VBScript Getting Started with the WSH and VBScript
    Overview of the Windows Script Host
    WSH Scripting Engines
    VBScript Part II - Learning VBScript & WSH Scripting
    JScript
    3rd Party VBScript Basics
    Constants, Variables, and Arrays
    WSH Script Execution Host Conditional Logic
    CScript.exe Processing Collections of Data
    Wscript.exe Using Procedures to Organize Scripts
   
    Part III - Advanced Topics
    WSH Core Object Model provides VBScript with direct access to Windows resources.
    ( WSH.OSX ) Exposes the Win OS objects in a format that allows scripts to view, access, and manipulate them. Handling Script Errors
    Using the Windows Registry to Configure Script Settings
    Windows Resources (objexts) Combining Different Scripting Languages
    The Windows operating system can be viewed as a collection of objects Windows desktop
    Windows Start Menu Part IV - Appendices
    Win OS: Objects > file Windows applications
    disk drive Windows file system Appendix A WSH Administrative Scripting
    printer Windows Quick Launch Toolbar Appendix B Built-In VBScript Functions
    any resource that is part of the computer Network printers Appendix C Whats on the CD-ROM?
    Network drives
    Windows registry
   
    Objects > Have associated properties and methods that scripts can then use to interact with an object,
    as well as affect its behavior or status.
   
    Object Properties Methods properties (attributes) an object-specific attribute
    ie file name copy methods (actions) built-in functions that your scripts can execute to perform an action on an object
    file ext. move
   
   
    Overview of the Windows Script Host
   
    Working with objects Many Windows applications, including Microsoft Office applications, expose their own object models, allowing VBScript to programmatically manipulate them.
    In addition, other VBScript execution hosts, such as Internet Explorer, provide VBScript with access to other object models. 
    The WSH core object model is quite complex and may at first seem rather daunting
   
    Object Model   is a representation of a number of related objects that provide a script or program with the ability to view and interact with each of the objects (files, disks, printers, and so on) represented in the object model.
   
    The Core Object Model The WSH core object model provides programmatic access to Windows resources.
    There are 14 objects in the WSH core object model Each of these objects provides access to a particular category of Windows resources.
click to expand
   
    Wscript object ("top level", or root) It is from this object that all other objects are instantiated
    Is automatically established during the startup of the execution host and can therefore be referenced without first being instantiated within your scripts.
   
    Provides access to a number of very useful methods ----> CreateObject(). Establishes an instance of the specified object.
    DisconnectObject(). Prevents a script from accessing a previously instantiated object.
    Echo(). Displays a text message in the Windows Console or as a popup dialog depending on which execution hosts runs the script.
    Quit(). Terminates a script's execution.
    Sleep(). Pauses the execution of a script for a specified number of seconds.
   
    Instantiation A term that describes the process of creating a reference to an object.
    In order to work with an object you must first create, or instantiate, a reference to it within your scripts.
    Publice (Exposed) Objects
    The WScript object (top level object) is referred to as a public or exposed object. The WSH core object model has three other public objects  ------> Wscript "top level (root) object" Table 2.3: WSH OBJECT PROPERTIES Table 2.4: WSH OBJECT METHODS
      WshController
    Each of these three objects must be instantiated within your scripts using the WScript object's CreateObject() method   WshShell, Property Description Method Description
      WshNetwork Arguments Sets a pointer reference to the WshArguments collection. AddPrinterConnection() Creates printer mappings
    AtEndOfLine Returns either true or false depending on whether the end-of-line maker has been reached in the stream. AddWindowsPrinterConnection() Creates a new printer connection
    All of the other objects in the WSH core object model can only be instantiated by using properties or methods associated with the WScript, WshController, WshShell, and WshNetwork objects. AtEndOfStream Returns either true or false depending on whether the end of the input stream has been reached. AppActivate() Activates the targeted application Window
    Character Identifies the specific character in a line of code where an error occurs. Close() Terminates an open data stream
    Lower-Level Objects Column Returns the current column position in the input stream. ConnectObject() Establishes a connection to an object
    Table 2.1: WORKING WITH LOWER-LEVEL WSH OBJECTS WshArguments ComputerName Retrieves a computer's name. Count Retrieves the number of switches found in the WshNamed and WshUnnamed objects
    WshNamed CurrentDirectory Sets or retrieves a script current working directory. CreateObject() Creates a new instance of an object
    Object Method of Instantiation (the object properties or methods required to instantiate them)                 WshUnnamed Description Retrieves the description for a specified shortcut. CreateScript() Instantiates a WshRemote object representing a script that is running remotely
    WshArguments WScript.Arguments WshRemote Environment Sets a pointer reference to the WshEnvironment. CreateShortcut() Creates a Windows shortcut
    WshNamed WScript.Arguments.Named WshRemoteError Error Provides the ability to expose a WshRemoteError object. DisconnectObject() Terminates a connection with an object
    WshUnnamed WScript.Arguments.Unnamed WshShortcut ExitCode Returns the exist code from a script started using Exec(). Echo() Displays a text message
    WshRemote WshController.CreateScript() WshUrlShortcut FullName Retrieves a shortcut or executable program's path. EnumNetworkDrives() Enables access to network drives
    WshRemoteError WshRemote.Error WshEnvironment HotKey Retrieves the hotkey associated with the specified shortcut. EnumPrinterConnections() Enables access to network printers
    WshShortcut WshShell.CreateShortcut() WshSpecialFolders IconLocation Retrieves an icon's location. Exec() Executes an application in a child command shell and provides access to the environment variables
    WshUrlShortcut WshShell.CreateShortcut() WshScriptExec Interactive Provides the ability to programmatically set script mode. Execute() Initiates the execution of a remote script object
    WshEnvironment WshShell.Environment Item Retrieves the specified item from a collection or provides access to items stored in the WshNamed object. Exists() Determines a specified key exists within the WshNamed object
    WshSpecialFolders WshShell.SpecialFolders Length Retrieves a count of enumerated items. ExpandEnvironmentStrings() Retrieves a string representing the contents of the Process environmental variable
    WshScriptExec WshShell.Exec() Line Returns the line number for the current line in the input stream or identifies the line number within a script on which an error occurred. GetObject() Retrieves an Automation object
    Name Returns a string representing the name of the WScript object. GetResource() Retrieves a resource's value as specified by the tag
    Set used to create a reference to a specified object Number Provides access to an error number. LogEvent() Writes a message in the Windows event log
    & concatenation character Path Returns the location of the folder where the CScript or WScript execution hosts reside. MapNetworkDrive() Creates a network drive mapping
    _ The _ character is a continuation character and is used to indicate that a statement is continued on the next line. ProcessID Retrieves the process ID (PID) for a process started using the WshScriptExec object. Popup() Displays a text message in a popup dialog
    ScriptFullName Returns an executing script's path. Quit() Terminates, or ends, a script
    Constant a VBScript construct that contains information that does not change during the execution of a script ScriptName Returns the name of the executing script. Read() Retrieves a string of characters from the input stream
    Source Retrieves the identity of the object that caused a script error. ReadAll() Retrieves the s string that is made up of the characters in the input stream
    built-in constants VBScript provides a collection of built-in constants, such as the vbTab and vbCrLf constants SourceText Retrieves the source code that created the error. ReadLine() Retrieves a string containing an entire line of data from the input stream
    SpecialFolders Provides access to the Windows Start menu and desktop folders. RegDelete() Deletes a registry key or value
    Status Provides status information about a remotely executing script or a script starting with Exec(). RegRead() Retrieves a registry key or value
    Working with Object Methods StdErr Enables a script to write to the error output stream or provides access to read-only error output from an Exec object. RegWrite() Creates a registry key or value
    StdIn Enables read access to the input stream or provides access to the write-only input stream for the Exec object. Remove() Deletes the specified environmental variable
    WshShell object provides access to a number of Windows resources StdOut Enables write access to the output stream or provides access to the write-only output stream of the Exec object. RemoveNetworkDrive() Deletes the connection to the specified network drive
    The Windows application log TargetPath Retrieves a shortcut's path to its associated object. RemovePrinterConnection() Deletes the connection to the specified network printer
    The Windows registry UserDomain Retrieves the domain name. Run() Starts a new process
    ---> Any Windows command-line command ??  could make "log" entries using this ?? UserName Retrieves the currently logged-on user's name. Save() Saves a shortcut
    Version Retrieves the WSH version number. SendKeys() Emulates keystrokes and sends typed data to a specified window
    WindowStyle Retrieves a shortcut's window style. SetDefaultPrinter() Establishes a default Windows printer
    WorkingDirectory Returns the working directory associated with the specified shortcut. ShowUsage() Retrieves information regarding the way that a script is supposed to be executed
    Skip() Skips x number of characters when reading from the input stream
    SkipLine() Skips an entire line when reading from the input stream
    Sleep() Pauses script execution for x number of seconds
    Terminate() Stops a process started by Exec()
    Write() Places a string in the output stream
    WriteBlankLines() Places a blank in the output stream
    WriteLine() Places a string in the output stream