[Webinar] Streamline your web hosting managementRegister Today


Deleting desktop shotcuts after login script ran

Posted on 2008-02-10
Medium Priority
Last Modified: 2010-05-18
Hi Guys,

I use Win XP Pro (SP 2).

When I log into my company's domain, the login script places approx. 15 shortcut icons on my desktop (which includes shortcuts to MS office, several network resources and even Windows Media player).

I never us any of these and it just clutters up my desktop.

The sysadmins can't remove this from the login script, as some employees use them.

Is it possible to place a script in the Start up Folder, which will run after the login script has executed, which will delete the icons from my desktop?

What would this "clean-up" script contain?

Thank you.

Question by:m0nk3yza
LVL 31

Expert Comment

ID: 20864525
You could make a .BAT file that deletes the shortcuts. The code would be something like:

@echo off
del "%userprofile%\desktop\Microsoft Office Word 2003.lnk"
del "%userprofile%\desktop\Some other icon.lnk"
del "%userprofile%\desktop\Some network resource.lnk"

And drop that into your startup folder. You'd need to make sure this got executed AFTER the logon script from your domain got executed (otherwise the icons wouldn't have arrived yet!). If it's always getting executed first... you can just put the file on your desktop and doubleclick it when your system has loaded.

Shortcuts on your desktop are just ".lnk" files, where the name of the file is the caption on the icon


Expert Comment

ID: 20864529
write in Notepad the snippet and save it as .BAT or .CMD file.
Copy it onto your Start Up menu and that is all done.
@echo off
DEL /F "%USERPROFILE%\Desktop\office*.lnk"
DEL /F "%USERPROFILE%\Desktop\any other file.txt"

Open in new window


Expert Comment

ID: 20864553
It should be possible to do so, or atleast you could put a registry string in your registry database, to startup with windows.

You should make a .bat script, with something like this:

Delete c:\documents and settings\[Your account]\Desktop\[filename]

Then put in one line for each file.

Then go to start > run, and type regedit, and go to the following:

Make a new key with the type "REG_SZ" and value should be the path to the .bat file you just made.

Hope that can help you, and will work for you.
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!


Author Comment

ID: 20864923
Hi Guys,

Thanks for the response.

The login script seems to be executed after this .BAT file.

So the shortcuts are deleted, then recreated by the login script.

Any ideas on how to delay the execution on the .BAT file?

Thank you.

LVL 31

Assisted Solution

Frosty555 earned 600 total points
ID: 20868662
You could make the bat file pause for a few seconds before performing the delete operation, giving the icons time to be created.

Unfortunately .BAT don't have any intrinsic wait commands. There used to be a TIMEOUT command but I don't see it anymore.

But there's a workaround! You can use "Ping" to ping a nonexistant IP address with a specific timeout delay ;)

To wait four seconds:

ECHO Waiting for four seconds...
PING -w 4000 -n 1 >nul  

Accepted Solution

stopReplying earned 1400 total points
ID: 20873566
like my fellow expert has mentioned you could ping a non existing IP address.
you can modify it depending on how much time you need.
1 failed ping response = 4 seconds
so you can do the following:

in the code "PING -w 4000 -n 3 >nul" you can substitute the number 3 with as many you need. (3 meaning the number of times PING packages are being sent) and also the wait time (-w 4000, meaning "wait 4000 milliseconds before sending another package).

another thing: it is important to put the path in quotes, or it will not be recognized, due to spaces in the path.
Good Luck
@echo off
echo waiting...
PING -w 4000 -n 3 >nul
echo erasing... 
DEL /F "%USERPROFILE%\Desktop\Microsoft*.lnk"
DEL /F "%USERPROFILE%\Desktop\any other file.txt"

Open in new window


Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We have adopted the strategy to use Computers in Student Labs as the bulletin boards. The same target can be achieved by using a Login Notice feature in Group policy but it’s not as attractive as graphical wallpapers with message which grabs the att…
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
There may be issues when you are trying to access Outlook or send & receive emails or due to Outlook crash which leads to corrupt or damaged PST file. To eliminate the corruption from your PST file, you need to repair the corrupt Outlook PST file. U…

613 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question