+ Post New Thread
Page 3 of 3 FirstFirst 123
Results 31 to 40 of 40
How do you do....it? Thread, How do you do your start menus. in Technical; Originally Posted by jcs808 Attachment 10080 You've got a spelling error in 'Macromedia Studio MX 2004' before some know it ...
  1. #31
    Freedom's Avatar
    Join Date
    Feb 2007
    Location
    England - Midlands
    Posts
    42
    Thank Post
    6
    Thanked 5 Times in 4 Posts
    Rep Power
    16
    Quote Originally Posted by jcs808 View Post
    You've got a spelling error in 'Macromedia Studio MX 2004' before some know it all kid spots it

    On another note I really need to do this to our network so when I get a chance I will start playing with the code you guys have already posted . Thanks for it!

  2. Thanks to Freedom from:

    jcs808 (17th May 2011)

  3. #32

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,823
    Thank Post
    875
    Thanked 1,675 Times in 1,458 Posts
    Blog Entries
    12
    Rep Power
    444
    Quote Originally Posted by AlexB View Post
    It would work best when run after the batch file.
    Both Work a treat thanks

  4. #33

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,823
    Thank Post
    875
    Thanked 1,675 Times in 1,458 Posts
    Blog Entries
    12
    Rep Power
    444
    Quote Originally Posted by AlexB View Post
    It would work best when run after the batch file.
    Daft question, how would i call the VBS script from the batch file please? Everywhere i put the line it doesnt seem to run

    Thanks

  5. #34
    AlexB's Avatar
    Join Date
    Jul 2006
    Location
    Warwickshire
    Posts
    365
    Thank Post
    36
    Thanked 36 Times in 32 Posts
    Rep Power
    23
    I believe cscript is the correct way to call vb scripts.

    You might also want to take a look at another very similar post. The tidy up script is a lot more fleshed out than the one above I wrote quickly at home the other day, but it does look rather similar

  6. #35

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,823
    Thank Post
    875
    Thanked 1,675 Times in 1,458 Posts
    Blog Entries
    12
    Rep Power
    444
    Quote Originally Posted by AlexB View Post
    I believe cscript is the correct way to call vb scripts.

    You might also want to take a look at another very similar post. The tidy up script is a lot more fleshed out than the one above I wrote quickly at home the other day, but it does look rather similar
    cheers will have a look.

  7. #36

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,823
    Thank Post
    875
    Thanked 1,675 Times in 1,458 Posts
    Blog Entries
    12
    Rep Power
    444
    Quote Originally Posted by AlexB View Post
    Bah, what can I say, the idea intrigued me!

    Anyway, this script will parse through the location defined in objStartFolder and look for any shortcuts pointing to locations beginning with sTargetStart and if they don't point to anything valid it deletes them. Afterwards it goes through and looks for empty folders and removes them too.

    As it is set atm it looks in "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Applications" (After first checking it exists) for any shortcuts (.lnk) that point to a target starting with "C:\" and removes it if the target doesn't exist.

    I've hacked this together quite quickly, so don't expect anything pretty
    Code:
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set oShell = CreateObject("WScript.Shell")
    objStartFolder = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Applications"
    sTargetStart = "C:\"
    
    If objFSO.FolderExists(objStartFolder) Then
    
    	' Check for invalid shortcuts pointing to locations starting with sTargetStart
    	Set objFolder = objFSO.GetFolder(objStartFolder)
    	Set colFiles = objFolder.Files
    	For Each objFile in colFiles
    		CheckValid objFile
    	Next
    	 
    	CheckSubFoldersShortcuts objFSO.GetFolder(objStartFolder)
    
    
    	' Check for empty folders after clearing out invalid shortcuts
    	CheckSubFoldersEmptyAndRemove objFSO.GetFolder(objStartFolder)
    	
    Else
    	'msgbox objStartFolder & " does not exist"
    	
    End If
    
    
    
    
    Sub CheckSubFoldersEmptyAndRemove(Folder)
        For Each Subfolder in Folder.SubFolders
            Set objFolder = objFSO.GetFolder(Subfolder.Path)
    		
    		If FolderEmpty(Subfolder.Path) Then
    			'msgbox "delete " & Subfolder.Path
    			objFSO.DeleteFolder Subfolder.Path
    		Else 
    			'msgbox Subfolder.Path & " is occupied"
    			CheckSubFoldersEmptyAndRemove Subfolder
    		End If
        Next
    End Sub
    
    
    Sub CheckSubFoldersShortcuts(Folder)
        For Each Subfolder in Folder.SubFolders
            Set objFolder = objFSO.GetFolder(Subfolder.Path)
            Set colFiles = objFolder.Files
            For Each objFile in colFiles
    			CheckValid objFile
            Next
            CheckSubFoldersShortcuts Subfolder
        Next
    End Sub
    
    
    Sub CheckValid(objCheckFile)
    	If LCase(objFSO.GetExtensionName(objCheckFile.name)) = "lnk" Then
    		
    		Set oLnk = oShell.CreateShortcut(objCheckFile.path)
    		'msgbox objCheckFile.Path
    		'msgbox oLnk.TargetPath
    		
    		If StrComp(LCase(Left(oLnk.TargetPath,Len(sTargetStart))),LCase(sTargetStart))  = 0 Then
    			If objFSO.FileExists(oLnk.TargetPath) Then
    				'msgbox objCheckFile.path & " is a valid shortcut"
    			Else
    				'msgbox objCheckFile.path & " is an invalid shortcut"
    				objFSO.DeleteFile objCheckFile.path
    			End If
    		Else
    			'msgbox "Not local shortcut"
    		End If
    	End If
    	
    End Sub
    
    
    Function FolderEmpty(strFolderPathName)
    	Dim oFiles, oFile, oFolder, oSubFolders, oSubFolder
    	Dim blnFileFound : blnFileFound = False
    	Set oFolder = objFSO.GetFolder(strFolderPathName)
    	Set oFiles = oFolder.Files
    	If oFiles.Count > 1 Then
    		FolderEmpty = False
    		Exit Function
    	ElseIf oFiles.Count = 1 Then
    		For Each oFile In oFiles 
    			If oFile.Name <> "desktop.ini" Then
    				FolderEmpty = False
    				Exit Function
    			End If
    		Next
    	End If
    	Set oSubFolders = oFolder.SubFolders
    	For Each oSubFolder In oSubFolders
    		If Not FolderEmpty(oSubFolder.Path) Then
    			FolderEmpty = False
    			Exit Function
    		End If
    	Next
    	FolderEmpty = True
    End Function
    I know my original script was batch, but I didn't think I could do this with batch, so vbs will have to do
    Every now and then the script is erroring throwing up access denied. It is then not deleting folders automatically. if i delete them manually its fine. Any thoughts please?

  8. #37

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,689
    Thank Post
    334
    Thanked 515 Times in 483 Posts
    Rep Power
    179
    Quote Originally Posted by FN-GM View Post
    Every now and then the script is erroring throwing up access denied. It is then not deleting folders automatically. if i delete them manually its fine. Any thoughts please?
    Any chance of getting the full error (or line), and/or files it fails on? :P

    And by any chance is the full filename over 250 chars long? If so you'd need to force it to be a shortpath.

    One thing I noticed aswell, if you're only having problems on a few files

    Code:
    objFSO.DeleteFolder Subfolder.Path
    Is going to fail on read-only files, You'll need to do a force delete aka

    Code:
    objFSO.DeleteFolder Subfolder.Path,True
    Might be worth trying that.

    Other options although I haven't checked all of it yet, is your script is modifying/opening a file when it's running. Thus locking it. If the above doesn't work, shout and I'll check rest.

    Steve

  9. Thanks to Steve21 from:

    FN-GM (19th May 2011)

  10. #38

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,823
    Thank Post
    875
    Thanked 1,675 Times in 1,458 Posts
    Blog Entries
    12
    Rep Power
    444
    objFSO.DeleteFolder Subfolder.Path,True
    That did the trick.

    Thanks

  11. #39

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,823
    Thank Post
    875
    Thanked 1,675 Times in 1,458 Posts
    Blog Entries
    12
    Rep Power
    444
    Hi Guys,

    For network applications where do you put the shortcuts? If i put them in a redirected folder on the C Drive, when a laptop is taken home the start menu will freeze because the shortcuts lead to a path that the machine can't contact.

    How would you deal with it?

    Thanks

  12. #40
    AlexB's Avatar
    Join Date
    Jul 2006
    Location
    Warwickshire
    Posts
    365
    Thank Post
    36
    Thanked 36 Times in 32 Posts
    Rep Power
    23
    Quote Originally Posted by FN-GM View Post
    Hi Guys,

    For network applications where do you put the shortcuts? If i put them in a redirected folder on the C Drive, when a laptop is taken home the start menu will freeze because the shortcuts lead to a path that the machine can't contact.

    How would you deal with it?

    Thanks
    Hi @FN-GM

    We sync (one way sync) our P drive to all staff laptops so that these network apps are available at home. (P drive is the mapped drive to the network apps share)

SHARE:
+ Post New Thread
Page 3 of 3 FirstFirst 123

Similar Threads

  1. Replies: 4
    Last Post: 10th December 2010, 09:51 AM
  2. Custom Start Menus on a per room basis.
    By Disease in forum Windows Server 2000/2003
    Replies: 10
    Last Post: 10th September 2009, 08:35 PM
  3. Graphics output/have 2 start menus
    By andy_d in forum Windows
    Replies: 5
    Last Post: 24th March 2009, 09:21 AM
  4. Start menu/Office menus do not expand
    By meastaugh1 in forum Windows
    Replies: 1
    Last Post: 9th January 2008, 08:52 PM
  5. Start Menus home folder load balancing.
    By Teth in forum How do you do....it?
    Replies: 6
    Last Post: 1st November 2006, 04:49 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
  •