Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Hatsukaichi, Hiroshima, Japan
    Posts
    904
    Thanks
    0
    Thanked 0 Times in 0 Posts

    del command in bat files (Pro)

    well here I am again trying to make a batch file work. Has anyone had any success using del in a batch file or from the run box. When I try from the run box I get an error message
    "Windows cannot find 'del'. Make sure you typed the name correctly and then try again..."

    I also tried del.exe with the same result. Previously I did a search for xcopy.exe and found that but it appears no del.exe exists on my computer. Is this normal?

    Thanks,

    Chris

  2. #2
    Super Moderator
    Join Date
    Dec 2000
    Location
    Renton, Washington, USA
    Posts
    12,560
    Thanks
    0
    Thanked 4 Times in 4 Posts

    Re: del command in bat files (Pro)

    Are you trying this from a DOS Prompt or a DOS Window?

    If you are using the DOS Prompt then you need the path to "Command.com" which del is part of. The path should be "C:Windows"

    Now running HP Pavilion a6528p, with Win7 64 Bit OS.

  3. #3
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: del command in bat files (Pro)

    Yes, that is normal. The DELete command is what is know as an internal DOS command, and therefore there is not DEL.EXE or DEL.COM file. The DEL command in contained in COMMAND.COM. To use it, you need to open a DOS window and enter the command at the DOS prompt.
    Legare Coleman

  4. #4
    3 Star Lounger
    Join Date
    Nov 2001
    Location
    Upstate, South Carolina, USA
    Posts
    253
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: del command in bat files (Pro)

    I don't think so ...

    As an experiment, I created the following simple batch file:
    <font face="Georgia">
    del /?
    pause
    </font face=georgia>
    Double-clicking on the file in an explorer window yielded the attached results. My PATH statement, without any changes from the standard XP installation, is "PATH=C:WINDOWSsystem32;C:WINDOWS;C:WINDOWSsystem3 2WBEM." COMMAND.COM is in the system32 directory.

    So, it would seem that the "del" command should function just fine in batch files under XP.
    Attached Images Attached Images
    Al
    "Do or do not do. There is no try." -- Yoda
    <img src=/S/flags/USA.gif border=0 alt=USA width=30 height=18>

  5. #5
    5 Star Lounger
    Join Date
    Dec 2002
    Location
    Perth, Western Australia, Australia
    Posts
    730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: del command in bat files (Pro)

    Al & Legare, you're both right!

    If you're trying to execute DEL directly, you need to be at a DOS prompt (and if you're there, then COMMAND.COM, or preferably CMD.EXE, is processing your commands). Chris tried to use DEL in the windows RUN box, and windows knows stuff all about internal DOS commands, hence his error msg.

    When you run a DOS Batch file, it invokes CMD.EXE (see Al's title bar above), which does understand internal DOS commands, and DEL works fine.
    <font face="Comic Sans MS" color="blue">TimOz</font>
    <img src=/S/flags/Finland.gif border=0 alt=Finland width=30 height=18> <img src=/S/flags/Australia.gif border=0 alt=Australia width=30 height=18>

  6. #6
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Hatsukaichi, Hiroshima, Japan
    Posts
    904
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: del command in bat files (Pro)

    Thanks for all the replies - now I really wonder! I started out by using del in a batch file. When this didn't work I tried del.exe not realising at the time that del is different from xcopy (xcopy won't work in batch files on my computer but xcopy.exe will). Of course del. exe didn't work so then I switched to the run box where i got the error messages. I just tried del from the command prompt and got an error message:

    Cocuments and SettingseverdayuseRecent>del *.jpg
    Could Not Find Cocuments and SettingseverydayuseRecent*.jpg

    Is this because I'm in the Recents Folder? I know there are jpg files because I'm looking at them.

    GOT IT! <img src=/S/bow.gif border=0 alt=bow width=15 height=15> Silly me! I should have typed del *.jpg.lnk. They are all shortcuts! Why doesn't windows show the extension for shortcuts? del *.jpg.lnk did the trick. My plan is to create a batch file to tidy up the recents folder leaving just file types of my choosing. Now all I have to do is get del working in a batch file.

    To be continued...

    Chris

  7. #7
    5 Star Lounger
    Join Date
    Dec 2002
    Location
    Perth, Western Australia, Australia
    Posts
    730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: del command in bat files (Pro)

    Chris, in Explorer, click Tools / Folder Options
    <font face="Comic Sans MS" color="blue">TimOz</font>
    <img src=/S/flags/Finland.gif border=0 alt=Finland width=30 height=18> <img src=/S/flags/Australia.gif border=0 alt=Australia width=30 height=18>

  8. #8
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Hatsukaichi, Hiroshima, Japan
    Posts
    904
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: del command in bat files (Pro)

    Thanks Tim, that's about the first thing I do after installing Windows. I've also made sure hidden files and folders are shown and at the moment I've even unchecked the box "hide protected operating system files" - but I still can't see the lnk extension - can you see this extension on your computer?

    Chris

  9. #9
    Plutonium Lounger
    Join Date
    Oct 2001
    Location
    Lexington, Kentucky, USA
    Posts
    12,107
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: del command in bat files (Pro)

    I think you're right, Chris. Windows will not "show" us the .lnk even when you do a search for *.lnk, it will bring 'em all up on the screen, but the file extension doesn't show. I too have my "View" preferences set to show me EVERYTHING.

    But, back to your original question. Didn't you have a problem with your PATH setting some time ago? If you open up a command prompt (Run, CMD) and type DEL /? do you see the help? If so, it should work in a batch file, as long as that batch file is run in an "environment" where it has a proper PATH setting to the Windows folders.

  10. #10
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Hatsukaichi, Hiroshima, Japan
    Posts
    904
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: del command in bat files (Pro)

    Well my batch file works! But I didn't get the result I thought I would. The batch file creates a temporary directory, copies lnks for 4 files types to the temporary directory, removes what's left from the Recent folder, copies the lnk files back and deletes the temp folder. But when I go to documents off the start folder it shows up as being completely empty! It doesn't show the lnks that are left even though they are in the Recent Folder. Does anyone have any idea why? There's little point to my batch file if I can't see the lnks that are left.

    Chris

  11. #11
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Hatsukaichi, Hiroshima, Japan
    Posts
    904
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: del command in bat files (Pro)

    Thanks Big Al, I can see del from teh cmd prompt - it works in the batch file - the reason it didn't work before was because I didn't have .lnk included in the command line. Not showing the lnk extension is inconsistent - and annoying!

    Chris

  12. #12
    Administrator
    Join Date
    Mar 2001
    Location
    St Louis, Missouri, USA
    Posts
    23,572
    Thanks
    5
    Thanked 1,057 Times in 926 Posts

    Re: del command in bat files (Pro)

    BigAl, At one time there was a tweak to see the .lnk extension. Don't remember if it was an older TweakUI or X-Setup. You could also see several other 'normally' hidden extensions. The only drawback was you saw them everywhere - even the desktop which I found annoying. I could not find it in TweakUI for XP and don't have X-Setup at work to check.

    Joe
    Joe

  13. #13
    Administrator
    Join Date
    Mar 2001
    Location
    St Louis, Missouri, USA
    Posts
    23,572
    Thanks
    5
    Thanked 1,057 Times in 926 Posts

    Re: del command in bat files (Pro)

    BigAl, On even further review, here's a link to a registry patch to show 'super hidden' extensions http://www.winguides.com/registry/display.php/627/.

    Joe
    Joe

  14. #14
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: del command in bat files (Pro)

    Yes, DEL is an internal DOS command and works just fine in a DOS window (which is where your batch file was running). The DOS window uses either COMMAND.COM or CMD.EXE, both of which have DEL as an internal command, and it works fine. However, you can NOT select RUN from the START menu, type a DEL command in the run command line box and have it work since COMMAND.COM or CMD.EXC are not in control.
    Legare Coleman

  15. #15
    5 Star Lounger
    Join Date
    Dec 2002
    Location
    Perth, Western Australia, Australia
    Posts
    730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: del command in bat files (Pro)

    Thanks for that link Joe. When I moved from w98 to XP I had forgotten to unhide SHS and other potentially dodgy extensions. (Woody may have mentioned this in WWW a couple of years back, I think.)

    I guess this is one those <img src=/w3timages/censored.gif alt=censored border=0> "by design" features, fully supported by Winspeak. After all, the option that we uncheck in Explorer quite clearly states "Hide extensions for known file types". Obviously SHS, LNK, URL, etc are top secret unknown file types. Maybe this thread should be erased in the interests of secrecy? <img src=/S/evilgrin.gif border=0 alt=evilgrin width=15 height=15>

    PS. Sorry Chris, should have checked that my "cure" worked before foisting it on you <img src=/S/bummer.gif border=0 alt=bummer width=15 height=15> .
    <font face="Comic Sans MS" color="blue">TimOz</font>
    <img src=/S/flags/Finland.gif border=0 alt=Finland width=30 height=18> <img src=/S/flags/Australia.gif border=0 alt=Australia width=30 height=18>

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •