Page 1 of 1 1
Topic Options
#200305 - 2010-10-19 06:07 PM deleting icons
hinote Offline
Just in Town

Registered: 2010-02-15
Posts: 2
Loc: jefferson iowa
I have a VB script that searches all userprofiles to delete shortcuts to old programs based on target path. Our logon script was written before I got here and it is in Kix. I was wondering if someone could help rewrite my script into KIX so I don't have to call it from the kix script. I have added the vbscript.

 Code:
Dim objShell, objFSO, sonicPath, fileFolder
Dim userFolder, desktopFolder, custFolder, extension
Dim fullname, shortcut, shortTarget

paragonPath = "C:\Program Files\Paragon93\"

Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")

Set fileFolder = objFSO.GetFolder("C:\Documents and Settings")
Set subFileFolder = fileFolder.Subfolders

For Each userFolder in subFileFolder    
	If objFSO.FolderExists(userFolder & "\Desktop") Then        
		Set desktopFolder = objFSO.GetFolder(userFolder & "\Desktop")        
		Set custFolder = desktopFolder.Files        

		For Each custFile in custFolder            
			extension = objFSO.GetExtensionName(LCase(custFile.name))            
			If extension = "lnk" then                
				'Find full path of shortcut                
				fullname = objFSO.GetAbsolutePathName(custFile)                

				'Find full path of target within shortcut                
				'See http://www.devguru.com/Technologies/wsh/quickref/wshshell_CreateShortcut.html                
				'for more information on how this works.                
				Set shortcut = objShell.CreateShortcut(fullname)                
				shortTarget = shortcut.TargetPath                    

				If InStr(shortTarget, paragonPath) then                    
					Dim myFileToDelete                    
					Set myFileToDelete = objFSO.GetFile(fullname)                    
					myFileToDelete.Delete                
				End If            
			End If        
		Next    
	End If
Next


Attachments
icon.txt (176 downloads)
Description:




Edited by Mart (2010-10-19 07:12 PM)
Edit Reason: Inserted the code from the txt attachment.

Top
#200306 - 2010-10-19 06:27 PM Re: deleting icons [Re: hinote]
cjutting Offline
Fresh Scripter

Registered: 2010-02-05
Posts: 40
Loc: IA
Sorry I Won't be of any help but I know the author of your logon script ;\)
Top
#200309 - 2010-10-19 10:47 PM Re: deleting icons [Re: cjutting]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
Here you go:
 Code:
Dim $objShell, $objFSO, $sonicPath, $fileFolder
Dim $userFolder, $desktopFolder, $custFolder, $extension
Dim $fullname, $shortcut, $shortTarget

$paragonPath = "C:\Program Files\Paragon93\"

$objShell = CreateObject("WScript.Shell")
$objFSO = CreateObject("Scripting.FileSystemObject")

$fileFolder = $objFSO.GetFolder("C:\Documents and Settings")
$subFileFolder = $fileFolder.Subfolders

For Each $userFolder in $subFileFolder
  If $objFSO.FolderExists($userFolder + "\Desktop")
    $desktopFolder = $objFSO.GetFolder($userFolder + "\Desktop")
    $custFolder = $desktopFolder.Files
    For Each $custFile in $custFolder
      $extension = $objFSO.GetExtensionName(LCase($custFile.name))
      If $extension = "lnk"
        ;Find full path of shortcut
        $fullname = $objFSO.GetAbsolutePathName($custFile)
        ;Find full path of target within shortcut
        ;See http://www.devguru.com/Technologies/wsh/quickref/wshshell_CreateShortcut.html
        ;for more information on how this works.
        $shortcut = $objShell.CreateShortcut($fullname)
        $shortTarget = $shortcut.TargetPath
        If InStr($shortTarget, $paragonPath)
          Dim $myFileToDelete
          $myFileToDelete = $objFSO.GetFile($fullname)
          $myFileToDelete.Delete
        EndIf
      EndIf
    Next
  EndIf
Next

Top
#200317 - 2010-10-20 02:24 PM Re: deleting icons [Re: Arend_]
hinote Offline
Just in Town

Registered: 2010-02-15
Posts: 2
Loc: jefferson iowa
Thank you so much. I will give it a try and see what happens.
Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2924 anonymous users online.
Newest Members
batdk82, StuTheCoder, M_Moore, BeeEm, min_seow
17885 Registered Users

Generated in 0.067 seconds in which 0.037 seconds were spent on a total of 14 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org