I've seen threads about DelProf not always working as it should. I want to be able to delete local profiles on a client in a test setup. I'm far from an expert with VBS and came across some code:
I've added the problem that I have to the code. Basically, it doesn't delete the profiles unless I put in a "Pause" so I can watch the profiles deleted but I want to avoid that (well I do in the "real life" situation).Code:Option Explicit Dim objOU, objComputer, strComputer, objShell Dim strPath, intError, intDays ' Specify path to delprof.exe. strPath = "\\server\tools$\delprof.exe" ' Specify number of days after which delprof ' considers the profile as inactive (and subject to deletion). intDays = 1 ' Bind to the Organizational Unit. Set objOU = GetObject("LDAP://ou=Test_OU,dc=MyDomain,dc=test") 'I set this as the OU which contains the client computer ' Filter on objects of class computer. objOU.Filter = Array("computer") ' Use the Run method of the wshShell object. Set objShell = CreateObject("Wscript.Shell") ' Enumerate all computers in the OU. For Each objComputer In objOU ' Retrieve the NetBIOS name of the computer. strComputer = objComputer.sAMAccountName ' Strip off trailing "$". strComputer = Left(strComputer, Len(strComputer) - 1) ' Run delprof.exe on the remote computer. 'The next line is for testing purposes, to confirm that the correct computer has been picked up, along 'with the number of inactive days. wscript.echo "Running DelProf on " & strComputer & " - " & Cstr(intDays) & " day(s)." intError = objShell.Run("%comspec% /c " & strPath & " /q /i /c:\\" & strComputer & " /d:" & CStr(intDays)) If (intError <> 0) Then Wscript.Echo "Error " & CStr(intError) & " on computer " & strComputer End If 'If the following line is commented out, the script doesn't delete the profiles 'but if I uncomment it, I can watch the deletion(s) happen then click OK and everything 'has gone, as it should! wscript.echo "DONE" Next
I've tried setting the /k switch after %comspec% but that doesn't help either.
Any ideas (other than deleting the profiles remotely from the server)?
Thanks in advance.



LinkBack URL
About LinkBacks
Reply With Quote

