Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
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
  • 612 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,579 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
  • 612 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,579 posts
The command must be executed by pressing Enter. No way around it.
  • 0

#5
hmp3

hmp3

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 612 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,579 posts
Only in advanced programming. Something that you wont be able to understand yet.
  • 0

#7
hmp3

hmp3

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 612 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
  • 612 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