FN-GM Posted April 14, 2008 Posted April 14, 2008 (edited) 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\CurrentVersion\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 Edited April 14, 2008 by FN-Greatermanchester
ChrisH Posted April 14, 2008 Posted April 14, 2008 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.
FN-GM Posted April 14, 2008 Author Posted April 14, 2008 (edited) But would users have security rights to change registry settings? Edited April 14, 2008 by FN-Greatermanchester
FN-GM Posted April 14, 2008 Author Posted April 14, 2008 using this 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?
ChrisH Posted April 14, 2008 Posted April 14, 2008 (edited) You cant just use an environment variable in VB such as %homedir% you must expand it first. There is a command to do this. Edited April 14, 2008 by ChrisH
fooby Posted April 14, 2008 Posted April 14, 2008 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
FN-GM Posted April 14, 2008 Author Posted April 14, 2008 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. 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
ChrisH Posted April 14, 2008 Posted April 14, 2008 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
srochford Posted April 15, 2008 Posted April 15, 2008 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: 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.
tech-man Posted April 15, 2008 Posted April 15, 2008 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\Explorer\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"
FN-GM Posted April 15, 2008 Author Posted April 15, 2008 Thanks for the feedback will test them tomorrow.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now