Mikka Posted August 13, 2012 Share Posted August 13, 2012 (edited) Hi,I'd like to use some sort of login script for a Windows PE (Win7PE SE) doing this:detect all existing drives (read-write), c:, d:, e: ..., x: (default PE ramdrive)check each drive on root for a specific folder, i.e. RECYCLER / $Recycle.bindelete each matchI thought of executing this script each time the PE is booted. I don't know what's best for it; probably a cmd/batch script...?I know, that the desired action could be done using something like rd /q/s c:\RECYCLER and so forth, but it should execute well for several systems (some having merely c:, x:; another one with c:, d:, e:, f:, v:, x: etc.).My first idea was to use e.g. diskpart to get a list of available (NTFS) volumes and corresponding drive letters.Dunno how to script this, though. Any suggestions on this? Greetings,Mikka Edited August 13, 2012 by Mikka Link to comment Share on other sites More sharing options...
Mikka Posted August 17, 2012 Author Share Posted August 17, 2012 (edited) Okay, I've written a basic script (still alpha) that works for Windows XP and Windows 7. I still have to test it within my PE project.Instead of diskpart I used wmic (need to verify this for my Win7PESE build as well) to get the relevant NTFS drives.Here's what I've got so far:@echo offREM Need to loop through all available NTFS volumes, excluding volume X: (on any system)For /f "skip=3" %%i In ('wmic logicaldisk where "filesystem='ntfs'" get Name^') Do If Not "%%i"=="X:" ( For %%t In ($RECYCLE.BIN RECYCLER "System Volume Information") Do ( If Exist %%~di\%%t Rd /q/s %%~di\%%t ))Little problem: If I omit "skip=3" (which might be skip=2 in your case), the script will try twice to delete matches on C:—don't know why.Any CMD guru reading along who could comment on this (Yzöwl maybe)? Cheers,Mikka Edited August 19, 2012 by Mikka Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now