+ Post New Thread
Results 1 to 9 of 9
Windows Thread, Sort desktop icons by name - Windows XP in Technical; Hi I want to sort our desktop icons by name as default for all our users. At the moment allot ...
  1. #1

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    16,374
    Thank Post
    906
    Thanked 1,811 Times in 1,559 Posts
    Blog Entries
    12
    Rep Power
    468

    Sort desktop icons by name - Windows XP

    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
    Last edited by FN-GM; 19th February 2008 at 12:06 AM.

  2. #2
    Iain's Avatar
    Join Date
    Oct 2006
    Location
    Warwickshire
    Posts
    197
    Thank Post
    28
    Thanked 98 Times in 56 Posts
    Rep Power
    36
    Hi,

    The settings for desktop icon placement in Windows XP are located in the the HKCU\Software\Microsoft\Windows\Shell\Bags\1\Deskt op registry key.

    This registry key contains a number of values, the most relevant if which are the ItemPos<screenresolution> 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)

    Code:
    ' =====================================
    ' 
    '  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
    ' <objReg> - Pointer to a registry object
    ' <strSubTree> - Which subtree to we want to search, ie HLKM, HKCU etc.
    ' <strKeyPath> - the registry key we want to search for.
    ' Returns: True if the <strKeyPath> 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\Deskt op key and then the user should pick up the setting for the default user!

    Hope that is of some help,

    Iain.

  3. Thanks to Iain from:

    FN-GM (19th February 2008)

  4. #3

    Michael's Avatar
    Join Date
    Dec 2005
    Location
    Birmingham
    Posts
    9,345
    Thank Post
    242
    Thanked 1,602 Times in 1,278 Posts
    Rep Power
    346
    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

  5. Thanks to Michael from:

    FN-GM (19th February 2008)

  6. #4

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    16,374
    Thank Post
    906
    Thanked 1,811 Times in 1,559 Posts
    Blog Entries
    12
    Rep Power
    468
    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

  7. #5

    Michael's Avatar
    Join Date
    Dec 2005
    Location
    Birmingham
    Posts
    9,345
    Thank Post
    242
    Thanked 1,602 Times in 1,278 Posts
    Rep Power
    346
    I agree that using the script would be more efficient in the circumstances!

  8. #6

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    16,374
    Thank Post
    906
    Thanked 1,811 Times in 1,559 Posts
    Blog Entries
    12
    Rep Power
    468
    Yer of course, i am doing it as a do them now.

  9. #7

    elsiegee40's Avatar
    Join Date
    Jan 2007
    Location
    Kent
    Posts
    10,225
    Thank Post
    1,926
    Thanked 2,425 Times in 1,775 Posts
    Rep Power
    842
    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.

  10. #8
    Oops_my_bad's Avatar
    Join Date
    Jan 2007
    Location
    Man chest hair
    Posts
    1,738
    Thank Post
    438
    Thanked 53 Times in 50 Posts
    Rep Power
    31
    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

  11. #9
    mullet_man's Avatar
    Join Date
    Oct 2005
    Location
    Oldham
    Posts
    740
    Thank Post
    35
    Thanked 48 Times in 46 Posts
    Rep Power
    28
    Quote Originally Posted by Iain View Post
    Hi,

    The settings for desktop icon placement in Windows XP are located in the the HKCU\Software\Microsoft\Windows\Shell\Bags\1\Deskt op registry key.

    This registry key contains a number of values, the most relevant if which are the ItemPos<screenresolution> 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)

    Code:
    ' =====================================
    ' 
    '  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
    ' <objReg> - Pointer to a registry object
    ' <strSubTree> - Which subtree to we want to search, ie HLKM, HKCU etc.
    ' <strKeyPath> - the registry key we want to search for.
    ' Returns: True if the <strKeyPath> 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\Deskt op 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?



SHARE:
+ Post New Thread

Similar Threads

  1. desktop icons via gpo
    By goodhead in forum Windows
    Replies: 8
    Last Post: 2nd November 2011, 12:12 AM
  2. Ranger not displaying Desktop icons, taskbar.......
    By mar5hy in forum Network and Classroom Management
    Replies: 10
    Last Post: 16th January 2008, 11:29 AM
  3. desktop icons
    By Danielstaunton in forum Learning Network Manager
    Replies: 4
    Last Post: 21st September 2007, 10:40 PM
  4. Replies: 12
    Last Post: 6th December 2006, 11:26 AM

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
  •