Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

Can't delete folder via Command Prompt, Only manually.


Best Answer hmp3 , 05 December 2019 - 05:11 PM

Okay, I experimented and remembered that cmd stops processing automatically without adding the "Exit" afterwards. I stuck that after the "rmdir" and the bat file worked perfectly but only when the/... Go to the full post »


  • This topic is locked This topic is locked

#1
hmp3

hmp3

    Member

  • Member
  • PipPipPip
  • 478 posts

Hi I can delete folder manually but I need to automate a folder deletion process silently.

There was originally a desktop.ini in the folder and regardless of whether I showed system files or not, or deleted the file manually, the folder I want to delete still remained using the following methods:

After using CD to navigate to the parent directory.

I write the following to delete a specific folder in that directory:

"rmdir FOLDERNAME" which results in folder not empty.

"del /q FOLDERNAME" which fails to delete, but no error (hence the /q)

Just for testing purposes, I tried it without /q:

"del FOLDERNAME" which results in Y/N Are you sure, I type "Y" but folder remains.

 

Any ideas?


  • 0

Advertisements


#2
JSntgRvr

JSntgRvr

    Global Moderator

  • Global Moderator
  • 11,426 posts

Use switch to remove subfolders and files

 

Try rmdir /s /q [drive:]path

 

Example:

 

rmdir /s /q c:\foldername


  • 0

#3
hmp3

hmp3

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 478 posts

Thanks now it works but what happens is that cmd displays:

Rmdir /s /q FOLDERNAME

 

but then doesn't process it until I press the ENTER key.

How do I get it to process it without me manually pressing ENTER?


  • 0

#4
JSntgRvr

JSntgRvr

    Global Moderator

  • Global Moderator
  • 11,426 posts
The command must be executed by pressing Enter. No way around it.
  • 0

#5
hmp3

hmp3

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 478 posts

I can't believe how stupid it is that cmd is programmed in such a way that a batch script cannot be run without manual input.

Is there any way to program the script to automatically trigger the ENTER keypress?


Edited by phickspc, 05 December 2019 - 09:34 AM.

  • 0

#6
JSntgRvr

JSntgRvr

    Global Moderator

  • Global Moderator
  • 11,426 posts
Only in advanced programming. Something that you wont be able to understand yet.
  • 0

#7
hmp3

hmp3

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 478 posts

Only in advanced programming. Something that you wont be able to understand yet.

lol, is there a workaround?


  • 0

#8
hmp3

hmp3

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 478 posts
✓  Best Answer

Okay, I experimented and remembered that cmd stops processing automatically without adding the "Exit" afterwards. I stuck that after the "rmdir" and the bat file worked perfectly but only when the/bat file was stored on OS drive, otherwise it asked all sorts of permissions.

I realise now that this must be really Programming 101 for those reading but still! Thanks!


  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP