This script was created for a specific purpose...so there are some shortcuts
that may not be applicable in all situations. It is a bit of a hack, but I
couldn't find any way to automatically roll this out to all users within an
organization. Individually, users can set this up themselves by creating a My
Site in MOSS and clicking Yes on the dialogue that asks if they want to
integrate with Microsoft Office.
It is meant to be rolled out en masse to users of a particuler MOSS 2007
document library. It is assumed that the users all have Office 2007 installed
and they have access to the document library.
Once this script is run for a particular user (it can be added to AD logon
scripts), the user will have a "My SharePoint Sites" folder in the Save or
Save As dialogues of any Microsoft Office Application with a browser view of
the document library.
This script does a couple of things:
-- Creates a Link Folder in the My SharePoint Sites folder for Office 2007
-- Adds the necessary registry keys to let Office know that a My SharePoint
Sites folder exists.
--
Option Explicit
Dim objFSO, objWSHShell
Const NETHOOD = &H13&
'Create the FileSystemObject and the Windows Scripting Shell
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWSHShell = CreateObject("Wscript.Shell")
'Setup the file path variables
Dim sTargetPath, sFolderPath, spFolderPath
'sTargetPath is the local path to the sharepoint folder that you want to
show up in My SharePoint Sites
sTargetPath = "{fill in your sharepoint path here}"
'SFolderPath is the path to the folder as you want it to appear to the user
in My SharePoint Sites
sFolderPath = objWSHShell.Environment("PROCESS")("UserProfile") & "\Local
Settings\Application Data\Microsoft\Office\My SharePoint Sites" & "\" &
"{Fill in Name Here}"
'spFolderPath is the location of the SharePoint folder for Microsoft Office
spFolderPath = objWSHShell.Environment("PROCESS")("UserProfile") & "\Local
Settings\Application Data\Microsoft\Office\My SharePoint Sites"
'Calls the subroutine that does the work
CreateNetworkPlace sTargetPath, sFolderPath, spFolderPath
Sub CreateNetworkPlace(sTargetPath, sFolderPath, spFolderPath)
Dim oShortcut, oTextFile, objFSOFolder
'If the sharepoint folder does not exist, then create it
if NOT objFSO.FolderExists(spFolderPath) Then
Set objFSOFolder = objFSO.CreateFolder(spFolderPath)
objFSOFolder.Attributes = 1
Set oTextFile = objFSOFolder.CreateTextFile("Desktop.ini", True)
oTextFile.WriteLine "[.ShellClassInfo]"
oTextFile.WriteLine "IconIndex=0"
oTextFile.WriteLine "Flags=2"
oTextFile.WriteLine "IconFile=" &
objWSHShell.Environment("PROCESS")("AllUsersProfile") & "\Application
Data\Microsoft\Office\MySharePoints.ico"
oTextFile.Close
End If
'Delete the sFolderPath if it already exists. We are going to recreate it
if objFSO.FolderExists(sFolderPath) Then
objFSO.DeleteFolder sFolderPath, True
End If
'Create the sFolderPath and make it readonly
Set objFSOFolder = objFSO.CreateFolder(sFolderPath)
objFSOFolder.Attributes = 1
'Need to create a target.lnk shortcut that tells the sFolderPath how to get
to the sharepoint site
Set oShortcut = objWSHShell.CreateShortcut(objFSOFolder.Path &
"\target.lnk")
oShortcut.TargetPath = sTargetPath
oShortcut.IconLocation = "%SystemRoot%\system32\SHELL32.DLL, 85"
oShortcut.Description = "Icon Master Content Repository"
oShortcut.WorkingDirectory = sTargetPath
oShortcut.WindowStyle = 1
oShortcut.Save
'The Desktop.ini class id denotes this folder as a shortcut folder
Set oTextFile = objFSOFolder.CreateTextFile("Desktop.ini", True)
oTextFile.WriteLine "[.ShellClassInfo]"
oTextFile.WriteLine "CLSID2={0AFACED1-E828-11D1-9187-B532F1E9575D}"
oTextFile.WriteLine "Flags=2"
oTextFile.WriteLine "ConfirmFileOp=0"
oTextFile.Close
'Create the registry key for Microsoft Office
objWSHShell.RegWrite
"HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Common\Portal\PersonalSiteURL",sTargetPath,"REG_SZ"
End Sub
--
Doug


