Windows Vista Forums

Script to create "My SharePoint Sites"
  1. #1


    Doug Guest

    Script to create "My SharePoint Sites"

    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

      My System SpecsSystem Spec

  2. #2


    Al Dunbar Guest

    Re: Script to create "My SharePoint Sites"


    "Doug" <Doug@xxxxxx> wrote in message
    news:C66D778E-C058-47C3-922E-4108C15BB286@xxxxxx

    > 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.
    > --
    Do you have a question?

    /Al

    > 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


      My System SpecsSystem Spec

  3. #3


    Doug Guest

    Re: Script to create "My SharePoint Sites"

    Nope, just sharing...this post is marked as a general comment.
    --
    Doug


    "Al Dunbar" wrote:

    >
    > "Doug" <Doug@xxxxxx> wrote in message
    > news:C66D778E-C058-47C3-922E-4108C15BB286@xxxxxx

    > > 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.
    > > --
    >
    > Do you have a question?
    >
    > /Al
    >

    > > 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
    >
    >
    >

      My System SpecsSystem Spec

Script to create "My SharePoint Sites" problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help! Vista Cannot create dialup/VPN connections "The wizard cannot create the connection" licensetokill007 Vista networking & sharing 14 27 Apr 2009
do not display "ERRORS" when running script without using $erroractionpreference = "SilentlyContinue" IT Staff PowerShell 2 27 Feb 2009
"Parameter is incorrect" for SOME file copy SharePoint to Vista NO LarryPullingTeeth Vista General 0 18 Jan 2008
Should "script" be listed as a "reserved word" Andrew Watt [MVP] PowerShell 2 22 Jan 2007
Longhorn Beta2: Error on adding Role "Windows Sharepoint Services" André M. Bautz Vista installation & setup 2 02 Jun 2006