On ZDNet: Top 10 affordable gadgets

Remove desktop icons in preparation for a new app with this member-submitted script

Tags: NETWORKING, desktop, Guest Contributor, new app, Profname, Dan Parr

  • Save
  • Print
  • Recommend
  • 5

Takeaway: TechRepublic asked members to submit their favorite network administration scripts and this is one of the responses. This script will parse through every windows user profile on a machine and delete a specified file from their desktops.

By Dan Parr

TechRepublic recently asked members to submit their favorite Network Administration scripts for possible publication. One of the first to make a submission was Dan Parr. For his effort, Lee earned $100 and the satisfaction of seeing his scripts published on TechRepublic.


Earn $100 for your admin script


Let us pay you for your original scripts so that we can publish them as downloads on TechRepublic and allow your fellow IT professionals to benefit from your scripting savvy. We only ask that you put in the appropriate comments to your scripts so that it's easy to tell what the script is doing and which variables might need to be customized. Send us your original admin scripts and we'll pay you $100 for each one that we publish as a TechRepublic download.


Editor's note: This script is included in the downloadable Zip file for your convenience.

In their own words

Below is a script that I used to remove desktop icons from machines. We had an application that was going offline, in lieu of an alternative. We anticipated some hesitation from the users, but wanted to make sure that they started using the new app before taking it offline. I created this script to remove the old icons so that the users would be forced to move to the new app, but we could leave the old server online until we had ensured that there were no issues with the new app.

It also creates an HTML log file that can be used to view which files were deleted on each machine. We directed this to a network share using the OUTSTORE variable. The outfile is in the format of compname-dd-mm-yyyy.htm.

Listing A

'Remove desktop icon
'Writen by: Dan Parr
'this script will parse through every windows user profile on a machine and delete a specified
'file from the desktops.  Useful if you have a web based application etc. That goes offline and
'you wan to ensure users stop using it to move to your newer alternative app.


'Setup some variables
Dim Shell, FSO, Profname, subdir

'Setup the script Objects
Set Shell = CreateObject("WScript.Shell")
Set FSO = CreateObject("Scripting.FileSystemObject")


'*************************************************
'PROFNAME - FOLDER WHERE PROFILES ARE STORED ON THE MACHINE
WIN2K/XP: C:\DOCUMENTS AND SETTINGS

set Profname = fso.getfolder("C:\documents and settings")
'*************************************************
'*************************************************
'SICON - This is the name of the icon/file you want to
remove(google.url, othericon.lnk etc...)

sicon=""
'*************************************************
'*************************************************
''''        Set Outstore to be equal to the network share where you want
''''        each system to dump their ouput log.  \\servername\share\

OUTSTORE = ""
'************************************************

Dpart=datepart("d",Date)
Mpart=datepart("m",Date)
Ypart=datepart("yyyy",Date)
Fdate= dpart & "-" & Mpart & "-" & Ypart


' Script Objects required for output
Set WshNetwork = WScript.CreateObject("WScript.Network")
Compname = Wshnetwork.Computername
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objNewFile = objFS.CreateTextFile(OUTSTORE & Compname & "-" & Fdate & ".htm")

' last of the variables for output

Delfile = False

objNewFile.WriteLine "<html>"
objNewFile.WriteLine "<head>"
objNewFile.WriteLine "<title>Process Report:" & Compname & "</title>"
objNewFile.WriteLine "</head>"
objNewFile.WriteLine "<body>"
objNewFile.WriteLine "<h1>Process Report <BR>Computer Name: " & Compname & "<BR>Date: " & Now() & _
    "</h1>" & vbCrLf

   
For Each subdir In PROFNAME.SubFolders
       
        Sfldr = subdir.path
        Sdesk = Sfldr & "\desktop"
        Slink = Sdesk & "\" & sicon
        if fso.folderexists(Sdesk) then

               
                If fso.fileexists(Slink) Then
                       
                        objNewFile.WriteLine "Shortcut Exists at:" & Slink & "<BR>"
                           objNewFile.WriteLine _
                               ".............................................. <BR>"
                           objNewFile.WriteLine "<BR>"

                        fso.deletefile Slink
                        objNewFile.WriteLine "Shortcut Deleted:" & Slink & "<BR>"
                        Delfile=True
                Else                 
                end if

       
        Else
        end if
Next
if Delfile = False then
        objNewFile.WriteLine "No Shortcuts Found - No Files Deleted"
End if
  • Save
  • Print
  • Recommend
  • 5

Print/View all Posts Comments on this article

Member-submitted script to remove icons Mark W. KaelinTechrepublic Moderator | 01/20/06
Could this be run remotely? burke.bob@... | 03/13/06

What do you think?

White Papers, Webcasts, and Downloads

Article Categories

Security
Security Solutions, IT Locksmith
Networking and Communications
E-mail Administration NetNote, Cisco Routers and Switches
CIO and IT Management
Project Management, CIO Issues, Strategies that Scale
Desktops, Laptops & OS
Windows 2000 Professional, Microsoft Word, Microsoft Excel, Microsoft Access, Windows XP,
Data Management
Oracle, SQL Server
Servers
Windows NT, Linux NetNote, Windows Server 2003
Career Development
Geek Trivia
Software/Web Development
Web Development Zone, Visual Basic, .NET

SmartPlanet

advertisement
Click Here