/build/static/layout/Breadcrumb_cap_w.png

VbScript to delete files

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

Answers (8)

Posted by: jan thielemans 17 years ago
Yellow Belt
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
Posted by: msi_learner 17 years ago
Orange Belt
0
Hi Jan,

Can you share that script with me. Please post it here .
Posted by: jan thielemans 17 years ago
Yellow Belt
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"
Posted by: jmcfadyen 17 years ago
5th Degree Black Belt
0
microsoft released a tool called delprof which does a similar thing based on last use of profile.


ie after X days toast profile.
Posted by: jmcfadyen 17 years ago
5th Degree Black Belt
0
sorry its called delprof.exe
Posted by: jan thielemans 17 years ago
Yellow Belt
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
Posted by: msi_learner 17 years ago
Orange Belt
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.
Posted by: jmcfadyen 17 years ago
5th Degree Black Belt
0
you can make it silent

echo was something along the lines of

echo delprof ..blah blah |y
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