0

I'm trying to create a batch that will delete an icon from the desktop however its not working could anyone elaborate on this?

del "%userprofile%\Bureaublad\AutoCAD 2006.ico"

Second part of my question, the %userprofile% works fine at work however is this valid with home pc's?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
philip
  • 345
  • 4
  • 5
  • 9

3 Answers3

1

maybe Your script waits the confirmation of deleting file?

try:

echo y | del "%userprofile%\Bureaublad\AutoCAD 2006.ico"
Anton Sizikov
  • 9,105
  • 1
  • 28
  • 39
0

your code should be working wonderfully...do you maybe mean a program link? Then the extension would have to be .lnk ?

so it would be:

   del "%userprofile%\Bureaublad\AutoCAD 2006.lnk"

Should work with any windows Pc - only problem could be UAC with Vista and upwards.

Lorenz
  • 129
  • 1
  • 3
  • 9
0

Well, %userprofile% will get you to the User directory, not the Desktop directory. Try writing something like

del "%userprofile%\Desktop\MyIcon.ico"

Btw, if you by "icon" actually mean the shortcut for the application in question the extension would not be .ico but .lnk

And yes, %userprofile% should work on your home PC as well.

PS: All of the above is assuming that you are using Windows.

pajevic
  • 4,607
  • 4
  • 39
  • 73
  • C:\Documents and Settings\All Users.WINDOWS\Bureaublad dose this make any diffrence becuase all the sugestions are not working for some reason? – philip Feb 07 '11 at 12:28
  • I just made a bat file (c:\test.bat) with the following line: `del "%userprofile%\Desktop\test.lnk"`. When I run it from the Command window I get the following output: `C:\>del "C:\Users\NobleK\Desktop\test.lnk"` and the file test.lnk is deleted from the desktop. Checkk your subdirectories (like Bureaublad). You might also want to give us the entire script and the full path of the file you wish to delete. – pajevic Feb 07 '11 at 12:52