1 / 9

Windows Script 101

Windows Script 101. VBScript for Sysadmins. Dave Motovidlak Faculty of Arts & Sciences motovidlak@admin.rutgers.edu. What is VBScript?. VBScript = Visual Basic Scripting Edition Subset of VB language – “VB Lite” Less GUI oriented  Easier for beginning programmers to use … ?

collin
Download Presentation

Windows Script 101

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Windows Script 101 VBScript for Sysadmins Dave Motovidlak Faculty of Arts & Sciences motovidlak@admin.rutgers.edu

  2. What is VBScript? • VBScript = Visual Basic Scripting Edition • Subset of VB language – “VB Lite” • Less GUI oriented  Easier for beginning programmers to use … ? • Intermediate step between batch files and “real” programming… maybe? • VBS (and JScript) support built into OS

  3. How do you make VBScripts? • Regular ol’ text. No compiling. • Notepad suffices, other IDE’s are available. Try jEdit (http://jedit.org) or PrimalScript (http://sapien.com) • Run with wscript.exe or cscript.exe. Debugger available too. • VBS also used in MS Office docs  Visual Basic for Applications (use the Visual Basic Editor, under View  Toolbars)

  4. What can I do with VBScripts? • VBS = object-oriented. Depends on object model you are scripting. VBS is just the “glue.” • Some object models: Windows Script Host, Office, Internet Explorer, WMI, ADSI • Can read / write files, modify the registry, change pc name, collect system data, manage user accounts / services, send data over web, reboot, create Excel charts, start processes on remote computers, automate OS installs, create your own “dll’s,**” etc.…

  5. What are objects? • Objects are just things with properties and methods. Described by “dot” syntax. • Set myIE=CreateObject(“InternetExplorer.Application”) • myIE.IsVulernable=True • myIE.SpawnVirus(“ILoveYou”) • Object model = all the objects + methods + properties “exposed” by a particular app or package 5ProgID

  6. Syntax examples • Set objShl=CreateObject(“WScript.Shell”)objShl.Run “notepad.exe”,1,True • strOutfile=“C:\Temp\1.txt”Set objFso=CreateObject(“Scripting.FileSystemObject)Set objFil=objFso.OpenTextFile(strOutfile,2,True)objFil.WriteLine “Hello world”objFil.Close

  7. Which objects / models are most important? • Depends on what you want to do… • Windows Script Host (Network, Environment variables, Special Folders) • Scripting.FileSystemObject • WScript.Shell • ADSI  service / user mgt. • WMI  tricky but very powerful system admin interfaces

  8. How do I learn more? • Online documentation, especially downloadable “Windows Script” chm • Oleview from reskit • Cheat with Visual Basic Editor in Office  set References with Object Browser (use “dot completion” feature) • Scriptomatic tools, esp. for WMI and ADSI • Browse the registry … e.g., HKEY_CLASSES_ROOT\WScript.Shell

  9. A few script resources • UCS Toolkit: http://ucstoolkit.rutgers.edu/technical/scripts.html • MSDN:http://msdn.microsoft.com/scripting • Win32 Scripting:http://cwashington.netreach.net/ motovidlak@admin.rutgers.edu

More Related