Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account


Photo

Login script for cleaning up partitions sought

- - - - -

  • Please log in to reply
1 reply to this topic

#1
Mikka

Mikka

    Junior

  • Member
  • Pip
  • 80 posts
  • OS:none specified
  • Country: Country Flag
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, 13 August 2012 - 12:46 PM.



How to remove advertisement from MSFN

#2
Mikka

Mikka

    Junior

  • Member
  • Pip
  • 80 posts
  • OS:none specified
  • Country: Country Flag
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, 19 August 2012 - 06:28 AM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users



How to remove advertisement from MSFN