Jump to content
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble

MSFN is made available via donations, subscriptions and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. Alternatively, register and become a site sponsor/subscriber and ads will be disabled automatically. 



Sign in to follow this  
Mikka

Login script for cleaning up partitions sought

Recommended Posts

Mikka    0

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.bin
  • delete each match

I 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? :unsure:

Greetings,

Mikka

Edited by Mikka

Share this post


Link to post
Share on other sites

Mikka    0

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 off
REM 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 by Mikka

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×