My script is below. I have two questions.
1. If Object.File("H:" & "\" & user & ".doc")
H: is mapped to the user's home share. Is there a variable for home share
(the vb equivelant to %homeshare%)?
2. serverpath = file://S047-s0371-01/047users$/diplomas/
Sorry, I have forgotten names, but several people in this news group helped
me with this script. One person gave me this line. Are the forward slashes
correct (rather then back slashes?). Is the line basically just a hyperlink
to the directory named?
CODE
****************************************************************************
On Error Resume Next
'*** Declarations ***
Dim Shell,FSO,Network,word
'*** Objects ***
Set Network = WScript.CreateObject("WScript.Network")
Set Shell = WScript.CreateObject("WScript.Shell")
Set FSO = CreateObject("Scripting.FileSystemObject")
'Begin printer setup section
Dim oNet
Set oNet = CreateObject("WScript.Network")
Dim strComputerName
strComputerName = oNet.ComputerName
If InStr(strComputerName, "047-C303") > 1 Then
Net.AddWindowsPrinterConnection "\\S047-S0371-01\C303"
Net.setdefaultprinter "\\S047-S0371-01\C303"
End If
If InStr(strComputerName, "047-C309") > 1 Then
Net.AddWindowsPrinterConnection "\\S047-S0371-01\C309"
Net.setdefaultprinter "\\S047-S0371-01\C309"
End If
If InStr(strComputerName, "047-C310") > 1 Then
Net.AddWindowsPrinterConnection "\\S047-S0371-01\C310"
Net.setdefaultprinter "\\S047-S0371-01\C310"
End If
If InStr(strComputerName, "047-C312") > 1 Then
Net.AddWindowsPrinterConnection "\\S047-S0371-01\C312"
Net.setdefaultprinter "\\S047-S0371-01\C312"
End If
If InStr(strComputerName, "047-C110") > 1 Then
Net.AddWindowsPrinterConnection "\\S047-S0371-01\C110"
Net.setdefaultprinter "\\S047-S0371-01\C110"
End If
If InStr(strComputerName, "047-C111") > 1 Then
Net.AddWindowsPrinterConnection "\\S047-S0371-01\C111"
Net.setdefaultprinter "\\S047-S0371-01\C111"
End If
If InStr(strComputerName, "047-LIB") > 1 Then
Net.AddWindowsPrinterConnection "\\S047-S0371-01\Lib"
Net.setdefaultprinter "\\S047-S0371-01\Lib"
End If
If InStr(strComputerName, "047-LIB1") > 1 Then
Net.AddWindowsPrinterConnection "\\S047-S0371-01\Lib1"
Net.setdefaultprinter "\\S047-S0371-01\Lib1"
End If
'End printer section
'Begin document creation section
serverpath = file://S047-s0371-01/047users$/diplomas/
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")
Then Word.Documents.Open("H" & "\" & user & ".doc")
Else
fso.copyfile serverpath & "diplomas.doc","H:" & "\" & user & ".doc"
Set Word = CreateObject ("Word.Application")
Word.Visible = TRUE
Word.Documents.Open("H:" & "\" & user & ".doc")
'End document creation section
wscript.quit