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

Re: variable for home directory by Fosco

Fosco
Fri Dec 15 00:56:40 CST 2006

"Jeremy Schubert"
> Sorry, I have forgotten names, but several people in this news group helped
> me with this script. One person gave me this line

http://tinyurl.com/s9rrt

--
Fosco



Re: variable for home directory by TDM

TDM
Tue Dec 19 09:25:25 CST 2006


"Baard Schøyen" <BaardSchyen@discussions.microsoft.com> wrote in message
news:ABA77382-0D85-4AF0-AB10-3647DD70ECC3@microsoft.com...
> Hello
>
> In vbscript you can find certain special folders, like e.g. My Documents:
>
> Set oShell = CreateObject("Shell.Application")
> Set oFol = oShell.Namespace(&H5&)
> Set oFolItem = oFol.Self
> msgbox oFolItem.Name & ": " & oFolItem.Path
>
> The above script will display your current path of My Documents.
>

You can also use the SpciealFolders property :

set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")

of which the following options are available :

a.. AllUsersDesktop
b.. AllUsersStartMenu
c.. AllUsersPrograms
d.. AllUsersStartup
e.. Desktop
f.. Favorites
g.. Fonts
h.. MyDocuments
i.. NetHood
j.. PrintHood
k.. Programs
l.. Recent
m.. SendTo
n.. StartMenu
o.. Startup
p.. Templates

Another option, say to find the users profile folder :

set WshShell = WScript.CreateObject("WScript.Shell")
WScript.Echo "Profile folder is " &
WshShell.ExpandEnvironmentStrings("%UserProfile%")
TDM