I'm looking to make an exe or batch file that will delete a folder, however the folder location changes based on the User, so I'd like it to determine this based on what user is currently logged in, or by asking the person running the exe/batch to type in the user name so it knows where to look.

The folder I'd like to have deleted is in the example below, where "PC" is the Login name that needs to match the current user or allow it to be entered.

C:\Users\PC.digilabs\ubuildabook\data

Thanks

Recommended Answers

All 4 Replies

C:\Users\PC.digilabs\ubuildabook\data

For some reason it's not showing the "\" between PC and .digilabs

For some reason it's not showing the "\" between PC and .digilabs

Directories are seperated by the backslash. The path you are showing indicates that PC.digilabs is the name of the folder.

Use the USERNAME environment variables. On my machine with my current account it is

USERPROFILE=C:\Users\Jim

You can see the resulting command by

echo rd %USERPROFILE%\.digilabs\ubuildabook\data

If you use two backslashes before the "." when you post you get

C:\Users\PC\.digilabs\ubuildabook\data

Thanks for the info on both why my post was missing the \ and about the RD command.

The only change I had to make was adding /s/q after RD so it would remove all the files it contains without asking.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.