Jump to content

Cleanup.cmd issue suggestions please


Recommended Posts

I am calling my Cleanup.cmd from the Apps directory as final entry in my RunOnceEx.cmd as per standard procedure. Problem is the old one of not all desktop shortcuts being deleted. After searching, and wading through 100's of threads, which suggest "this code" and "that code" as the problem I have drawn the conclusion that this isn't the case as I have manually/individually tested the syntaxes and ALL work manually - but only half work and half dont with identical syntax/paths when called from RunOnceEx.

The problem is = the command must be executing as the shortcuts are appearing and as such the code runs faster than the desktop is refreshing itself and therefore "misses" deleting some.

So the answer is a delay on the cleanup.cmd so it doesn't start to delete until all the shortcuts are in place - but I don't know how to implement this. Can some kind soul assist?

EDIT: Basically all I'm trying to do in effect is totally clear the Desktop of all shortcuts except the Recycle Bin.

Link to comment
Share on other sites


if you are using runonceex...then there couldnt possibly be any shortcuts "being created" unless you install something that installs a shortcut during your cleanup.cmd...which shouldnt be the case, since this is your cleanup...and as for the desktop refreshing...the del command does it by command window, and not technically through the gui...what i mean is the desktop refresh would only have a problem if del was manually going over to the shortcut and deleting it...but its not cuz thats not how it works...i honestly dont know why yours doesnt work, mine works fine...are you deleting the shortcuts from your userprofile and the alluserprofile? because some shortcuts gets placed there too.

Link to comment
Share on other sites

@evilvoice

For example to get rid of the 2 Adaware Pro created desktop shortcuts I use:

del /q "%allusersprofile%\Desktop\AdAware SE Professional.Lnk"
del /q "%allusersprofile%\Desktop\Ad-Watch SE Professional.Lnk"

and the first one gets deleted but the 2nd one doesn't!

@gunsmokingman, thanks for reply I am investigating your link now.

Link to comment
Share on other sites

@evilvoice

For example to get rid of the 2 Adaware Pro created desktop shortcuts I use:

del /q "%allusersprofile%\Desktop\AdAware SE Professional.Lnk"
del /q "%allusersprofile%\Desktop\Ad-Watch SE Professional.Lnk"

and the first one gets deleted but the 2nd one doesn't!

@gunsmokingman, thanks for reply I am investigating your link now.

try switching the ad-watch line to %userprofile%...

those shortcuts like to hide themselves in all sorts of places :realmad:

Link to comment
Share on other sites

@bacd = I will try that shortly and post results.

@gunsmokingman = wow dude, thats way too difficult for me. I've never had any dealing with vbs scripts and even though I can grab the gist of the instructions I wouldn't know where to put the script or even how to call it as there's no mention of vbs implementation on the msfn.org unattended site. Good post though.

Basically all I'm trying to do in effect is totally clear the Desktop of all shortcuts except the Recycle Bin.

There must be a simple way of doing that. I have even used this and this doesn't work either:

del /q "%allusersprofile%\Desktop\*.Lnk"
del /q "%allusersprofile%\Desktop\?.Lnk"

Link to comment
Share on other sites

I give you my script it works fine to delete icons and quicklaunchs icons.

If your native language has accents here's is the solution : in a dos windows type dir /X and you will see the 8 characters name. Exemple : you want to del "Sauvegarder et éteindre.lnk" becomes "Sauveg~1.lnk".

Have fun deleting Icons and quicklaunchs icons.

