FN-GM Posted February 18, 2008 Posted February 18, 2008 (edited) Hi I want to sort our desktop icons by name as default for all our users. At the moment allot of peoples icons are all over the show. How can I achieve this please? Thanks Edited February 18, 2008 by FN-Greatermanchester
Iain Posted February 19, 2008 Posted February 19, 2008 Hi, The settings for desktop icon placement in Windows XP are located in the the HKCU\Software\Microsoft\Windows\Shell\Bags\1\Desktop registry key. This registry key contains a number of values, the most relevant if which are the ItemPos values, the Sort value and the FFlags value. The sort value controls the sort order of the icons (by name, by type, by size etc.), the FFlags value controls the arrangement of the icons (align to grid, auto align etc.) Finally there may be any number of ItemPos values (appended with different screen resolutions eg. ItemPos800x600), which contol the user defined positions of the icons for different screen resolutions. So in order to reset a users desktop layout you would need to remove any ItemPos values and optionally set the FFlags and Sort values depending on your requirements. The following vbs script should achieve this, if it is run as a logon script. (Appologies about the length of the script, but I've added a few comments to try and explain what is going on) ' ===================================== ' ' Script to reset desktop icon layout ' ' ===================================== ' declaire variables before use Option Explicit Dim strComputer, objReg, strKeyPath, arrValueNames, strValueName ' Hex value for HKEY_CURRENT_USER sub-tree Const HKEY_CURRENT_USER = &H80000001 ' Create a registry object for the local computer Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv") ' Set which registry key we want to modify strKeyPath = "Software\Microsoft\Windows\Shell\Bags\1\Desktop" ' First test to see the the registry key exists If KeyExists(objReg,HKEY_CURRENT_USER,strKeyPath) Then ' Delete stored icon positions (ItemPos values) objReg.EnumValues HKEY_CURRENT_USER, strKeyPath, arrValueNames For Each strValueName in arrValueNames If (Left(strValueName,7) = "ItemPos") Then objReg.DeleteValue HKEY_CURRENT_USER, strKeyPath, strValueName End If Next ' Set the icon sort order ' Possible vaules for Sort DWord Value ' dword:0x00000000 = sort by name ' dword:0x00000001 = sort by size ' dword:0x00000002 = sort by type ' dword:0x00000003 = sort by modified strValueName = "Sort" objReg.SetDWORDValue HKEY_CURRENT_USER, strKeyPath, strValueName, &H00000000 ' Set the icon auto arrangement / grid settings ' Possible vaules for FFlags DWord Value ' dword:0x00000220 = Auto Arrange off, Align to Grid off ' dword:0x00000221 = Auto Arrange on ' dword:0x00000224 = Auto Arrange off - align to Grid On ' dword:0x00000225 = Auto Arange on, Align to Grid on ' dword:0x00001220 = Hide Desktop Icons strValueName = "FFlags" objReg.SetDWORDValue HKEY_CURRENT_USER, strKeyPath, strValueName, &H00000224 End If ' Function to test for the existance for a registry key ' - Pointer to a registry object ' - Which subtree to we want to search, ie HLKM, HKCU etc. ' - the registry key we want to search for. ' Returns: True if the registry key exists, False otherwise Private Function KeyExists(objReg, strSubTree, strKeyPath) Dim arrSubKeys, intErr intErr = objReg.EnumKey(strSubTree, strKeyPath, arrSubKeys) If intErr = 0 Then KeyExists = True Else KeyExists = False End If End Function Or I guess you could just delete the whole HKCU\Software\Microsoft\Windows\Shell\Bags\1\Desktop key and then the user should pick up the setting for the default user! Hope that is of some help, Iain. 1
Michael Posted February 19, 2008 Posted February 19, 2008 When I setup/create a standard roaming profile, such as clicking on MS Office, Adobe Reader 8 etc... I always right click the desktop and choose Auto Arrange. This info is then stored in everyone's profile 1
FN-GM Posted February 19, 2008 Author Posted February 19, 2008 I am starting to do the "auto arrange" but we have 500 computers and we se local default profiles. So its allot of work. I will have a try with the script tomorrow (if i get time) Thanks
Michael Posted February 19, 2008 Posted February 19, 2008 I agree that using the script would be more efficient in the circumstances!
FN-GM Posted February 19, 2008 Author Posted February 19, 2008 Yer of course, i am doing it as a do them now.
elsiegee40 Posted February 19, 2008 Posted February 19, 2008 I think I'd be in for all sorts of ear-ache if I tried rearranging people's icons! The pupil desktop has a fixed unchangeable layout, so that doesn't need it. The staff one looks pretty when they logon for the first time, but what they choose to do to it afterwards is their problem.
Oops_my_bad Posted February 19, 2008 Posted February 19, 2008 I'm not sure who's being more anal here to have their icons arranged in such a manner.. the staff or the network admin
mullet_man Posted September 30, 2009 Posted September 30, 2009 Hi, The settings for desktop icon placement in Windows XP are located in the the HKCU\Software\Microsoft\Windows\Shell\Bags\1\Desktop registry key. This registry key contains a number of values, the most relevant if which are the ItemPos values, the Sort value and the FFlags value. The sort value controls the sort order of the icons (by name, by type, by size etc.), the FFlags value controls the arrangement of the icons (align to grid, auto align etc.) Finally there may be any number of ItemPos values (appended with different screen resolutions eg. ItemPos800x600), which contol the user defined positions of the icons for different screen resolutions. So in order to reset a users desktop layout you would need to remove any ItemPos values and optionally set the FFlags and Sort values depending on your requirements. The following vbs script should achieve this, if it is run as a logon script. (Appologies about the length of the script, but I've added a few comments to try and explain what is going on) ' ===================================== ' ' Script to reset desktop icon layout ' ' ===================================== ' declaire variables before use Option Explicit Dim strComputer, objReg, strKeyPath, arrValueNames, strValueName ' Hex value for HKEY_CURRENT_USER sub-tree Const HKEY_CURRENT_USER = &H80000001 ' Create a registry object for the local computer Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv") ' Set which registry key we want to modify strKeyPath = "Software\Microsoft\Windows\Shell\Bags\1\Desktop" ' First test to see the the registry key exists If KeyExists(objReg,HKEY_CURRENT_USER,strKeyPath) Then ' Delete stored icon positions (ItemPos values) objReg.EnumValues HKEY_CURRENT_USER, strKeyPath, arrValueNames For Each strValueName in arrValueNames If (Left(strValueName,7) = "ItemPos") Then objReg.DeleteValue HKEY_CURRENT_USER, strKeyPath, strValueName End If Next ' Set the icon sort order ' Possible vaules for Sort DWord Value ' dword:0x00000000 = sort by name ' dword:0x00000001 = sort by size ' dword:0x00000002 = sort by type ' dword:0x00000003 = sort by modified strValueName = "Sort" objReg.SetDWORDValue HKEY_CURRENT_USER, strKeyPath, strValueName, &H00000000 ' Set the icon auto arrangement / grid settings ' Possible vaules for FFlags DWord Value ' dword:0x00000220 = Auto Arrange off, Align to Grid off ' dword:0x00000221 = Auto Arrange on ' dword:0x00000224 = Auto Arrange off - align to Grid On ' dword:0x00000225 = Auto Arange on, Align to Grid on ' dword:0x00001220 = Hide Desktop Icons strValueName = "FFlags" objReg.SetDWORDValue HKEY_CURRENT_USER, strKeyPath, strValueName, &H00000224 End If ' Function to test for the existance for a registry key ' - Pointer to a registry object ' - Which subtree to we want to search, ie HLKM, HKCU etc. ' - the registry key we want to search for. ' Returns: True if the registry key exists, False otherwise Private Function KeyExists(objReg, strSubTree, strKeyPath) Dim arrSubKeys, intErr intErr = objReg.EnumKey(strSubTree, strKeyPath, arrSubKeys) If intErr = 0 Then KeyExists = True Else KeyExists = False End If End Function Or I guess you could just delete the whole HKCU\Software\Microsoft\Windows\Shell\Bags\1\Desktop key and then the user should pick up the setting for the default user! Hope that is of some help, Iain. Am being stupid, I can't get this to work!! Any ideas?
Csydrsy Posted October 16, 2015 Posted October 16, 2015 I'm having a similar issue with Windows 7. I work for a school district and our elementary school teachers would like all of our computer desktops to be identical to help the students. But the little brats keep moving things around! I would like to logon GPO to organize the desktop icons. I can probably figure out the GPO side of things, but I've tried running the posted script in CMD and it seems to run, but it doesn't change the order of my icons. I have noticed that in the registry, my "Sort" value is of type "REG_BINARY" instead of "REG_DWORD" I'm not sure if that affects anything, but even after deleting "Sort" and making a new REG_DWORD value, upon the next logon, it reverts to BINARY. I am running Windows 7 64-bit, and my target computers are windows 7 32-bit. Also here are Registry values for the Desktop key
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