Hi All ,
I am looking for a Vbscript which can delete files from all user profiles present on the computer. Can anyone help me with that? Thanks in advance
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
I have a script that first looks in the registry for a list of the profiles on the pc, then they are removed from the registry and also the files under documents and settings will be removed. (Except from the user who is working on that computer), so it also works for remote computers as well for the local computer
Answered 04/18/2007 by: jan thielemans
Yellow Belt

Please log in to comment
0
Hi Jan,

Can you share that script with me. Please post it here .
Answered 04/18/2007 by: msi_learner
Orange Belt

Please log in to comment
0
So,
give it a try
(the script connects to \\computer\c$ as the v-drive)
Jan




' this script removes the cached profiles on a pc
' use : in doswindow : cscript verwijderprofiles.vbs computername
' *******************************************************************
'On Error Resume Next

' om te connecteren met de registry

Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = wscript.Arguments.Item(0)
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(shutdown)}!\\" _
& strComputer & "\root\cimv2")
Set objRegistry=GetObject("winmgmts:\\" & _
strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList"
objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubkeys

' koppelen van de c-schijf (v)

Set objShell = CreateObject("Wscript.Shell")
Set objNetwork = Wscript.CreateObject("WScript.Network")
objNetwork.MapNetworkDrive "v:","\\" & strComputer & "\c$"
wscript.echo " v-schijf is gekoppeld"
'zoeken in registry naar info over profiles

For Each objSubkey In arrSubkeys
if left(objsubkey,8) ="S-1-5-21" then
strValueName = "ProfileImagePath"
strSubPath = strKeyPath & "\" & objSubkey
objRegistry.GetExpandedStringValue HKEY_LOCAL_MACHINE,strSubPath,strValueName,strValue
gebruiker = Split(strValue,"\")
Set colComputer = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
if colcomputer.count = 0 then
wie = ""
else
For Each objComputer in colComputer
if isnull(objcomputer.username) then
wie = ""
else
wie = objcomputer.username
wie = Right(wie,len(wie)-5)
wscript.echo wie & " is ingelogd op " & strComputer
end if
Next
end if
if gebruiker(2) <> wie and left(gebruiker(2),10) <> "Administra" then
objRegistry.DeleteKey HKEY_LOCAL_MACHINE,strSubPath,strValueName
wscript.Echo gebruiker(2) & " wordt verwijderd"
' objShell.Run ("%comspec% /c rmdir /s/q \\" & strComputerv & "\c$\Docume~1\" & gebruiker(2)&""),0,TRUE
objShell.Run ("%comspec% /c rmdir /s/q v:\Docume~1\" & gebruiker(2)&""),0,TRUE
' objShell.Run ("%comspec% /c rmdir /s/q '%\\" & strComputer & "\c$\Documents and settings\" & gebruiker(2)& "%'"),0,TRUE
end if
end if

Next
objNetwork.RemoveNetworkDrive "v:"
'wscript.Echo " v-schijf is ontkoppeld"
Answered 04/18/2007 by: jan thielemans
Yellow Belt

Please log in to comment
0
microsoft released a tool called delprof which does a similar thing based on last use of profile.


ie after X days toast profile.
Answered 04/18/2007 by: jmcfadyen
Fifth Degree Black Belt

Please log in to comment
0
sorry its called delprof.exe
Answered 04/18/2007 by: jmcfadyen
Fifth Degree Black Belt

Please log in to comment
0
Yes, I know,
I was not so happy with it, but I do not remember why (i think it was because you always had to agree)

Jan
Answered 04/18/2007 by: jan thielemans
Yellow Belt

Please log in to comment
0
Thanks for the script.
I came to know there is a feature in msi itself , called jump profile that can be used to delete the files from each user profile folder. Anyone has any information on it.
Answered 04/19/2007 by: msi_learner
Orange Belt

Please log in to comment
0
you can make it silent

echo was something along the lines of

echo delprof ..blah blah |y
Answered 04/22/2007 by: jmcfadyen
Fifth Degree Black Belt

Please log in to comment
Answer this question or Comment on this question for clarity