user2333439
user2333439

Reputation: 9

Deleting via Batch file

I want to create a batch file to delete the following path across the network via automated scripting.

So far I'm using :

REM <start>
@echo off
rmdir /s /q c:\users\%allusersprofile%\ppTemp\
REM <end>

Where %alluserprofiles% would be each individual user and ppTemp is the dir that needs removed.

The code above isn't working.

Help!

Upvotes: 0

Views: 333

Answers (1)

Jay
Jay

Reputation: 11

The environment variable reference %AllUsersProfile% returns a fully qualified path, so prefixing it with C:\users\ in the rmdir command is redundant. It also returns the path for program data storage for ALL USERS, not individual users; it's not clear from your question which behavior you want.

As an example, the result I see for echo %AllUsersProfile% is

  • on Windows 7:    C:\ProgramData
  • on Windows XP: C:\Documents and Settings\All Users

For the UserProfile environment variable, echo %UserProfile% returns

  • on Win7:    C:\Users\MyUserName
  • on WinXP: C:\Documents and Settings\MyUserName

So assuming you're using Windows 7 or Vista, you probably want to change the rmdir command to:

rmdir /s /q "%UserProfile%\ppTemp\"

which should resolve to a path of C:\Users\username\ppTemp\.

Upvotes: 1

Related Questions