Del "%AllUsersProfile%\Bureau\CloneCD.lnk"
del "%AllUsersProfile%\Bureau\DAEMON Tools.lnk"
Del "%AllUsersProfile%\Bureau\Mozilla Firefox.lnk"
Del "%AllUsersProfile%\Bureau\Nero StartSmart.lnk"
Del "%UserProfile%\Bureau\Opera.lnk"
Del "%UserProfile%\Bureau\Ultr@VNC Viewer.lnk"
Del "%UserProfile%\Bureau\Ultr@VNC Server.lnk"
Del "%UserProfile%\Bureau\Serv-U.lnk"
Del "%UserProfile%\Bureau\Maxthon.lnk"
Del "%UserProfile%\Bureau\Ultr@VNC Repeater.lnk"
Del "%UserProfile%\Bureau\UltraBackup.lnk"
Del "%UserProfile%\Bureau\DVD Shrink 3.2.lnk"
Del "%UserProfile%\Bureau\TVTAD.lnk"
Del "%UserProfile%\Bureau\Spybot - Search & Destroy.lnk"
Del "%UserProfile%\Bureau\CCleaner.lnk"
Del "%UserProfile%\Bureau\BSplayer.lnk"
Del "%UserProfile%\Bureau\BitComet.lnk"
Del "%UserProfile%\Bureau\Ad-Watch SE Professional.lnk"
Del "%UserProfile%\Bureau\Ad-Aware SE Professional.lnk"
Del "%UserProfile%\Bureau\Sauveg~1.lnk"
Del "%UserProfile%\Application Data\Microsoft\Internet Explorer\Quick Launch\Ad-Aware SE Professional.lnk"
Del "%UserProfile%\Application Data\Microsoft\Internet Explorer\Quick Launch\Ad-Watch SE Professional.lnk"
Del "%UserProfile%\Application Data\Microsoft\Internet Explorer\Quick Launch\Mozilla Firefox.lnk"
Del "%UserProfile%\Application Data\Microsoft\Internet Explorer\Quick Launch\Winamp.lnk"
Del "%UserProfile%\Application Data\Microsoft\Internet Explorer\Quick Launch\Opera.lnk"
Del "%UserProfile%\Application Data\Microsoft\Internet Explorer\Quick Launch\Nero StartSmart.lnk"
Del "%UserProfile%\Application Data\Microsoft\Internet Explorer\Quick Launch\Spybot - Search & Destroy.lnk"

Link to comment
Share on other sites

The problem is usually because the shortcuts can be located on one of many desktops!

Here is a simple piece of code to go into your batch that will remove All Desktop shortcuts (*.lnk)

for /d %%a in ("%AllUsersProfile:\All Users=%\*") do if exist "%%~a\Desktop\*" del /q "%%~a\Desktop\*.lnk"

To test it first on your existing installation, to see what would be removed, nothing will be, open a cmd prompt and type or paste the following single line into it

@echo off &&for /d %a in ("%AllUsersProfile:\All Users=%\*") do if exist "%~a\Desktop\*" echo Cleaning shortcuts from the "%~na Desktop" &&@echo del /q "%~a\Desktop\*.lnk"

Link to comment
Share on other sites

Basically I'm expanding %ALLUSERSPROFILE% i.e Drive:\Documents and Settings\All Users and replacing \All Users with nothing, thus making Drive:\Documents and Settings. This way you can use the location of Documents and Settings without the need for knowing which drive it is installed on!

Cool eh! :P

<Edit>

The other benefit is that if someone has for instance renamed the Profiles directory in their winnt.sif file to for example

[GuiUnattended]
   ProfilesDir = "E:\Profile Settings\"

this code will automatically remove the shortcuts from, for example, E:\Profile Settings\Big John\Desktop and E:\Profile Settings\All Users\Desktop and E:\Profile Settings\Administrator\Desktop and E:\Profile Settings\Default User\Desktop etc.

</Edit>

Edited by Yzöwl
Link to comment
Share on other sites

@Yzowl

for /d %%a in ("%AllUsersProfile:\All Users=%\*") do if exist "%%~a\Desktop\*" del /q "%%~a\Desktop\*.lnk"

:thumbup You have done it! This code works faultlessly. All Desktop shortcuts deleted. Many thanks. :thumbup

@evilvoice

Now how the hell does that work

Doesn't matter, it just does. Respect to the coder Yzowl. :D

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...