+ Post New Thread
Results 1 to 11 of 11
Scripts Thread, Redirecting favourites with a script. in Coding and Web Development; Hi I want to re-direct the favourites to a folder in the users home folder. In the registry I can ...
  1. #1

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,950
    Thank Post
    886
    Thanked 1,697 Times in 1,475 Posts
    Blog Entries
    12
    Rep Power
    447

    Redirecting favourites with a script.

    Hi

    I want to re-direct the favourites to a folder in the users home folder. In the registry I can find where to do it “HKEY_CURRENT_USER\Software\Microsoft\Windows\Curr entVersion\Explorer\User Shell Folders” then “Favourites”.

    How would I change this in a VBS script? Would it be a start-up or logon please?

    Cheers
    Last edited by FN-GM; 14th April 2008 at 10:33 PM.

  2. #2
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    5,009
    Thank Post
    120
    Thanked 282 Times in 260 Posts
    Rep Power
    108
    It would be to change the user environment so it would be a log on script. There are plenty of examples on the MS Script Centre you can adapt for your needs.

  3. #3

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,950
    Thank Post
    886
    Thanked 1,697 Times in 1,475 Posts
    Blog Entries
    12
    Rep Power
    447
    But would users have security rights to change registry settings?
    Last edited by FN-GM; 14th April 2008 at 10:40 PM.

  4. #4

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,950
    Thank Post
    886
    Thanked 1,697 Times in 1,475 Posts
    Blog Entries
    12
    Rep Power
    447
    using this code:

    Code:
    Option Explicit
    
    ' Variable Declarations
    Dim objShell
    Dim objNetwork
    Dim strUserName
    Dim strRegKey
    Dim strRedirectionPath
    
    ' Variable Initilisations
    Set objShell = CreateObject("WScript.Shell")
    Set objNetwork = CreateObject("WScript.Network")
    strUserName = objNetwork.UserName
    strRegKey = "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Favorites"
    strRedirectionPath = "%homedrive%\Favorites"
    
    ' Write the new Favorites path
    objShell.RegWrite strRegKey, strRedirectionPath
    
    ' Variable Destruction
    Set objShell = Nothing
    Set objNetwork = Nothing
    
    ' Quit
    WScript.Quit
    It alters the registry so thats all good.

    But when i try to view the favourites its all greyed out. The folder does exist in the users home drive but it jsut doesn't want to work.

    any ideas please?

  5. #5
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    5,009
    Thank Post
    120
    Thanked 282 Times in 260 Posts
    Rep Power
    108
    You cant just use an environment variable in VB such as %homedir% you must expand it first. There is a command to do this.
    Last edited by ChrisH; 14th April 2008 at 11:32 PM.

  6. #6
    fooby's Avatar
    Join Date
    Dec 2005
    Posts
    351
    Thank Post
    0
    Thanked 5 Times in 4 Posts
    Rep Power
    19
    dont forget if you redirect for all your users it adds a massive load to the server to have all those connections, an alternative is to add custom ones via group policy or by copying to the users logon profile folder.

    or have them locally and redirect all users to the local copy.

    we do this here with the startmenu, its redirected to c:\profile\startmenu and can be updated with a robocopy script to copy the files to all of the computers in a room.

    works here

    hth

  7. #7

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,950
    Thank Post
    886
    Thanked 1,697 Times in 1,475 Posts
    Blog Entries
    12
    Rep Power
    447
    Quote Originally Posted by ChrisH View Post
    You cant just use an environment variable in VB such as %homedir% you must expand it first. There is a command to do this.
    Iím not a VB expert here so please bare with me. Why not? It seems to have done the trick on the registry settings and all the other settings of this nature use those variables.

    Quote Originally Posted by fooby View Post
    dont forget if you redirect for all your users it adds a massive load to the server to have all those connections, an alternative is to add custom ones via group policy or by copying to the users logon profile folder.

    or have them locally and redirect all users to the local copy.

    we do this here with the startmenu, its redirected to c:\profile\startmenu and can be updated with a robocopy script to copy the files to all of the computers in a room.

    works here

    hth
    Thanks an idea thanks, but i haven't got my head arround robocopy yet

  8. #8
    ChrisH's Avatar
    Join Date
    Jun 2005
    Location
    East Lancs
    Posts
    5,009
    Thank Post
    120
    Thanked 282 Times in 260 Posts
    Rep Power
    108
    VB Script does not know what to do with %homedir% without expanding it first. It will just treat it as its written. Looking at the way you have used it as a string, it may work if it looks ok in the registry but normally you have to do this:

    vbscript expand environment variable - Google Search

  9. #9

    Join Date
    Aug 2005
    Location
    London
    Posts
    3,156
    Thank Post
    116
    Thanked 529 Times in 452 Posts
    Blog Entries
    2
    Rep Power
    124
    It's not that VBScript doesn't understand environment variables; it's whether the registry key is REG_SZ or REG_EXPAND_SZ.

    User Shell Folders does use REG_EXPAND_SZ so you should be able to use the env var - we use:
    Code:
    oShell.regwrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Favorites","%homeshare%\favorites","REG_EXPAND_SZ"
    and it works fine.

    Can't see any reason why having a connection to a server will cause a problem - even if the users are reading the entire tree every few minutes they're all tiny files so you're hardly going to stress things out. If you put the favorites as a sub folder under the home drive then they've already got a connection to the server for that.

  10. #10
    tech-man's Avatar
    Join Date
    Jul 2005
    Location
    The Pub
    Posts
    171
    Thank Post
    13
    Thanked 16 Times in 11 Posts
    Rep Power
    21
    We don't use a script, I have a ADM for Group Policy..... call it iefavsloc.adm and import it in to a object.... hey presto!

    CLASS USER
    CATEGORY !!WindowsComponents
    CATEGORY !!InternetExplorer
    CATEGORY !!IE_Favorites
    KEYNAME "Software\Microsoft\Windows\CurrentVersion\Explore r\User Shell Folders"

    POLICY !!IE_Favorites
    #if version >= 4
    SUPPORTED !!SUPPORTED_IE5
    #endif

    EXPLAIN !!IE_Favorites_Location_Explain

    PART !!IE_Favorites_Location_Tip1 TEXT
    END PART

    PART !!IE_Favorites_Location EDITTEXT EXPANDABLETEXT
    VALUENAME Favorites
    DEFAULT "%USERPROFILE%\Favorites"
    REQUIRED
    END PART
    END POLICY

    END CATEGORY ;; IE_Favorites
    END CATEGORY ;; Internet Explorer
    END CATEGORY ;; WindowsComponents


    [strings]

    WindowsComponents="Windows Components"
    IE_Favorites="Favorites"
    IE_Favorites_Location="The path to the favorites folder"
    IE_Favorites_Location_Explain="Specify the path to the location of favorites. You can use variables like %USERPROFILE%, %USERNAME%, etc... Both local and UNC paths are valid."
    IE_Favorites_Location_Tip1="Specify the UNC path to the favorites location"
    InternetExplorer="Internet Explorer"
    SUPPORTED_IE5="at least Internet Explorer v5.01"

  11. #11

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,950
    Thank Post
    886
    Thanked 1,697 Times in 1,475 Posts
    Blog Entries
    12
    Rep Power
    447
    Thanks for the feedback will test them tomorrow.

SHARE:
+ Post New Thread

Similar Threads

  1. Adding favourites to groups
    By ictex in forum Windows
    Replies: 6
    Last Post: 20th April 2008, 05:31 PM
  2. Redirect Favourites Bug??
    By SwedishChef in forum Windows
    Replies: 4
    Last Post: 23rd February 2007, 03:56 PM
  3. Shared favourites for different classes
    By contink in forum How do you do....it?
    Replies: 7
    Last Post: 1st October 2006, 01:32 PM
  4. Redirection of the Favourites Folder
    By wesleyw in forum How do you do....it?
    Replies: 2
    Last Post: 15th January 2006, 10:14 PM
  5. Redirecting Internet Explorer Favourites?
    By Thomas in forum Windows
    Replies: 5
    Last Post: 12th October 2005, 12:02 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •