i need help to delete the additional root folders i created

Gogol King 0 Reputation points
2024-07-19T11:00:57.8933333+00:00

Hello. so i made the big mistakes of creating root folders and files and i need help to delete them so basically i was trying to code a node and java file and i didnt thought of what permissions im giving to the VS code and about 1 or 2 hours later i realised everything im trying to do in my D drive needs adminstrator permission i didnt mind atm but after a while when i wanted to code again every little change required adminstrator and it got on my nerves so i did some research and realised im destroyed i just want my D drive to go back to normal , i dont know how i should locate the Root drives and create subfolders or stuff im a complete newbie

Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
9,847 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,577 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Jacen Wang 960 Reputation points Microsoft Vendor
    2024-07-21T22:20:34.3533333+00:00

    Hello,

    We can use PowerShell to find the root drive and create subfolders. The following is an example:

    1. Find the root drive:

    $rootDrive = Get-PSDrive -PSProvider FileSystem | Where-Object { $_.Root -eq "D:" }

    1. Create a subfolder:

    $folderPath = "$($rootDrive.Root)NewFolder"

    New-Item -Path $folderPath -ItemType Directory

    This script first finds the root drive (D:) and then creates a subfolder called "NewFolder" under the root drive.

    Reference: Working with files and folders - PowerShell | Microsoft Learn

    ———————————————————————————————————————

    If the Answer is helpful, please click "Accept Answer" and upvote it.


  2. MotoX80 34,346 Reputation points
    2024-07-27T20:54:37.67+00:00

    It is not clear from your description what your problem is. Use the Snipping tool (Win+Shift+s) and share some screen shots to show us what you did and what you need fixed.

    Like this... here I have test VM that has an E drive where I created a Data folder.

    User's image

    On the drive permissions, I granted Everyone full control because I have no specific security requirements, and if I had only granted Administrators access then I would need to deal with UAC elevation.

    If you created a bunch of folders like this...

    User's image

    You can delete them like this... you might want to add the -WhatIf switch to the remove-item to verify what folders would be deleted. I've had to restore servers because I had one guy who didn't understand the concept of current drive and current directory and he managed to delete almost all files in System32.

    Get-ChildItem folder* | remove-item -recurse
    

    User's image

    If you are a "complete newbie", then I would suggest that you take some courses (online or at a school) on Windows basics before you try to start writing code.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.