amd64 Posted January 30, 2007 Share Posted January 30, 2007 hi peeps,i have tried to delete a .lnk file in:C:\Documents and Settings\Default User\Start Menu\Programs\some program\some program.lnki'm using a cmd batch file to do thisi have tried several combanation but its not working.DEL /Q /F "C:\Documents and Settings\Default User\Start Menu\Programs\some program\some program.lnk"DEL /Q /F "%Systemsdrive%\Documents and Settings\Default User\Start Menu\Programs\some program\some program.lnk"DEL /Q /F "%DEFAULTUSERPROFILE%\Start Menu\Programs\some program\some program.lnk"DEL /Q /F "%CSIDL_DEFAULT_PROGRAMS%\some program\some program.lnk"what am i doing wrong?regards, amd64 Link to comment Share on other sites More sharing options...
mywindow Posted January 30, 2007 Share Posted January 30, 2007 It depends on where the link is located? All Users Profile == "%ALLUSERSPROFILE%\Start Menu\Programs\App_Name\App.lnk" Users Profile == "%USERPROFILE%\Start Menu\Programs\App_Name\App.lnk"Here is the commands I would use in a batch file to remove a shortcut.@ECHO OFFIF /i EXIST "%ALLUSERSPROFILE%\Start Menu\Programs\App_Name\App.lnk" DEL /F /Q "%ALLUSERSPROFILE%\Start Menu\Programs\App_Name\App.lnk"IF /i EXIST "%USERPROFILE%\Start Menu\Programs\App_Name\App.lnk" DEL /F /Q "%USERPROFILE%\Start Menu\Programs\App_Name\App.lnk"EXITNotice the quotes? Since we are not dealing with 8.3 names.For help with windows commands and batch files you should install "Windows Support Tools" This should be located on the cd and is available from MS. Link to comment Share on other sites More sharing options...
f5ferrari Posted January 30, 2007 Share Posted January 30, 2007 Hey AMD64Don't know if it is a typo but the variable for the root drive is %systemdrive%..If you want a list of all the active variables type SET into cmd, hope that helps. Link to comment Share on other sites More sharing options...
Yzöwl Posted January 30, 2007 Share Posted January 30, 2007 Well the first thing you need to know is what the switches are that you are /not using for the DEL command.For instance...Why are you using the /Q switch?It is not needed or used at all in your case!Have you thought about typing DEL /? inside the console, for information which may help solve your problem.You could also try this!2>NUL DEL/F/A "%ALLUSERSPROFILE%\..\Default User\Start Menu\Programs\some program\some program.lnk" Link to comment Share on other sites More sharing options...
legionaire Posted January 30, 2007 Share Posted January 30, 2007 (edited) Hey Yzowl,Could you please explain just what this "2>NUL" command is? I've tried "1>NUL" and got an error message - the help switch didn't provide any enlightenment either...so please elaborate: Is this a DOS or CMD Shell command and why the heck does it use "2"? Are there any more of these?Edit: OK, I was able to answer this one myself - it appears as though "2>" stands for "redirect everything that's to the left of the '2' character". Probably "2" was intended to be an abbreviation for "to", further emphasizing the prospect of redirection. Edited January 30, 2007 by legionaire Link to comment Share on other sites More sharing options...
Yzöwl Posted January 30, 2007 Share Posted January 30, 2007 Simply, >NUL or more correctly 1>NUL redirects STDOUT (your standard output) to NUL (a non-existant location) this prevents the output from showing in your console.2>NUL on the other hand does the same thing only this time with STDERR (standard error output).In the case above, what it actually does is prevents a message showing if the file cannot be found for instance. It could I suppose be seen as a lazy way of doing this:IF EXIST "%ALLUSERSPROFILE%\..\Default User\Start Menu\Programs\some program\some program.lnk" DEL/F/A "%ALLUSERSPROFILE%\..\Default User\Start Menu\Programs\some program\some program.lnk"The NUL redirection can be place at the beginning of the command line or more commonly at the end. Link to comment Share on other sites More sharing options...
amd64 Posted January 30, 2007 Author Share Posted January 30, 2007 (edited) thanks peeps ,,, but its the %DEFAULTUSERPROFILE% (hidden systems) that the app is in. i have no problems with the ALLUSERSPROFILE.oooh and the Q/ = do not prompt to delete ,,, and the /F = force deletion Edited January 30, 2007 by amd64 Link to comment Share on other sites More sharing options...
Yzöwl Posted January 30, 2007 Share Posted January 30, 2007 Okay, what are you reading for /Q when you type DEL /?, because I seem to recall it mentioning somewhere 'global wildcards', which yours doesn't have!Also nevermind 'half-reading' my response, try the command I gave you and report back. Link to comment Share on other sites More sharing options...
amd64 Posted January 31, 2007 Author Share Posted January 31, 2007 hi Yzowl,i have tried as you asked, but the code still does not work.here is my cleanup.cmd for you to have a look at,cmdow @ /HID@Echo OffIF EXIST D:\CDROM.txt set CDROM=D:IF EXIST E:\CDROM.txt set CDROM=E:IF EXIST F:\CDROM.txt set CDROM=F:IF EXIST G:\CDROM.txt set CDROM=G:IF EXIST H:\CDROM.txt set CDROM=H:IF EXIST I:\CDROM.txt set CDROM=I:IF EXIST J:\CDROM.txt set CDROM=J:XCOPY /Q "%CDROM%\XTRS\Show Desktop.scf" "%USERPROFILE%\Application Data\Microsoft\Internet Explorer\Quick Launch\" /YMKDIR "%ALLUSERSPROFILE%\Start Menu\Programs\Audacity\"XCOPY /Q "%ALLUSERSPROFILE%\Start Menu\Programs\Audacity.lnk" "%ALLUSERSPROFILE%\Start Menu\Programs\Audacity\" /YDEL /Q /F "%DEFAULTUSERPROFILE%\Start Menu\Programs\CyberLink PowerDVD\Online registration.lnk"DEL /Q /F "%DEFAULTUSERPROFILE%\Start Menu\Programs\CyberLink PowerDVD\Uninstall PowerDVD.lnk"DEL /Q /F "%DEFAULTUSERPROFILE%\Start Menu\Programs\CyberLink PowerDVD\System Diagnosis.lnk"DEL /Q /F "%DEFAULTUSERPROFILE%\Start Menu\Programs\CyberLink PowerDVD\PowerDVD Help file.lnk"DEL /Q /F "%ALLUSERSPROFILE%\Desktop\Java Web Start.lnk"DEL /Q /F "%ALLUSERSPROFILE%\Desktop\Mozilla Firefox.lnk"DEL /Q /F "%ALLUSERSPROFILE%\Desktop\AntiVir PE Classic.lnk"DEL /Q /F "%ALLUSERSPROFILE%\Start Menu\Microsoft Update.lnk"DEL /Q /F "%ALLUSERSPROFILE%\Start Menu\Set Program Access and Defaults.lnk"DEL /Q /F "%ALLUSERSPROFILE%\Start Menu\Programs\Audacity.lnk"DEL /Q /F "%USERPROFILE%\Desktop\CyberLink PowerDVD.lnk"DEL /Q /F "%USERPROFILE%\Desktop\RightMark CPU Clock Utility.lnk"DEL /Q /F "%USERPROFILE%\Desktop\Audacity.lnk"DEL /Q /F "%USERPROFILE%\Desktop\Mp3tag.lnk"DEL /Q /F "%USERPROFILE%\Desktop\Audiograbber.lnk"DEL /Q /F "%USERPROFILE%\Desktop\DVD Shrink 3.2.lnk"DEL /Q /F "%USERPROFILE%\Start Menu\Programs\Remote Assistance.lnk"DEL /Q /F "%USERPROFILE%\Start Menu\Programs\Mp3tag\Information (german).lnk"DEL /Q /F "%USERPROFILE%\Start Menu\Programs\Mp3tag\Version history.lnk"DEL /Q /F "%USERPROFILE%\Start Menu\Programs\Mp3tag\Uninstall Mp3tag.lnk"everything workd fine exept the %DEFAULTUSERPROFILE% part.is this mabee because the default user is a hidden sysyems folder?and thanks for taking your time with me. Link to comment Share on other sites More sharing options...
legionaire Posted February 2, 2007 Share Posted February 2, 2007 There is no such thing as a "default user" directory in Windows XP. While there is an entire branch in the HKEY_USERS Registry devoted to ".DEFAULT", the file system equivalent is %allusersprofile% and is located in C:\All Users by default.@Yzowl: Thanks for pointing out the difference between 1>nul and 2>nul - I've finally got it. Link to comment Share on other sites More sharing options...
Yzöwl Posted February 2, 2007 Share Posted February 2, 2007 There is a Default User folder, it is has hidden but not system attributes and is usually here:"C:\Documents and Settings\Default User"To remove the link, this exact line, which is the same as the one I've previously given will work, (unless it's either not there or you do not have sufficient permissions to remove it).DEL/F/A "%ALLUSERSPROFILE%\..\Default User\Start Menu\Programs\CyberLink PowerDVD\unwanted.lnk" Link to comment Share on other sites More sharing options...
nizzehult Posted February 3, 2007 Share Posted February 3, 2007 Since it's hidden, how about if you use ATTRIB -S -H first to make it visible? Link to comment Share on other sites More sharing options...
Yzöwl Posted February 3, 2007 Share Posted February 3, 2007 Well, since I said it was hidden but not system then you would only need ATTRIB -H, for the folder. However that is not needed as the /F and /A switches in my code cover deleting read-only, hidden and system files anyway. Link to comment Share on other sites More sharing options...
spidercop Posted February 9, 2007 Share Posted February 9, 2007 (edited) i think the deletion must work wen is youre batch started tho delet these icons if there not created they cant be deleted Edited February 9, 2007 by spidercop Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now