Monday, May 21, 2012
   
Text Size

Template.vbs file

Below is the template script for the VBScripting Source code on this site, all other VB's can be appended to the bottom of this script:

'*************************************************
'* Script Name        -   Template.vbs
'* Script Author      -   Andy Henderson
'* Version Number     -   1.00
'* Issue Date         -   6th March 2009
'* Script Description -   Template Visual Basic Script
'*************************************************

'****DIM VARIABLE NAMES
Dim WshShell, WshNetwork, FSO, WshEnv, WMIService
Dim sSysDrive, sWindir, sSys32, sRegEdit, sMSIExec
Dim sRegSvr, sAttrib, sAppData, sProgFiles
Dim sCommonProgFiles, sAllUserD, sAllUsersSt
Dim sDesktop, sStartmenu

'****SET VARIABLES
strComputer = "."

Set WshShell = WScript.CreateObject("WScript.Shell")
Set WshNetwork=Wscript.CreateObject ("Wscript.Network")
Set FSO = Wscript.CreateObject ("scripting.FileSystemObject")
Set WshEnv = WshShell.Environment("Process")
Set WMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

sSysDrive  = WshEnv("SystemDrive")
sWinDir    = WshEnv("WinDir")
sSys32     = sWinDir & "\System32"
sRegEdit   = sSys32 & "\regedit.exe"
sMsiExec   = sSys32 & "\MsiExec.exe"
sRegSvr    = sSys32 & "\RegSvr32.exe"
sAttrib    = sSys32 & "\Attrib.exe"
sAppData   = WshEnv("AppData")
sProgFiles = WshEnv("ProgramFiles")
sCommonProgFiles = WshEnv("CommonProgramFiles")
sAllUserD  = WshShell.SpecialFolders("AllUsersDesktop")
sAllUserSt = WshShell.SpecialFolders("AllUsersPrograms")
sDesktop   = WshShell.SpecialFolders("Desktop")
sStartMenu = WshShell.SpecialFolders("Programs")

'****Error Trapping
On Error Resume Next
Option Explicit

'****Main Program Body