feedback on a script please
- From: "Jeremy Schubert" <jschubert@no*spam.shaw.ca>
- Date: Tue, 19 Dec 2006 20:44:35 -0700
I put a version of this script out once but I have rewritten it since. I'm
sure all of you have better things to do now before the holidays start, but
if you have a bit of time, please give me feedback on this script.
CODE
---------------------------
'Author Jeremy Schubert
'047diploma.vbs
'Logon Script to:
' - map diploma users Home Drive
' - set appropriate printer
' - create and open a word document pre-formatted with Alberta
Education's requirements
' - name the document with the exam ID#
'****************Begin Initial Tasks Section********************
On Error Resume Next
'*** Declarations ***
Dim Shell,FSO,Network,word, WSHNetwork, UserString
'*** Objects ***
Set Network = WScript.CreateObject("WScript.Network")
Set Shell = WScript.CreateObject("WScript.Shell")
Set FSO = CreateObject("Scripting.FileSystemObject")
'Disconnect ALL existing mapped drives
Set clDrives = WshNetwork.EnumNetworkDrives
For i = 0 to clDrives.Count -1 Step 2
WSHNetwork.RemoveNetworkDrive clDrives.Item(i), True, True
Next
'Give the PC time to do the disconnect, wait 300 milliseconds
wscript.sleep 300
'Map H: to users home share
WSHNetwork.MapNetworkDrive "H:", "\\S047-S-0371-01\" & UserString & "$",True
'Map S: to \\s047-s0371-01\047diploma$
objNetwork.MapNetworkDrive "S:" , "\\S047-S0371-01\047diplomasusers$"
'*************End Initial Task Section**************************
'*************Begin Printer Setup Section***********************
Dim oNet
Set oNet = CreateObject("WScript.Network")
Dim strComputerName
strComputerName = oNet.ComputerName
If InStr(strComputerName, "047-C303") > 1 Then
oNet.AddWindowsPrinterConnection "\\S047-S0371-01\C303"
oNet.setdefaultprinter "file://server/printer"
End If
If InStr(strComputerName, "047-C309") > 1 Then
oNet.AddWindowsPrinterConnection "\\S047-S0371-01\C309"
oNet.setdefaultprinter "\\S047-S0371-01\C309"
End If
If InStr(strComputerName, "047-C310") > 1 Then
oNet.AddWindowsPrinterConnection "\\S047-S0371-01\C310"
oNet.setdefaultprinter "\\S047-S0371-01\C310"
End If
If InStr(strComputerName, "047-C312") > 1 Then
oNet.AddWindowsPrinterConnection "\\S047-S0371-01\C312"
oNet.setdefaultprinter "\\S047-S0371-01\C312"
End If
If InStr(strComputerName, "047-C110") > 1 Then
oNet.AddWindowsPrinterConnection "\\S047-S0371-01\C110"
oNet.setdefaultprinter "\\S047-S0371-01\C110"
End If
If InStr(strComputerName, "047-C111") > 1 Then
oNet.AddWindowsPrinterConnection "\\S047-S0371-01\C111"
oNet.setdefaultprinter "\\S047-S0371-01\C111"
End If
If InStr(strComputerName, "047-LIB") > 1 Then
oNet.AddWindowsPrinterConnection "\\S047-S0371-01\Lib"
oNet.setdefaultprinter "\\S047-S0371-01\Lib"
End If
If InStr(strComputerName, "047-LIB1") > 1 Then
oNet.AddWindowsPrinterConnection "\\S047-S0371-01\Lib1"
oNet.setdefaultprinter "\\S047-S0371-01\Lib1"
End If
'*******************End Printer Setup Section*****************************
'*******************Begin Document Creation Section***********************
'Instruct user to enter the 6 digit exam id number
user = inputbox("Please enter your 6 DIGIT EXAM NUMBER")
'Check to see if the users's document already exists. The document may
already exist if 'this is the second time a 'user is logging in if (for
example) the computer crashed and 'needed to be rebooted). In that case,
the user's 'existing document is opened.
If Object.File("H:" & "\" & user & ".doc")
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Open("H:\" & User & ".doc")
Else
'Copy template (diplomas.doc) from S: to H:
Const OverwriteExisting = True
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "S:\diplomas.doc" , "H:\diplomas.doc", OverwriteExisting
'Rename template to User & doc
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.MoveFile "H:\diplomas.doc" , "H:\" & User & ".doc"
'Open the new document
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Open("H:\" & User & ".doc")
'******************End Document Creation Section**************************
'******************Terminate Script***************************************
wscript.quit
.
- Prev by Date: Re: Thank you Richard, Paul and urkec
- Next by Date: Re: Moving Mouse pointer with .vbs file
- Previous by thread: Moving Mouse pointer with .vbs file
- Next by thread: Check Existence of Registry Key, HOW ?
- Index(es):
Relevant Pages
|