Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

delete old profile through bat file

4 views
Skip to first unread message

Vijay

unread,
Nov 24, 2009, 7:49:01 AM11/24/09
to
hi,

I want to delete old user profile (old more than one day ) ,
Please tell me the bat file command to delete these profiles......

thanks,,

vijay

Pegasus [MVP]

unread,
Nov 24, 2009, 8:46:30 AM11/24/09
to

"Vijay" <Vi...@discussions.microsoft.com> wrote in message
news:2EC94E27-213A-4859...@microsoft.com...

Seems a dangerous thing to do, like running around with a few razor blades
in your hands. Still - it's your machine. Remember to unwrapped wrapped
lines, to remove the line numbers, to set the exclusions and to test it from
a Console screen before activating it. To make this tool fully active you
must change this line
[20] %VB% 'oFSO.DeleteFolder(oFolder.Path)
like so:
[20] %VB% oFSO.DeleteFolder(oFolder.Path)

Note: When you use this tool, all responsibility lies with you.

[01] @echo off
[02] set Active=false
[03] set Exclusions=/Administrator/LocalService/NetworkService/Default User/
[04] set Scr=c:\TempVBS.vbs
[05] set VB=echo^>^>%Scr%
[06] cd 1>nul 2>%Scr%
[07]
[08] %VB% Set oFSO = CreateObject("Scripting.FileSystemObject")
[09] %VB% Set oWshShell = CreateObject("WScript.Shell")
[10] %VB% sProfiles =
oWshShell.ExpandEnvironmentStrings("%AllUsersProfile%\..")
[11] %VB% sProfiles = oFSO.GetAbsolutePathName(sProfiles)
[12] %VB% For Each oFolder In oFSO.GetFolder(sProfiles).SubFolders
[13] %VB% If InStr(1, "%Exclusions%", "/" ^& oFolder.Name ^& "/", 1) = 0
Then
[14] %VB% If oFSO.FileExists(oFolder.Path ^& "\ntuser.dat") Then
[15] %VB% dFileDate = oFSO.GetFile(oFolder.Path ^&
"\ntuser.dat").DateLastModified
[16] %VB% If DateDiff("d", dFileDate, Date()) ^> 1 Then
[17] %VB% WScript.Echo "Deleting", oFolder.Path
[18] %VB% If %Active% Then
[19] %VB% On Error Resume Next
[20] %VB% 'oFSO.DeleteFolder(oFolder.Path)
[21] %VB% if err.number ^> 0 then WScript.Echo Err.Description
[22] %VB% On Error Goto 0
[23] %VB% End If
[24] %VB% End If
[25] %VB% End If
[26] %VB% End If
[27] %VB% Next
[28] cscript //nologo %Scr%
[29] del %Scr%


SPAMCOP User

unread,
Nov 24, 2009, 6:54:07 PM11/24/09
to

Op,

Why not use the Microsoft service to delete redundant profiles?

==============

What about the owner profile, Pergasus? Not in your default exclusions

--
SPAMCOP User


"Pegasus [MVP]" <ne...@microsoft.com> wrote in message
news:OHnqIyQb...@TK2MSFTNGP02.phx.gbl...

Pegasus [MVP]

unread,
Nov 24, 2009, 7:03:37 PM11/24/09
to

"SPAMCOP User" <spamcop_user@no_mail.haha> wrote in message
news:%23959nFW...@TK2MSFTNGP06.phx.gbl...

> Op,
>
> Why not use the Microsoft service to delete redundant profiles?
>
> ==============
>
> What about the owner profile, Pergasus? Not in your default exclusions
>
> --
> SPAMCOP User

That's why I wrote "Remember to [..] set the exclusions". If the OP wants to
use such a dangerous tool then he must have the sense
a) To set his own exclusions, and
b) To fully test the script before activating it.


Vijay

unread,
Nov 25, 2009, 5:33:01 AM11/25/09
to
Please tell me the bat command only, i think you described with help of vb,

"Pegasus [MVP]" wrote:

> .
>

Pegasus [MVP]

unread,
Nov 25, 2009, 5:38:37 AM11/25/09
to
I did give you a batch file. While there is a VB Script file embedded in it,
this is irrelevant. Just leave it as it is (with the exception of these
lines:

[20] %VB% 'oFSO.DeleteFolder(oFolder.Path)
[20] %VB% oFSO.DeleteFolder(oFolder.Path)
)

"Vijay" <Vi...@discussions.microsoft.com> wrote in message

news:1751D3FE-3FCB-43FC...@microsoft.com...

Willard

unread,
Nov 26, 2009, 9:39:51 AM11/26/09
to
What is the "Microsoft Service" and where do you find lt ??

Pegasus [MVP]

unread,
Nov 26, 2009, 11:35:24 AM11/26/09
to
It's not a "Microsoft Service" that Spamcop was thinking about but rather
the "User Profile Deletion Utility" (Delprof.exe) - see here:
http://www.microsoft.com/downloads/details.aspx?familyid=901a9b95-6063-4462-8150-360394e98e1e&displaylang=en


"Willard" <gu...@msn.invalid> wrote in message
news:eUyaMZqb...@TK2MSFTNGP04.phx.gbl...

0 new messages