Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

GUI for HTA will not refresh once VBscript Function has been called.

Posted on 2008-11-08
13
Medium Priority
?
4,223 Views
Last Modified: 2012-05-05
I've got an HTA that processes all machines with a specific machine naming convention and cleans the local profiles on that machine older than X ammount of days.  I've got the HTA looping through the vbscript for each machine and folder it processes.  The GUI is set to show what machine and what folder is processing, but it only updates if I give it a msgbox break.

How else can I force the GUI to update before processing the entry?
0
Comment
Question by:piattnd
  • 7
  • 3
  • 2
  • +1
13 Comments
 
LVL 76

Expert Comment

by:David Lee
ID: 22914172
0
 
LVL 14

Expert Comment

by:rejoinder
ID: 22914970
You can try the window.setTimeout command.  You can see an example here;
http://www.microsoft.com/technet/scriptcenter/resources/qanda/jul06/hey0727.mspx

Say in your script you have your loop.  Within the loop you can institute the setTimeout method to run a sub but only after x number of milliseconds.

It behaves in a similar way as the .setInterval method but instead of continuing to fire for the entire time, my method will run only in the loop section.
0
 
LVL 12

Author Comment

by:piattnd
ID: 22916876
I've tried using the window.settimeout and it doesn't work  :(
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 12

Author Comment

by:piattnd
ID: 22916896
Here's my code... pardon the sloppiness as my brain has been scattered, therefore not as neat.
<HTML>
<HEAD>
<link rel="stylesheet" type="text/css"
href="\\baker\boiseIT$\scripts\Profile Cleanup\Profile Cleanup.css"/>
<TITLE>Profile Cleanup Utility</TITLE>
<HTA:APPLICATION 
     APPLICATIONNAME="User Account Management"
     SCROLL="no"
     BORDER="THIN"
     SINGLEINSTANCE="yes"
     WINDOWSTATE="normal"
     MINIMIZEBUTTON="no"
     MAXIMIZEBUTTON="no"
     ICON="\\baker\boiseIT$\scripts\Script Central\icons\icon.ico"
>
 
<script language="VBScript">
'On error resume next
'=====================
'Defining variables
'=====================
Const ForReading = 1
const ForWriting = 2
Const ForAppending = 8
Const ADS_SCOPE_SUBTREE = 2
 
strDate = Date()
x = 2
strTotalSize = 0
strMonth = Month(Now)
strDay = Day(Now)
strYear = Year(Now)
 
'--------------------------------------------------
'Establishing connection to AD
'--------------------------------------------------
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE 
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
'*********************************************************************
'Correcting format of the Day variable and creating file date variable.
'*********************************************************************
If len(strDay) = 1 then
 
	strDay = "0" & strDay
	
End If
 
strFileDate = strMonth & strDay & strYear
 
'****************************
'Function to determine size
'****************************
Function FolderSize(strSizePath, strFolderSize)
	set objFolderSize = objFSO.GetFolder(strSizePath)
	strFolderSize = objFolderSize.size
End Function
 
'================================
'Determine location to run script
'================================    
    Sub RunLocation
	
		strLocation = SelectLocation.Value
		strGroup = ""
		
		select case strLocation
			case ""
				GroupSelect.innerHTML = ""
				
			case "Boise"
				GroupSelect.innerHTML = "<select size='1' width='50' name='SelectGroup' onchange='BoiseSetGroupInfo'>" &_
					"<option selected value=''>Make a Selection</option>" &_
					"<option value='PPD'>PPD</option>" &_
					"<option value='WDTS'>WDTS</option>" &_
					"<option value='TRN'>TRN</option></select>"
								
			case "Seattle"
				GroupSelect.innerHTML = "<select size='1' width='50' name='SelectGroup' onchange='SeattleSetGroupInfo'>" &_
					"<option selected value=''>Make a Selection</option>" &_
					"<option value='TMO'>TMO</option>" &_
					"<option value='VZW'>VZW</option>" &_
					"<option value='POO'>POO</option>" &_
					"<option value='TRN'>TRN</option></select>"
			
		End Select
	
	End Sub
	
	Sub SeattleSetGroupInfo
		
		strGroup = SelectGroup.Value
			Offline = "\\rainier\seattleIT$\Profile Cleanup\offline.txt"
			Deleted = "\\rainier\seattleIT$\Profile Cleanup\deleted.txt"
			Checked = "\\rainier\seattleIT$\Profile Cleanup\checked.txt"
			strExcelPath = "\\rainier\seattleIT$\Profile Cleanup\profile cleanup.xls"
			strGroupLocation = "LDAP://ou=seattle,ou=us,ou=wdsglobal,dc=corp,dc=wdsglobal,dc=com"
			strExcelSavePath = "\\rainier\seattleIT$\Profile Cleanup"
			MachineNames = "\\rainier\seattleIT$\Profile Cleanup\machinenames.txt"
							
				select case strGroup
				
					case ""
						'Nothing
						
					case "TMO"
						strMachineGroup = "SCUS-TMO*"
						intDel = 60
						StartAction.innerHTML = "<input type='button' value='Start Cleanup' name='start_cleanup' onClick='ProcessGroup """ & MachineNames & ""","""  & Offline & """,""" & Deleted & """,""" & Checked & """,""" & strExcelPath & """,""" & strMachineGroup & """,""" & strGroupLocation & """,""" & intDel & """,""" & strExcelSavePath & """'>"
					
					case "VZW"
						strMachineGroup = "SCUS-VZW*"
						intDel = 60
						StartAction.innerHTML = "<input type='button' value='Start Cleanup' name='start_cleanup' onClick='ProcessGroup """ & MachineNames & ""","""  & Offline & """,""" & Deleted & """,""" & Checked & """,""" & strExcelPath & """,""" & strMachineGroup & """,""" & strGroupLocation & """,""" & intDel & """,""" & strExcelSavePath & """'>"
 
					case "POO"
						strMachineGroup = "SCUS-POO*"
						intDel = 60
						StartAction.innerHTML = "<input type='button' value='Start Cleanup' name='start_cleanup' onClick='ProcessGroup """ & MachineNames & ""","""  & Offline & """,""" & Deleted & """,""" & Checked & """,""" & strExcelPath & """,""" & strMachineGroup & """,""" & strGroupLocation & """,""" & intDel & """,""" & strExcelSavePath & """'>"
 
					case "TRN"
						strMachineGroup = "TRNUS*"
						intDel = 45
						StartAction.innerHTML = "<input type='button' value='Start Cleanup' name='start_cleanup' onClick='ProcessGroup """ & MachineNames & ""","""  & Offline & """,""" & Deleted & """,""" & Checked & """,""" & strExcelPath & """,""" & strMachineGroup & """,""" & strGroupLocation & """,""" & intDel & """,""" & strExcelSavePath & """'>"
				
				End Select		
	End Sub
	
	Sub BoiseSetGroupInfo
		
		strGroup = SelectGroup.Value
			Offline = "\\baker\boiseIT$\scripts\Profile Cleanup\offline.txt"
			Deleted = "\\baker\boiseIT$\scripts\Profile Cleanup\deleted.txt"
			Checked = "\\baker\boiseIT$\scripts\Profile Cleanup\checked.txt"
			strExcelPath = "\\baker\boiseIT$\scripts\Profile Cleanup\profile cleanup.xls"
			strGroupLocation = "LDAP://ou=boise,ou=us,ou=wdsglobal,dc=corp,dc=wdsglobal,dc=com"
			strExcelSavePath = "\\baker\boiseIT$\scripts\Profile Cleanup"
			MachineNames = "\\baker\boiseIT$\scripts\Profile Cleanup\machinenames.txt"
							
				select case strGroup
				
					case ""
						'Nothing
						
					case "PPD"
						strMachineGroup = "SCID-PPD*"
						intDel = 60
						StartAction.innerHTML = "<input type='button' value='Start Cleanup' name='start_cleanup' onClick='ProcessGroup """ & MachineNames & ""","""  & Offline & """,""" & Deleted & """,""" & Checked & """,""" & strExcelPath & """,""" & strMachineGroup & """,""" & strGroupLocation & """,""" & intDel & """,""" & strExcelSavePath & """'>"
					
					case "WDTS"
						strMachineGroup = "SCID-WDTS*"
						intDel = 60
						StartAction.innerHTML = "<input type='button' value='Start Cleanup' name='start_cleanup' onClick='ProcessGroup """ & MachineNames & ""","""  & Offline & """,""" & Deleted & """,""" & Checked & """,""" & strExcelPath & """,""" & strMachineGroup & """,""" & strGroupLocation & """,""" & intDel & """,""" & strExcelSavePath & """'>"
 
					case "TRN"
						strMachineGroup = "TRNID*"
						intDel = 45
						StartAction.innerHTML = "<input type='button' value='Start Cleanup' name='start_cleanup' onClick='ProcessGroup """ & MachineNames & """,""" & Offline & """,""" & Deleted & """,""" & Checked & """,""" & strExcelPath & """,""" & strMachineGroup & """,""" & strGroupLocation & """,""" & intDel & """,""" & strExcelSavePath & """'>"
				
				End Select
				
	End Sub
	
Function ProcessGroup(MachineNames,Offline,Deleted,Checked,strExcelPath,strMachineGroup,strGroupLocation,intDel,strExcelSavePath)
 
CurrentStatus.innerText = "Getting machine list.... please wait"
		
If NOT objFSO.FileExists(MachineNames) then
	objFSO.CreateTextFile(MachineNames)
	
	Else
	Set objMachineNames = objFSO.OpenTextFile(MachineNames,ForWriting)
		
		objCommand.CommandText = strMachineGroup
		objCommand.CommandText = "SELECT Name, dNSHostName FROM '" & strGroupLocation & "' WHERE objectCategory='computer' AND dNSHostName='" & strMachineGroup & "'"
		Set objRecordSet = objCommand.Execute
		
	objRecordSet.MoveFirst		
		
Do Until objRecordSet.EOF
	
	strComputer = objRecordSet.Fields("Name").Value
	objMachineNames.writeline strComputer
	
objRecordSet.MoveNext
Loop
End If
 
CurrentStatus.innerText = "Processing machine list.... please wait"
set ObjMachineNames = nothing
 
CheckFolderAge intDel,Offline,Deleted,Checked,strExcelPath,strExcelSavePath,MachineNames
	
End Function
	
Function CheckFolderAge(intDel,Offline,Deleted,Checked,strExcelPath,strExcelSavePath,MachineNames)
 
On Error Resume Next
 
'======================================
'Establishing connection with log files
'======================================
		
Set objOffline = objFSO.OpenTextFile(Offline, ForWriting)
Set objDeleted = objFSO.OpenTextFile(Deleted, ForAppending)
set objChecked = objFSO.OpenTextFile(Checked, ForWriting)
Set objMachineNames = objFSO.OpenTextFile(MachineNames, ForReading)
 
set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.DisplayAlerts = True
objExcel.Workbooks.Open(strExcelPath)
Set objSheet = objExcel.Worksheets(1)
objSheet.Name = "Profile Cleanup"
 
Do Until objMachineNames.AtEndOfStream
 
	strComputer = objMachineNames.readline
	CurrentObject.innerText = "Machine: " & strComputer
	intDel = cint(intDel)
		if not objFSO.FolderExists("\\" & strComputer & "\c$") then
				objOffline.writeLine strComputer
				
		else
			
			Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
			Set colFolders = objWMIService.ExecQuery ("Select * From Win32_Directory Where Path Like '%\\Documents and Settings\\'")
				
			For Each objFolder in colFolders
				strFoldername = objFolder.Name
								
				strNameLength=Len(strFoldername)
				strNewNameLength = strNameLength - 26
				strNewFolderName = Right(strFoldername, strNewNameLength)
			
				objChecked.writeline strComputer & " , " & strNewFolderName
				'msgbox(strComputer & ", " & strNewFolderName)
				If strNewFolderName = "administrator" OR strNewFolderName = "all users" OR strNewFolderName = "default user" OR strNewFolderName = "localservice" OR strNewFolderName = "networkservice" OR strNewFolderName = "brian.whitted" then
					
					'Nothing
				
				Else
				
					set ColFiles = objWMIService.ExecQuery ("Select * From CIM_DataFile Where Extension = 'dat' AND Path Like '%\\" & strNewFoldername & "\\'")
							
						For Each objFile in ColFiles
							strLongMod = objFile.LastModified
							strShortMod = left(strLongMod,8)
							strModYear = left(strShortMod,4)
							strModMD = right(strShortMod,4)
							strModDay = right(strModMD,2)
							strModMonth = left(strModMD,2)
							strCorrectModMonth = right(strModMonth,2)
							strModDate = strCorrectModMonth & "/" & strModDay & "/" & strModYear 
							strLastModDif = cint(DateDiff("d", strModDate, strDate))
							'msgbox(strLastModDif & " days since modification")
							
							If strLastModDif >= intDel then
							strDeletePath = "\\" & strComputer & "\c$\Documents and Settings\" & strNewFolderName
								'msgbox(strNewFolderName & " is being processed for deletion!")
								strSizePath = "\\" & strComputer & "\c$\Documents and Settings\" & strNewFolderName
								Call FolderSize(strSizePath, strFolderSize)
								strTotalSize = strTotalSize + strFolderSize
								strFolderSizeKB = strFolderSize / 1000
								strFolderSizeMB = strFolderSizeKB / 1000
								objFSO.DeleteFolder strDeletePath,TRUE
								If objFSO.FolderExists(strDeletePath) then
									'Folder failed to delete, will not log
								Else
								objDeleted.writeline "\\" & strComputer & "\c$\Documents and Settings\" & strNewFolderName
								objSheet.cells(x,1).Value = strSizePath
								objSheet.Cells(x,2).Value = strFolderSizeMB
								x = x + 1
								End If
								Set objShell = nothing
							else
								'msgbox("This folder is not old enough")
							end if
						Next
					End if
			Next
	end if
 
Loop
 
objSheet.SaveAs strExcelSavePath & "\profile cleanup group_" & strFileDate & ".xls"
objExcel.Application.Quit
Set objApp = Nothing
	
CurrentObject.innerText = ""
CurrentFolder.innerText = ""
CurrentStatus.innerText = "Action Complete"
Set objChecked = Nothing
Set objDeleted = Nothing
Set objOffline = Nothing
Set objFSO = Nothing
			
End Function
	
</script>
 
</HEAD>
<BODY>
<DIV id="Background_DIV">
<img src= "\\baker\boiseIT$\scripts\script central\images\UAM background.bmp" height=100% width=100%/>
<script type="text/javascript">
	{
	window.resizeTo(400,300)
	window.moveTo(0,0);
	}	
</script>
 
<DIV id="LocationSelect_DIV">
<select size="1" width="30" name="SelectLocation" onchange="RunLocation">
    <option selected value="">Make a Selection</option>
    <option value="Boise">Boise</option>
    <option value="Seattle">Seattle</option>
</select>
</DIV>
 
<DIV id="GroupSelect_DIV" align="Center">
<span id="GroupSelect"></span>
</DIV>
<DIV id="ActionButton_DIV" align="Center">
<span id="StartAction"></span>
</DIV>
<DIV id="Status_DIV">
<span id="CurrentStatus"></span><br>
<span id="CurrentObject"></span><br>
<span id="CurrentFolder"></span>
</DIV>
</DIV>
</BODY>
</HTML>

Open in new window

0
 
LVL 65

Expert Comment

by:RobSampson
ID: 22918032
Hi, I am unable to test your code, as I'm not entirely sure how to work it, but I have added this:

            Sub Window_OnLoad
                  idTimer = window.setTimeout("UpdateStatus", 2000, "VBScript")
            End Sub

            Sub UpdateStatus
                  If strCurrentObject <> "" Then CurrentObject.innerText = CurrentObject.innerText & "Machine: " & strCurrentObject & VbCrLf
            End Sub


I have changed this
<BODY>
to this
<BODY OnLoad="vbs:Window_OnLoad"

and added strCurrentObject as a global varialbe and change this
      CurrentObject.innerText = "Machine: " & strComputer

to this
      strCurrentObject = strComputer

Hopefully this works to update the current machine...then we can change a couple more lines to work for the folder....

Regards,

Rob.
<HTML>
<HEAD>
<link rel="stylesheet" type="text/css"
href="\\baker\boiseIT$\scripts\Profile Cleanup\Profile Cleanup.css"/>
<TITLE>Profile Cleanup Utility</TITLE>
<HTA:APPLICATION 
     APPLICATIONNAME="User Account Management"
     SCROLL="no"
     BORDER="THIN"
     SINGLEINSTANCE="yes"
     WINDOWSTATE="normal"
     MINIMIZEBUTTON="no"
     MAXIMIZEBUTTON="no"
     ICON="\\baker\boiseIT$\scripts\Script Central\icons\icon.ico"
>
 
<script language="VBScript">
'On error resume next
'=====================
'Defining variables
'=====================
Const ForReading = 1
const ForWriting = 2
Const ForAppending = 8
Const ADS_SCOPE_SUBTREE = 2
Dim strCurrentObject
strCurrentObject = ""
 
strDate = Date()
x = 2
strTotalSize = 0
strMonth = Month(Now)
strDay = Day(Now)
strYear = Year(Now)
 
'--------------------------------------------------
'Establishing connection to AD
'--------------------------------------------------
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE 
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
'*********************************************************************
'Correcting format of the Day variable and creating file date variable.
'*********************************************************************
If len(strDay) = 1 then
 
	strDay = "0" & strDay
	
End If
 
strFileDate = strMonth & strDay & strYear
 
		Sub Window_OnLoad
			idTimer = window.setTimeout("UpdateStatus", 2000, "VBScript")
		End Sub
 
		Sub UpdateStatus
			If strCurrentObject <> "" Then CurrentObject.innerText = "Machine: " & strCurrentObject & VbCrLf
		End Sub
 
'****************************
'Function to determine size
'****************************
Function FolderSize(strSizePath, strFolderSize)
	set objFolderSize = objFSO.GetFolder(strSizePath)
	strFolderSize = objFolderSize.size
End Function
 
'================================
'Determine location to run script
'================================    
    Sub RunLocation
	
		strLocation = SelectLocation.Value
		strGroup = ""
		
		select case strLocation
			case ""
				GroupSelect.innerHTML = ""
				
			case "Boise"
				GroupSelect.innerHTML = "<select size='1' width='50' name='SelectGroup' onchange='BoiseSetGroupInfo'>" &_
					"<option selected value=''>Make a Selection</option>" &_
					"<option value='PPD'>PPD</option>" &_
					"<option value='WDTS'>WDTS</option>" &_
					"<option value='TRN'>TRN</option></select>"
								
			case "Seattle"
				GroupSelect.innerHTML = "<select size='1' width='50' name='SelectGroup' onchange='SeattleSetGroupInfo'>" &_
					"<option selected value=''>Make a Selection</option>" &_
					"<option value='TMO'>TMO</option>" &_
					"<option value='VZW'>VZW</option>" &_
					"<option value='POO'>POO</option>" &_
					"<option value='TRN'>TRN</option></select>"
			
		End Select
	
	End Sub
	
	Sub SeattleSetGroupInfo
		
		strGroup = SelectGroup.Value
			Offline = "\\rainier\seattleIT$\Profile Cleanup\offline.txt"
			Deleted = "\\rainier\seattleIT$\Profile Cleanup\deleted.txt"
			Checked = "\\rainier\seattleIT$\Profile Cleanup\checked.txt"
			strExcelPath = "\\rainier\seattleIT$\Profile Cleanup\profile cleanup.xls"
			strGroupLocation = "LDAP://ou=seattle,ou=us,ou=wdsglobal,dc=corp,dc=wdsglobal,dc=com"
			strExcelSavePath = "\\rainier\seattleIT$\Profile Cleanup"
			MachineNames = "\\rainier\seattleIT$\Profile Cleanup\machinenames.txt"
							
				select case strGroup
				
					case ""
						'Nothing
						
					case "TMO"
						strMachineGroup = "SCUS-TMO*"
						intDel = 60
						StartAction.innerHTML = "<input type='button' value='Start Cleanup' name='start_cleanup' onClick='ProcessGroup """ & MachineNames & ""","""  & Offline & """,""" & Deleted & """,""" & Checked & """,""" & strExcelPath & """,""" & strMachineGroup & """,""" & strGroupLocation & """,""" & intDel & """,""" & strExcelSavePath & """'>"
					
					case "VZW"
						strMachineGroup = "SCUS-VZW*"
						intDel = 60
						StartAction.innerHTML = "<input type='button' value='Start Cleanup' name='start_cleanup' onClick='ProcessGroup """ & MachineNames & ""","""  & Offline & """,""" & Deleted & """,""" & Checked & """,""" & strExcelPath & """,""" & strMachineGroup & """,""" & strGroupLocation & """,""" & intDel & """,""" & strExcelSavePath & """'>"
 
					case "POO"
						strMachineGroup = "SCUS-POO*"
						intDel = 60
						StartAction.innerHTML = "<input type='button' value='Start Cleanup' name='start_cleanup' onClick='ProcessGroup """ & MachineNames & ""","""  & Offline & """,""" & Deleted & """,""" & Checked & """,""" & strExcelPath & """,""" & strMachineGroup & """,""" & strGroupLocation & """,""" & intDel & """,""" & strExcelSavePath & """'>"
 
					case "TRN"
						strMachineGroup = "TRNUS*"
						intDel = 45
						StartAction.innerHTML = "<input type='button' value='Start Cleanup' name='start_cleanup' onClick='ProcessGroup """ & MachineNames & ""","""  & Offline & """,""" & Deleted & """,""" & Checked & """,""" & strExcelPath & """,""" & strMachineGroup & """,""" & strGroupLocation & """,""" & intDel & """,""" & strExcelSavePath & """'>"
				
				End Select		
	End Sub
	
	Sub BoiseSetGroupInfo
		
		strGroup = SelectGroup.Value
			Offline = "\\baker\boiseIT$\scripts\Profile Cleanup\offline.txt"
			Deleted = "\\baker\boiseIT$\scripts\Profile Cleanup\deleted.txt"
			Checked = "\\baker\boiseIT$\scripts\Profile Cleanup\checked.txt"
			strExcelPath = "\\baker\boiseIT$\scripts\Profile Cleanup\profile cleanup.xls"
			strGroupLocation = "LDAP://ou=boise,ou=us,ou=wdsglobal,dc=corp,dc=wdsglobal,dc=com"
			strExcelSavePath = "\\baker\boiseIT$\scripts\Profile Cleanup"
			MachineNames = "\\baker\boiseIT$\scripts\Profile Cleanup\machinenames.txt"
							
				select case strGroup
				
					case ""
						'Nothing
						
					case "PPD"
						strMachineGroup = "SCID-PPD*"
						intDel = 60
						StartAction.innerHTML = "<input type='button' value='Start Cleanup' name='start_cleanup' onClick='ProcessGroup """ & MachineNames & ""","""  & Offline & """,""" & Deleted & """,""" & Checked & """,""" & strExcelPath & """,""" & strMachineGroup & """,""" & strGroupLocation & """,""" & intDel & """,""" & strExcelSavePath & """'>"
					
					case "WDTS"
						strMachineGroup = "SCID-WDTS*"
						intDel = 60
						StartAction.innerHTML = "<input type='button' value='Start Cleanup' name='start_cleanup' onClick='ProcessGroup """ & MachineNames & ""","""  & Offline & """,""" & Deleted & """,""" & Checked & """,""" & strExcelPath & """,""" & strMachineGroup & """,""" & strGroupLocation & """,""" & intDel & """,""" & strExcelSavePath & """'>"
 
					case "TRN"
						strMachineGroup = "TRNID*"
						intDel = 45
						StartAction.innerHTML = "<input type='button' value='Start Cleanup' name='start_cleanup' onClick='ProcessGroup """ & MachineNames & """,""" & Offline & """,""" & Deleted & """,""" & Checked & """,""" & strExcelPath & """,""" & strMachineGroup & """,""" & strGroupLocation & """,""" & intDel & """,""" & strExcelSavePath & """'>"
				
				End Select
				
	End Sub
	
Function ProcessGroup(MachineNames,Offline,Deleted,Checked,strExcelPath,strMachineGroup,strGroupLocation,intDel,strExcelSavePath)
 
CurrentStatus.innerText = "Getting machine list.... please wait"
		
If NOT objFSO.FileExists(MachineNames) then
	objFSO.CreateTextFile(MachineNames)
	
	Else
	Set objMachineNames = objFSO.OpenTextFile(MachineNames,ForWriting)
		
		objCommand.CommandText = strMachineGroup
		objCommand.CommandText = "SELECT Name, dNSHostName FROM '" & strGroupLocation & "' WHERE objectCategory='computer' AND dNSHostName='" & strMachineGroup & "'"
		Set objRecordSet = objCommand.Execute
		
	objRecordSet.MoveFirst		
		
Do Until objRecordSet.EOF
	
	strComputer = objRecordSet.Fields("Name").Value
	objMachineNames.writeline strComputer
	
objRecordSet.MoveNext
Loop
End If
 
CurrentStatus.innerText = "Processing machine list.... please wait"
set ObjMachineNames = nothing
 
CheckFolderAge intDel,Offline,Deleted,Checked,strExcelPath,strExcelSavePath,MachineNames
	
End Function
	
Function CheckFolderAge(intDel,Offline,Deleted,Checked,strExcelPath,strExcelSavePath,MachineNames)
 
On Error Resume Next
 
'======================================
'Establishing connection with log files
'======================================
		
Set objOffline = objFSO.OpenTextFile(Offline, ForWriting)
Set objDeleted = objFSO.OpenTextFile(Deleted, ForAppending)
set objChecked = objFSO.OpenTextFile(Checked, ForWriting)
Set objMachineNames = objFSO.OpenTextFile(MachineNames, ForReading)
 
set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.DisplayAlerts = True
objExcel.Workbooks.Open(strExcelPath)
Set objSheet = objExcel.Worksheets(1)
objSheet.Name = "Profile Cleanup"
 
Do Until objMachineNames.AtEndOfStream
 
	strComputer = objMachineNames.readline
	strCurrentObject = strComputer
	intDel = cint(intDel)
		if not objFSO.FolderExists("\\" & strComputer & "\c$") then
				objOffline.writeLine strComputer
				
		else
			
			Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
			Set colFolders = objWMIService.ExecQuery ("Select * From Win32_Directory Where Path Like '%\\Documents and Settings\\'")
				
			For Each objFolder in colFolders
				strFoldername = objFolder.Name
								
				strNameLength=Len(strFoldername)
				strNewNameLength = strNameLength - 26
				strNewFolderName = Right(strFoldername, strNewNameLength)
			
				objChecked.writeline strComputer & " , " & strNewFolderName
				'msgbox(strComputer & ", " & strNewFolderName)
				If strNewFolderName = "administrator" OR strNewFolderName = "all users" OR strNewFolderName = "default user" OR strNewFolderName = "localservice" OR strNewFolderName = "networkservice" OR strNewFolderName = "brian.whitted" then
					
					'Nothing
				
				Else
				
					set ColFiles = objWMIService.ExecQuery ("Select * From CIM_DataFile Where Extension = 'dat' AND Path Like '%\\" & strNewFoldername & "\\'")
							
						For Each objFile in ColFiles
							strLongMod = objFile.LastModified
							strShortMod = left(strLongMod,8)
							strModYear = left(strShortMod,4)
							strModMD = right(strShortMod,4)
							strModDay = right(strModMD,2)
							strModMonth = left(strModMD,2)
							strCorrectModMonth = right(strModMonth,2)
							strModDate = strCorrectModMonth & "/" & strModDay & "/" & strModYear 
							strLastModDif = cint(DateDiff("d", strModDate, strDate))
							'msgbox(strLastModDif & " days since modification")
							
							If strLastModDif >= intDel then
							strDeletePath = "\\" & strComputer & "\c$\Documents and Settings\" & strNewFolderName
								'msgbox(strNewFolderName & " is being processed for deletion!")
								strSizePath = "\\" & strComputer & "\c$\Documents and Settings\" & strNewFolderName
								Call FolderSize(strSizePath, strFolderSize)
								strTotalSize = strTotalSize + strFolderSize
								strFolderSizeKB = strFolderSize / 1000
								strFolderSizeMB = strFolderSizeKB / 1000
								objFSO.DeleteFolder strDeletePath,TRUE
								If objFSO.FolderExists(strDeletePath) then
									'Folder failed to delete, will not log
								Else
								objDeleted.writeline "\\" & strComputer & "\c$\Documents and Settings\" & strNewFolderName
								objSheet.cells(x,1).Value = strSizePath
								objSheet.Cells(x,2).Value = strFolderSizeMB
								x = x + 1
								End If
								Set objShell = nothing
							else
								'msgbox("This folder is not old enough")
							end if
						Next
					End if
			Next
	end if
 
Loop
 
objSheet.SaveAs strExcelSavePath & "\profile cleanup group_" & strFileDate & ".xls"
objExcel.Application.Quit
Set objApp = Nothing
	
CurrentObject.innerText = ""
CurrentFolder.innerText = ""
CurrentStatus.innerText = "Action Complete"
Set objChecked = Nothing
Set objDeleted = Nothing
Set objOffline = Nothing
Set objFSO = Nothing
			
End Function
	
</script>
 
</HEAD>
<BODY onload="vbs:Window_OnLoad">
<DIV id="Background_DIV">
<img src= "\\baker\boiseIT$\scripts\script central\images\UAM background.bmp" height=100% width=100%/>
<script type="text/javascript">
	{
	window.resizeTo(400,300)
	window.moveTo(0,0);
	}	
</script>
 
<DIV id="LocationSelect_DIV">
<select size="1" width="30" name="SelectLocation" onchange="RunLocation">
    <option selected value="">Make a Selection</option>
    <option value="Boise">Boise</option>
    <option value="Seattle">Seattle</option>
</select>
</DIV>
 
<DIV id="GroupSelect_DIV" align="Center">
<span id="GroupSelect"></span>
</DIV>
<DIV id="ActionButton_DIV" align="Center">
<span id="StartAction"></span>
</DIV>
<DIV id="Status_DIV">
<span id="CurrentStatus"></span><br>
<span id="CurrentObject"></span><br>
<span id="CurrentFolder"></span>
</DIV>
</DIV>
</BODY>
</HTML>

Open in new window

0
 
LVL 12

Author Comment

by:piattnd
ID: 22918197
Not sure if you meant to, but you put the 2 subs inside another sub/function.  It ran and immediately quit.  I put them outside of all subs/functions and tried again, still no refresh, just a window that looks like its not responding... :(
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 22918270
OK, I should have used window.SetInterval instead of window.SetTimeOut, which is what BDF referred to in the first post....sorry BDF...

Try this out....
<HTML>
<HEAD>
<link rel="stylesheet" type="text/css"
href="\\baker\boiseIT$\scripts\Profile Cleanup\Profile Cleanup.css"/>
<TITLE>Profile Cleanup Utility</TITLE>
<HTA:APPLICATION 
     APPLICATIONNAME="User Account Management"
     SCROLL="no"
     BORDER="THIN"
     SINGLEINSTANCE="yes"
     WINDOWSTATE="normal"
     MINIMIZEBUTTON="no"
     MAXIMIZEBUTTON="no"
     ICON="\\baker\boiseIT$\scripts\Script Central\icons\icon.ico"
>
 
<script language="VBScript">
'On error resume next
'=====================
'Defining variables
'=====================
Const ForReading = 1
const ForWriting = 2
Const ForAppending = 8
Const ADS_SCOPE_SUBTREE = 2
Dim strCurrentObject
strCurrentObject = ""
 
strDate = Date()
x = 2
strTotalSize = 0
strMonth = Month(Now)
strDay = Day(Now)
strYear = Year(Now)
 
'--------------------------------------------------
'Establishing connection to AD
'--------------------------------------------------
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE 
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
'*********************************************************************
'Correcting format of the Day variable and creating file date variable.
'*********************************************************************
If len(strDay) = 1 then
 
	strDay = "0" & strDay
	
End If
 
strFileDate = strMonth & strDay & strYear
 
Sub Window_OnLoad
	idTimer = window.setInterval("UpdateStatus", 2000, "VBScript")
End Sub
 
Sub UpdateStatus
	If strCurrentObject <> "" Then CurrentObject.innerText = "Machine: " & strCurrentObject & VbCrLf
End Sub
 
'****************************
'Function to determine size
'****************************
Function FolderSize(strSizePath, strFolderSize)
	set objFolderSize = objFSO.GetFolder(strSizePath)
	strFolderSize = objFolderSize.size
End Function
 
'================================
'Determine location to run script
'================================    
    Sub RunLocation
	
		strLocation = SelectLocation.Value
		strGroup = ""
		
		select case strLocation
			case ""
				GroupSelect.innerHTML = ""
				
			case "Boise"
				GroupSelect.innerHTML = "<select size='1' width='50' name='SelectGroup' onchange='BoiseSetGroupInfo'>" &_
					"<option selected value=''>Make a Selection</option>" &_
					"<option value='PPD'>PPD</option>" &_
					"<option value='WDTS'>WDTS</option>" &_
					"<option value='TRN'>TRN</option></select>"
								
			case "Seattle"
				GroupSelect.innerHTML = "<select size='1' width='50' name='SelectGroup' onchange='SeattleSetGroupInfo'>" &_
					"<option selected value=''>Make a Selection</option>" &_
					"<option value='TMO'>TMO</option>" &_
					"<option value='VZW'>VZW</option>" &_
					"<option value='POO'>POO</option>" &_
					"<option value='TRN'>TRN</option></select>"
			
		End Select
	
	End Sub
	
	Sub SeattleSetGroupInfo
		
		strGroup = SelectGroup.Value
			Offline = "\\rainier\seattleIT$\Profile Cleanup\offline.txt"
			Deleted = "\\rainier\seattleIT$\Profile Cleanup\deleted.txt"
			Checked = "\\rainier\seattleIT$\Profile Cleanup\checked.txt"
			strExcelPath = "\\rainier\seattleIT$\Profile Cleanup\profile cleanup.xls"
			strGroupLocation = "LDAP://ou=seattle,ou=us,ou=wdsglobal,dc=corp,dc=wdsglobal,dc=com"
			strExcelSavePath = "\\rainier\seattleIT$\Profile Cleanup"
			MachineNames = "\\rainier\seattleIT$\Profile Cleanup\machinenames.txt"
							
				select case strGroup
				
					case ""
						'Nothing
						
					case "TMO"
						strMachineGroup = "SCUS-TMO*"
						intDel = 60
						StartAction.innerHTML = "<input type='button' value='Start Cleanup' name='start_cleanup' onClick='ProcessGroup """ & MachineNames & ""","""  & Offline & """,""" & Deleted & """,""" & Checked & """,""" & strExcelPath & """,""" & strMachineGroup & """,""" & strGroupLocation & """,""" & intDel & """,""" & strExcelSavePath & """'>"
					
					case "VZW"
						strMachineGroup = "SCUS-VZW*"
						intDel = 60
						StartAction.innerHTML = "<input type='button' value='Start Cleanup' name='start_cleanup' onClick='ProcessGroup """ & MachineNames & ""","""  & Offline & """,""" & Deleted & """,""" & Checked & """,""" & strExcelPath & """,""" & strMachineGroup & """,""" & strGroupLocation & """,""" & intDel & """,""" & strExcelSavePath & """'>"
 
					case "POO"
						strMachineGroup = "SCUS-POO*"
						intDel = 60
						StartAction.innerHTML = "<input type='button' value='Start Cleanup' name='start_cleanup' onClick='ProcessGroup """ & MachineNames & ""","""  & Offline & """,""" & Deleted & """,""" & Checked & """,""" & strExcelPath & """,""" & strMachineGroup & """,""" & strGroupLocation & """,""" & intDel & """,""" & strExcelSavePath & """'>"
 
					case "TRN"
						strMachineGroup = "TRNUS*"
						intDel = 45
						StartAction.innerHTML = "<input type='button' value='Start Cleanup' name='start_cleanup' onClick='ProcessGroup """ & MachineNames & ""","""  & Offline & """,""" & Deleted & """,""" & Checked & """,""" & strExcelPath & """,""" & strMachineGroup & """,""" & strGroupLocation & """,""" & intDel & """,""" & strExcelSavePath & """'>"
				
				End Select		
	End Sub
	
	Sub BoiseSetGroupInfo
		
		strGroup = SelectGroup.Value
			Offline = "\\baker\boiseIT$\scripts\Profile Cleanup\offline.txt"
			Deleted = "\\baker\boiseIT$\scripts\Profile Cleanup\deleted.txt"
			Checked = "\\baker\boiseIT$\scripts\Profile Cleanup\checked.txt"
			strExcelPath = "\\baker\boiseIT$\scripts\Profile Cleanup\profile cleanup.xls"
			strGroupLocation = "LDAP://ou=boise,ou=us,ou=wdsglobal,dc=corp,dc=wdsglobal,dc=com"
			strExcelSavePath = "\\baker\boiseIT$\scripts\Profile Cleanup"
			MachineNames = "\\baker\boiseIT$\scripts\Profile Cleanup\machinenames.txt"
							
				select case strGroup
				
					case ""
						'Nothing
						
					case "PPD"
						strMachineGroup = "SCID-PPD*"
						intDel = 60
						StartAction.innerHTML = "<input type='button' value='Start Cleanup' name='start_cleanup' onClick='ProcessGroup """ & MachineNames & ""","""  & Offline & """,""" & Deleted & """,""" & Checked & """,""" & strExcelPath & """,""" & strMachineGroup & """,""" & strGroupLocation & """,""" & intDel & """,""" & strExcelSavePath & """'>"
					
					case "WDTS"
						strMachineGroup = "SCID-WDTS*"
						intDel = 60
						StartAction.innerHTML = "<input type='button' value='Start Cleanup' name='start_cleanup' onClick='ProcessGroup """ & MachineNames & ""","""  & Offline & """,""" & Deleted & """,""" & Checked & """,""" & strExcelPath & """,""" & strMachineGroup & """,""" & strGroupLocation & """,""" & intDel & """,""" & strExcelSavePath & """'>"
 
					case "TRN"
						strMachineGroup = "TRNID*"
						intDel = 45
						StartAction.innerHTML = "<input type='button' value='Start Cleanup' name='start_cleanup' onClick='ProcessGroup """ & MachineNames & """,""" & Offline & """,""" & Deleted & """,""" & Checked & """,""" & strExcelPath & """,""" & strMachineGroup & """,""" & strGroupLocation & """,""" & intDel & """,""" & strExcelSavePath & """'>"
				
				End Select
				
	End Sub
	
Function ProcessGroup(MachineNames,Offline,Deleted,Checked,strExcelPath,strMachineGroup,strGroupLocation,intDel,strExcelSavePath)
 
CurrentStatus.innerText = "Getting machine list.... please wait"
		
If NOT objFSO.FileExists(MachineNames) then
	objFSO.CreateTextFile(MachineNames)
	
	Else
	Set objMachineNames = objFSO.OpenTextFile(MachineNames,ForWriting)
		
		objCommand.CommandText = strMachineGroup
		objCommand.CommandText = "SELECT Name, dNSHostName FROM '" & strGroupLocation & "' WHERE objectCategory='computer' AND dNSHostName='" & strMachineGroup & "'"
		Set objRecordSet = objCommand.Execute
		
	objRecordSet.MoveFirst		
		
Do Until objRecordSet.EOF
	
	strComputer = objRecordSet.Fields("Name").Value
	objMachineNames.writeline strComputer
	
objRecordSet.MoveNext
Loop
End If
 
CurrentStatus.innerText = "Processing machine list.... please wait"
set ObjMachineNames = nothing
 
CheckFolderAge intDel,Offline,Deleted,Checked,strExcelPath,strExcelSavePath,MachineNames
	
End Function
	
Function CheckFolderAge(intDel,Offline,Deleted,Checked,strExcelPath,strExcelSavePath,MachineNames)
 
On Error Resume Next
 
'======================================
'Establishing connection with log files
'======================================
		
Set objOffline = objFSO.OpenTextFile(Offline, ForWriting)
Set objDeleted = objFSO.OpenTextFile(Deleted, ForAppending)
set objChecked = objFSO.OpenTextFile(Checked, ForWriting)
Set objMachineNames = objFSO.OpenTextFile(MachineNames, ForReading)
 
set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.DisplayAlerts = True
objExcel.Workbooks.Open(strExcelPath)
Set objSheet = objExcel.Worksheets(1)
objSheet.Name = "Profile Cleanup"
 
Do Until objMachineNames.AtEndOfStream
 
	strComputer = objMachineNames.readline
	strCurrentObject = strComputer
	intDel = cint(intDel)
		if not objFSO.FolderExists("\\" & strComputer & "\c$") then
				objOffline.writeLine strComputer
				
		else
			
			Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
			Set colFolders = objWMIService.ExecQuery ("Select * From Win32_Directory Where Path Like '%\\Documents and Settings\\'")
				
			For Each objFolder in colFolders
				strFoldername = objFolder.Name
								
				strNameLength=Len(strFoldername)
				strNewNameLength = strNameLength - 26
				strNewFolderName = Right(strFoldername, strNewNameLength)
			
				objChecked.writeline strComputer & " , " & strNewFolderName
				'msgbox(strComputer & ", " & strNewFolderName)
				If strNewFolderName = "administrator" OR strNewFolderName = "all users" OR strNewFolderName = "default user" OR strNewFolderName = "localservice" OR strNewFolderName = "networkservice" OR strNewFolderName = "brian.whitted" then
					
					'Nothing
				
				Else
				
					set ColFiles = objWMIService.ExecQuery ("Select * From CIM_DataFile Where Extension = 'dat' AND Path Like '%\\" & strNewFoldername & "\\'")
							
						For Each objFile in ColFiles
							strLongMod = objFile.LastModified
							strShortMod = left(strLongMod,8)
							strModYear = left(strShortMod,4)
							strModMD = right(strShortMod,4)
							strModDay = right(strModMD,2)
							strModMonth = left(strModMD,2)
							strCorrectModMonth = right(strModMonth,2)
							strModDate = strCorrectModMonth & "/" & strModDay & "/" & strModYear 
							strLastModDif = cint(DateDiff("d", strModDate, strDate))
							'msgbox(strLastModDif & " days since modification")
							
							If strLastModDif >= intDel then
							strDeletePath = "\\" & strComputer & "\c$\Documents and Settings\" & strNewFolderName
								'msgbox(strNewFolderName & " is being processed for deletion!")
								strSizePath = "\\" & strComputer & "\c$\Documents and Settings\" & strNewFolderName
								Call FolderSize(strSizePath, strFolderSize)
								strTotalSize = strTotalSize + strFolderSize
								strFolderSizeKB = strFolderSize / 1000
								strFolderSizeMB = strFolderSizeKB / 1000
								objFSO.DeleteFolder strDeletePath,TRUE
								If objFSO.FolderExists(strDeletePath) then
									'Folder failed to delete, will not log
								Else
								objDeleted.writeline "\\" & strComputer & "\c$\Documents and Settings\" & strNewFolderName
								objSheet.cells(x,1).Value = strSizePath
								objSheet.Cells(x,2).Value = strFolderSizeMB
								x = x + 1
								End If
								Set objShell = nothing
							else
								'msgbox("This folder is not old enough")
							end if
						Next
					End if
			Next
	end if
 
Loop
 
objSheet.SaveAs strExcelSavePath & "\profile cleanup group_" & strFileDate & ".xls"
objExcel.Application.Quit
Set objApp = Nothing
	
CurrentObject.innerText = ""
CurrentFolder.innerText = ""
CurrentStatus.innerText = "Action Complete"
Set objChecked = Nothing
Set objDeleted = Nothing
Set objOffline = Nothing
Set objFSO = Nothing
			
End Function
	
</script>
 
</HEAD>
<BODY onload="vbs:Window_OnLoad">
<DIV id="Background_DIV">
<img src= "\\baker\boiseIT$\scripts\script central\images\UAM background.bmp" height=100% width=100%/>
<script type="text/javascript">
	{
	window.resizeTo(400,300)
	window.moveTo(0,0);
	}	
</script>
 
<DIV id="LocationSelect_DIV">
<select size="1" width="30" name="SelectLocation" onchange="RunLocation">
    <option selected value="">Make a Selection</option>
    <option value="Boise">Boise</option>
    <option value="Seattle">Seattle</option>
</select>
</DIV>
 
<DIV id="GroupSelect_DIV" align="Center">
<span id="GroupSelect"></span>
</DIV>
<DIV id="ActionButton_DIV" align="Center">
<span id="StartAction"></span>
</DIV>
<DIV id="Status_DIV">
<span id="CurrentStatus"></span><br>
<span id="CurrentObject"></span><br>
<span id="CurrentFolder"></span>
</DIV>
</DIV>
</BODY>
</HTML>

Open in new window

0
 
LVL 12

Author Comment

by:piattnd
ID: 22923987
So I tried your code, and still, just a window that looks like it's not responding once I've kicked off the script.

Does it have anything to do with the script looping through hundreds of machines?  I've tried posting updates to the GUI and the delay statement throughout the loop with no success...
0
 
LVL 14

Assisted Solution

by:rejoinder
rejoinder earned 400 total points
ID: 22925332
Please try this script.  The script should popup a little please wait box at each loop.  See line 227.
result = WshShell.Popup("Please wait...", 1)
Now... the popup should only stay up for about a second but should be enough to refreash the screen.
The number at the end represents the number of seconds the popup is to last before it should close itself.  After a little testing on a script I run here which has similar issues, I found that sometimes the popup would stay on screen for the duration of the function/sub.  It could be that the popup closed but the screen area never refreshed until the next loop and popup is displayed.
<HTML>
<HEAD>
<link rel="stylesheet" type="text/css"
href="\\baker\boiseIT$\scripts\Profile Cleanup\Profile Cleanup.css"/>
<TITLE>Profile Cleanup Utility</TITLE>
<HTA:APPLICATION 
     APPLICATIONNAME="User Account Management"
     SCROLL="no"
     BORDER="THIN"
     SINGLEINSTANCE="yes"
     WINDOWSTATE="normal"
     MINIMIZEBUTTON="no"
     MAXIMIZEBUTTON="no"
     ICON="\\baker\boiseIT$\scripts\Script Central\icons\icon.ico"
>
 
<script language="VBScript">
'On error resume next
'=====================
'Defining variables
'=====================
Const ForReading = 1
const ForWriting = 2
Const ForAppending = 8
Const ADS_SCOPE_SUBTREE = 2
 
strDate = Date()
x = 2
strTotalSize = 0
strMonth = Month(Now)
strDay = Day(Now)
strYear = Year(Now)
 
Set WshShell = CreateObject("WScript.Shell")
 
'--------------------------------------------------
'Establishing connection to AD
'--------------------------------------------------
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE 
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
'*********************************************************************
'Correcting format of the Day variable and creating file date variable.
'*********************************************************************
If len(strDay) = 1 then
 
	strDay = "0" & strDay
	
End If
 
strFileDate = strMonth & strDay & strYear
 
'****************************
'Function to determine size
'****************************
Function FolderSize(strSizePath, strFolderSize)
	set objFolderSize = objFSO.GetFolder(strSizePath)
	strFolderSize = objFolderSize.size
End Function
 
'================================
'Determine location to run script
'================================    
    Sub RunLocation
	
		strLocation = SelectLocation.Value
		strGroup = ""
		
		select case strLocation
			case ""
				GroupSelect.innerHTML = ""
				
			case "Boise"
				GroupSelect.innerHTML = "<select size='1' width='50' name='SelectGroup' onchange='BoiseSetGroupInfo'>" &_
					"<option selected value=''>Make a Selection</option>" &_
					"<option value='PPD'>PPD</option>" &_
					"<option value='WDTS'>WDTS</option>" &_
					"<option value='TRN'>TRN</option></select>"
								
			case "Seattle"
				GroupSelect.innerHTML = "<select size='1' width='50' name='SelectGroup' onchange='SeattleSetGroupInfo'>" &_
					"<option selected value=''>Make a Selection</option>" &_
					"<option value='TMO'>TMO</option>" &_
					"<option value='VZW'>VZW</option>" &_
					"<option value='POO'>POO</option>" &_
					"<option value='TRN'>TRN</option></select>"
			
		End Select
	
	End Sub
	
	Sub SeattleSetGroupInfo
		
		strGroup = SelectGroup.Value
			Offline = "\\rainier\seattleIT$\Profile Cleanup\offline.txt"
			Deleted = "\\rainier\seattleIT$\Profile Cleanup\deleted.txt"
			Checked = "\\rainier\seattleIT$\Profile Cleanup\checked.txt"
			strExcelPath = "\\rainier\seattleIT$\Profile Cleanup\profile cleanup.xls"
			strGroupLocation = "LDAP://ou=seattle,ou=us,ou=wdsglobal,dc=corp,dc=wdsglobal,dc=com"
			strExcelSavePath = "\\rainier\seattleIT$\Profile Cleanup"
			MachineNames = "\\rainier\seattleIT$\Profile Cleanup\machinenames.txt"
							
				select case strGroup
				
					case ""
						'Nothing
						
					case "TMO"
						strMachineGroup = "SCUS-TMO*"
						intDel = 60
						StartAction.innerHTML = "<input type='button' value='Start Cleanup' name='start_cleanup' onClick='ProcessGroup """ & MachineNames & ""","""  & Offline & """,""" & Deleted & """,""" & Checked & """,""" & strExcelPath & """,""" & strMachineGroup & """,""" & strGroupLocation & """,""" & intDel & """,""" & strExcelSavePath & """'>"
					
					case "VZW"
						strMachineGroup = "SCUS-VZW*"
						intDel = 60
						StartAction.innerHTML = "<input type='button' value='Start Cleanup' name='start_cleanup' onClick='ProcessGroup """ & MachineNames & ""","""  & Offline & """,""" & Deleted & """,""" & Checked & """,""" & strExcelPath & """,""" & strMachineGroup & """,""" & strGroupLocation & """,""" & intDel & """,""" & strExcelSavePath & """'>"
 
					case "POO"
						strMachineGroup = "SCUS-POO*"
						intDel = 60
						StartAction.innerHTML = "<input type='button' value='Start Cleanup' name='start_cleanup' onClick='ProcessGroup """ & MachineNames & ""","""  & Offline & """,""" & Deleted & """,""" & Checked & """,""" & strExcelPath & """,""" & strMachineGroup & """,""" & strGroupLocation & """,""" & intDel & """,""" & strExcelSavePath & """'>"
 
					case "TRN"
						strMachineGroup = "TRNUS*"
						intDel = 45
						StartAction.innerHTML = "<input type='button' value='Start Cleanup' name='start_cleanup' onClick='ProcessGroup """ & MachineNames & ""","""  & Offline & """,""" & Deleted & """,""" & Checked & """,""" & strExcelPath & """,""" & strMachineGroup & """,""" & strGroupLocation & """,""" & intDel & """,""" & strExcelSavePath & """'>"
				
				End Select		
	End Sub
	
	Sub BoiseSetGroupInfo
		
		strGroup = SelectGroup.Value
			Offline = "\\baker\boiseIT$\scripts\Profile Cleanup\offline.txt"
			Deleted = "\\baker\boiseIT$\scripts\Profile Cleanup\deleted.txt"
			Checked = "\\baker\boiseIT$\scripts\Profile Cleanup\checked.txt"
			strExcelPath = "\\baker\boiseIT$\scripts\Profile Cleanup\profile cleanup.xls"
			strGroupLocation = "LDAP://ou=boise,ou=us,ou=wdsglobal,dc=corp,dc=wdsglobal,dc=com"
			strExcelSavePath = "\\baker\boiseIT$\scripts\Profile Cleanup"
			MachineNames = "\\baker\boiseIT$\scripts\Profile Cleanup\machinenames.txt"
							
				select case strGroup
				
					case ""
						'Nothing
						
					case "PPD"
						strMachineGroup = "SCID-PPD*"
						intDel = 60
						StartAction.innerHTML = "<input type='button' value='Start Cleanup' name='start_cleanup' onClick='ProcessGroup """ & MachineNames & ""","""  & Offline & """,""" & Deleted & """,""" & Checked & """,""" & strExcelPath & """,""" & strMachineGroup & """,""" & strGroupLocation & """,""" & intDel & """,""" & strExcelSavePath & """'>"
					
					case "WDTS"
						strMachineGroup = "SCID-WDTS*"
						intDel = 60
						StartAction.innerHTML = "<input type='button' value='Start Cleanup' name='start_cleanup' onClick='ProcessGroup """ & MachineNames & ""","""  & Offline & """,""" & Deleted & """,""" & Checked & """,""" & strExcelPath & """,""" & strMachineGroup & """,""" & strGroupLocation & """,""" & intDel & """,""" & strExcelSavePath & """'>"
 
					case "TRN"
						strMachineGroup = "TRNID*"
						intDel = 45
						StartAction.innerHTML = "<input type='button' value='Start Cleanup' name='start_cleanup' onClick='ProcessGroup """ & MachineNames & """,""" & Offline & """,""" & Deleted & """,""" & Checked & """,""" & strExcelPath & """,""" & strMachineGroup & """,""" & strGroupLocation & """,""" & intDel & """,""" & strExcelSavePath & """'>"
				
				End Select
				
	End Sub
	
Function ProcessGroup(MachineNames,Offline,Deleted,Checked,strExcelPath,strMachineGroup,strGroupLocation,intDel,strExcelSavePath)
 
CurrentStatus.innerText = "Getting machine list.... please wait"
		
If NOT objFSO.FileExists(MachineNames) then
	objFSO.CreateTextFile(MachineNames)
	
	Else
	Set objMachineNames = objFSO.OpenTextFile(MachineNames,ForWriting)
		
		objCommand.CommandText = strMachineGroup
		objCommand.CommandText = "SELECT Name, dNSHostName FROM '" & strGroupLocation & "' WHERE objectCategory='computer' AND dNSHostName='" & strMachineGroup & "'"
		Set objRecordSet = objCommand.Execute
		
	objRecordSet.MoveFirst		
		
Do Until objRecordSet.EOF
	
	strComputer = objRecordSet.Fields("Name").Value
	objMachineNames.writeline strComputer
	
objRecordSet.MoveNext
Loop
End If
 
CurrentStatus.innerText = "Processing machine list.... please wait"
set ObjMachineNames = nothing
 
CheckFolderAge intDel,Offline,Deleted,Checked,strExcelPath,strExcelSavePath,MachineNames
	
End Function
	
Function CheckFolderAge(intDel,Offline,Deleted,Checked,strExcelPath,strExcelSavePath,MachineNames)
 
On Error Resume Next
 
'======================================
'Establishing connection with log files
'======================================
		
Set objOffline = objFSO.OpenTextFile(Offline, ForWriting)
Set objDeleted = objFSO.OpenTextFile(Deleted, ForAppending)
set objChecked = objFSO.OpenTextFile(Checked, ForWriting)
Set objMachineNames = objFSO.OpenTextFile(MachineNames, ForReading)
 
set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.DisplayAlerts = True
objExcel.Workbooks.Open(strExcelPath)
Set objSheet = objExcel.Worksheets(1)
objSheet.Name = "Profile Cleanup"
 
Do Until objMachineNames.AtEndOfStream
 
	strComputer = objMachineNames.readline
        result = WshShell.Popup("Please wait...", 1)
	CurrentObject.innerText = "Machine: " & strComputer
	intDel = cint(intDel)
		if not objFSO.FolderExists("\\" & strComputer & "\c$") then
				objOffline.writeLine strComputer
				
		else
			
			Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
			Set colFolders = objWMIService.ExecQuery ("Select * From Win32_Directory Where Path Like '%\\Documents and Settings\\'")
				
			For Each objFolder in colFolders
				strFoldername = objFolder.Name
								
				strNameLength=Len(strFoldername)
				strNewNameLength = strNameLength - 26
				strNewFolderName = Right(strFoldername, strNewNameLength)
			
				objChecked.writeline strComputer & " , " & strNewFolderName
				'msgbox(strComputer & ", " & strNewFolderName)
				If strNewFolderName = "administrator" OR strNewFolderName = "all users" OR strNewFolderName = "default user" OR strNewFolderName = "localservice" OR strNewFolderName = "networkservice" OR strNewFolderName = "brian.whitted" then
					
					'Nothing
				
				Else
				
					set ColFiles = objWMIService.ExecQuery ("Select * From CIM_DataFile Where Extension = 'dat' AND Path Like '%\\" & strNewFoldername & "\\'")
							
						For Each objFile in ColFiles
							strLongMod = objFile.LastModified
							strShortMod = left(strLongMod,8)
							strModYear = left(strShortMod,4)
							strModMD = right(strShortMod,4)
							strModDay = right(strModMD,2)
							strModMonth = left(strModMD,2)
							strCorrectModMonth = right(strModMonth,2)
							strModDate = strCorrectModMonth & "/" & strModDay & "/" & strModYear 
							strLastModDif = cint(DateDiff("d", strModDate, strDate))
							'msgbox(strLastModDif & " days since modification")
							
							If strLastModDif >= intDel then
							strDeletePath = "\\" & strComputer & "\c$\Documents and Settings\" & strNewFolderName
								'msgbox(strNewFolderName & " is being processed for deletion!")
								strSizePath = "\\" & strComputer & "\c$\Documents and Settings\" & strNewFolderName
								Call FolderSize(strSizePath, strFolderSize)
								strTotalSize = strTotalSize + strFolderSize
								strFolderSizeKB = strFolderSize / 1000
								strFolderSizeMB = strFolderSizeKB / 1000
								objFSO.DeleteFolder strDeletePath,TRUE
								If objFSO.FolderExists(strDeletePath) then
									'Folder failed to delete, will not log
								Else
								objDeleted.writeline "\\" & strComputer & "\c$\Documents and Settings\" & strNewFolderName
								objSheet.cells(x,1).Value = strSizePath
								objSheet.Cells(x,2).Value = strFolderSizeMB
								x = x + 1
								End If
								Set objShell = nothing
							else
								'msgbox("This folder is not old enough")
							end if
						Next
					End if
			Next
	end if
 
Loop
 
objSheet.SaveAs strExcelSavePath & "\profile cleanup group_" & strFileDate & ".xls"
objExcel.Application.Quit
Set objApp = Nothing
	
CurrentObject.innerText = ""
CurrentFolder.innerText = ""
CurrentStatus.innerText = "Action Complete"
Set objChecked = Nothing
Set objDeleted = Nothing
Set objOffline = Nothing
Set objFSO = Nothing
			
End Function
	
</script>
 
</HEAD>
<BODY>
<DIV id="Background_DIV">
<img src= "\\baker\boiseIT$\scripts\script central\images\UAM background.bmp" height=100% width=100%/>
<script type="text/javascript">
	{
	window.resizeTo(400,300)
	window.moveTo(0,0);
	}	
</script>
 
<DIV id="LocationSelect_DIV">
<select size="1" width="30" name="SelectLocation" onchange="RunLocation">
    <option selected value="">Make a Selection</option>
    <option value="Boise">Boise</option>
    <option value="Seattle">Seattle</option>
</select>
</DIV>
 
<DIV id="GroupSelect_DIV" align="Center">
<span id="GroupSelect"></span>
</DIV>
<DIV id="ActionButton_DIV" align="Center">
<span id="StartAction"></span>
</DIV>
<DIV id="Status_DIV">
<span id="CurrentStatus"></span><br>
<span id="CurrentObject"></span><br>
<span id="CurrentFolder"></span>
</DIV>
</DIV>
</BODY>
</HTML>

Open in new window

0
 
LVL 12

Author Comment

by:piattnd
ID: 22925727
I'd like to do this without a popup box, as sometimes the box has gotten stuck and I have to click ok.  This causes a problem because the script will (a lot of times) be run over night or just expected to complete without user interaction.

After speaking with a friend of mine, it sounds like the window.settimeout will ONLY work if it's the very last line of a sub AND the sub that calls that sub calls the sub as the very last line.  For example, Sub A calls sub B on the very last line of the sub.  Sub B calls sub C with the settimeout command and is the very last line in sub B.  Sub C calls back to Sub B.

In that scenario, sub A gathers all data and sets all variables needing to be set, sub B updates the gui, and sub C does the work.  Sounds like a major overhaul to what I have currently, which means more headache.  I'll leave this question open for a few days while I work on restructuring my program.
0
 
LVL 65

Accepted Solution

by:
RobSampson earned 1600 total points
ID: 22927018
Hi, the window.SetInterval has worked for me.....I have a HTA that reads event logs.  It displays a clock that shows the elapsed time in seconds as it goes.  When I comment out this line in my code

iTimerID = window.setInterval("UpdateProgress", 1000)

that display goes to 3 seconds, pauses a bit, and jumps to 8.  If I let the timer do its work, the display shows every second.

So, in theory, I though the below should work.....although, I can't test yours, because of the functionality it requires....

This will *only* update the current object status as it goes from machine to machine, which happens in the CheckFolderAge sub.

Regards,

Rob.
<HTML>
<HEAD>
<link rel="stylesheet" type="text/css"
href="\\baker\boiseIT$\scripts\Profile Cleanup\Profile Cleanup.css"/>
<TITLE>Profile Cleanup Utility</TITLE>
<HTA:APPLICATION 
     APPLICATIONNAME="User Account Management"
     SCROLL="no"
     BORDER="THIN"
     SINGLEINSTANCE="yes"
     WINDOWSTATE="normal"
     MINIMIZEBUTTON="no"
     MAXIMIZEBUTTON="no"
     ICON="\\baker\boiseIT$\scripts\Script Central\icons\icon.ico"
>
 
<script language="VBScript">
'On error resume next
'=====================
'Defining variables
'=====================
Const ForReading = 1
const ForWriting = 2
Const ForAppending = 8
Const ADS_SCOPE_SUBTREE = 2
Dim strCurrentObject
strCurrentObject = ""
 
strDate = Date()
x = 2
strTotalSize = 0
strMonth = Month(Now)
strDay = Day(Now)
strYear = Year(Now)
 
'--------------------------------------------------
'Establishing connection to AD
'--------------------------------------------------
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE 
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
'*********************************************************************
'Correcting format of the Day variable and creating file date variable.
'*********************************************************************
If len(strDay) = 1 then
 
	strDay = "0" & strDay
	
End If
 
strFileDate = strMonth & strDay & strYear
 
Sub Window_OnLoad
	idTimer = window.setInterval("UpdateStatus", 1000, "VBScript")
End Sub
 
Sub UpdateStatus
	If strCurrentObject <> "" Then
		CurrentObject.innerText = "Machine: " & strCurrentObject & VbCrLf
	Else
		CurrentObject.innerText = ""
	End If
End Sub
 
'****************************
'Function to determine size
'****************************
Function FolderSize(strSizePath, strFolderSize)
	set objFolderSize = objFSO.GetFolder(strSizePath)
	strFolderSize = objFolderSize.size
End Function
 
'================================
'Determine location to run script
'================================    
    Sub RunLocation
	
		strLocation = SelectLocation.Value
		strGroup = ""
		
		select case strLocation
			case ""
				GroupSelect.innerHTML = ""
				
			case "Boise"
				GroupSelect.innerHTML = "<select size='1' width='50' name='SelectGroup' onchange='BoiseSetGroupInfo'>" &_
					"<option selected value=''>Make a Selection</option>" &_
					"<option value='PPD'>PPD</option>" &_
					"<option value='WDTS'>WDTS</option>" &_
					"<option value='TRN'>TRN</option></select>"
								
			case "Seattle"
				GroupSelect.innerHTML = "<select size='1' width='50' name='SelectGroup' onchange='SeattleSetGroupInfo'>" &_
					"<option selected value=''>Make a Selection</option>" &_
					"<option value='TMO'>TMO</option>" &_
					"<option value='VZW'>VZW</option>" &_
					"<option value='POO'>POO</option>" &_
					"<option value='TRN'>TRN</option></select>"
			
		End Select
	
	End Sub
	
	Sub SeattleSetGroupInfo
		
		strGroup = SelectGroup.Value
			Offline = "\\rainier\seattleIT$\Profile Cleanup\offline.txt"
			Deleted = "\\rainier\seattleIT$\Profile Cleanup\deleted.txt"
			Checked = "\\rainier\seattleIT$\Profile Cleanup\checked.txt"
			strExcelPath = "\\rainier\seattleIT$\Profile Cleanup\profile cleanup.xls"
			strGroupLocation = "LDAP://ou=seattle,ou=us,ou=wdsglobal,dc=corp,dc=wdsglobal,dc=com"
			strExcelSavePath = "\\rainier\seattleIT$\Profile Cleanup"
			MachineNames = "\\rainier\seattleIT$\Profile Cleanup\machinenames.txt"
							
				select case strGroup
				
					case ""
						'Nothing
						
					case "TMO"
						strMachineGroup = "SCUS-TMO*"
						intDel = 60
						StartAction.innerHTML = "<input type='button' value='Start Cleanup' name='start_cleanup' onClick='ProcessGroup """ & MachineNames & ""","""  & Offline & """,""" & Deleted & """,""" & Checked & """,""" & strExcelPath & """,""" & strMachineGroup & """,""" & strGroupLocation & """,""" & intDel & """,""" & strExcelSavePath & """'>"
					
					case "VZW"
						strMachineGroup = "SCUS-VZW*"
						intDel = 60
						StartAction.innerHTML = "<input type='button' value='Start Cleanup' name='start_cleanup' onClick='ProcessGroup """ & MachineNames & ""","""  & Offline & """,""" & Deleted & """,""" & Checked & """,""" & strExcelPath & """,""" & strMachineGroup & """,""" & strGroupLocation & """,""" & intDel & """,""" & strExcelSavePath & """'>"
 
					case "POO"
						strMachineGroup = "SCUS-POO*"
						intDel = 60
						StartAction.innerHTML = "<input type='button' value='Start Cleanup' name='start_cleanup' onClick='ProcessGroup """ & MachineNames & ""","""  & Offline & """,""" & Deleted & """,""" & Checked & """,""" & strExcelPath & """,""" & strMachineGroup & """,""" & strGroupLocation & """,""" & intDel & """,""" & strExcelSavePath & """'>"
 
					case "TRN"
						strMachineGroup = "TRNUS*"
						intDel = 45
						StartAction.innerHTML = "<input type='button' value='Start Cleanup' name='start_cleanup' onClick='ProcessGroup """ & MachineNames & ""","""  & Offline & """,""" & Deleted & """,""" & Checked & """,""" & strExcelPath & """,""" & strMachineGroup & """,""" & strGroupLocation & """,""" & intDel & """,""" & strExcelSavePath & """'>"
				
				End Select		
	End Sub
	
	Sub BoiseSetGroupInfo
		
		strGroup = SelectGroup.Value
			Offline = "\\baker\boiseIT$\scripts\Profile Cleanup\offline.txt"
			Deleted = "\\baker\boiseIT$\scripts\Profile Cleanup\deleted.txt"
			Checked = "\\baker\boiseIT$\scripts\Profile Cleanup\checked.txt"
			strExcelPath = "\\baker\boiseIT$\scripts\Profile Cleanup\profile cleanup.xls"
			strGroupLocation = "LDAP://ou=boise,ou=us,ou=wdsglobal,dc=corp,dc=wdsglobal,dc=com"
			strExcelSavePath = "\\baker\boiseIT$\scripts\Profile Cleanup"
			MachineNames = "\\baker\boiseIT$\scripts\Profile Cleanup\machinenames.txt"
							
				select case strGroup
				
					case ""
						'Nothing
						
					case "PPD"
						strMachineGroup = "SCID-PPD*"
						intDel = 60
						StartAction.innerHTML = "<input type='button' value='Start Cleanup' name='start_cleanup' onClick='ProcessGroup """ & MachineNames & ""","""  & Offline & """,""" & Deleted & """,""" & Checked & """,""" & strExcelPath & """,""" & strMachineGroup & """,""" & strGroupLocation & """,""" & intDel & """,""" & strExcelSavePath & """'>"
					
					case "WDTS"
						strMachineGroup = "SCID-WDTS*"
						intDel = 60
						StartAction.innerHTML = "<input type='button' value='Start Cleanup' name='start_cleanup' onClick='ProcessGroup """ & MachineNames & ""","""  & Offline & """,""" & Deleted & """,""" & Checked & """,""" & strExcelPath & """,""" & strMachineGroup & """,""" & strGroupLocation & """,""" & intDel & """,""" & strExcelSavePath & """'>"
 
					case "TRN"
						strMachineGroup = "TRNID*"
						intDel = 45
						StartAction.innerHTML = "<input type='button' value='Start Cleanup' name='start_cleanup' onClick='ProcessGroup """ & MachineNames & """,""" & Offline & """,""" & Deleted & """,""" & Checked & """,""" & strExcelPath & """,""" & strMachineGroup & """,""" & strGroupLocation & """,""" & intDel & """,""" & strExcelSavePath & """'>"
				
				End Select
				
	End Sub
	
Function ProcessGroup(MachineNames,Offline,Deleted,Checked,strExcelPath,strMachineGroup,strGroupLocation,intDel,strExcelSavePath)
 
CurrentStatus.innerText = "Getting machine list.... please wait"
		
If NOT objFSO.FileExists(MachineNames) then
	objFSO.CreateTextFile(MachineNames)
	
	Else
	Set objMachineNames = objFSO.OpenTextFile(MachineNames,ForWriting)
		
		objCommand.CommandText = strMachineGroup
		objCommand.CommandText = "SELECT Name, dNSHostName FROM '" & strGroupLocation & "' WHERE objectCategory='computer' AND dNSHostName='" & strMachineGroup & "'"
		Set objRecordSet = objCommand.Execute
		
	objRecordSet.MoveFirst		
		
Do Until objRecordSet.EOF
	
	strComputer = objRecordSet.Fields("Name").Value
	objMachineNames.writeline strComputer
	
objRecordSet.MoveNext
Loop
End If
 
CurrentStatus.innerText = "Processing machine list.... please wait"
set ObjMachineNames = nothing
 
CheckFolderAge intDel,Offline,Deleted,Checked,strExcelPath,strExcelSavePath,MachineNames
	
End Function
	
Function CheckFolderAge(intDel,Offline,Deleted,Checked,strExcelPath,strExcelSavePath,MachineNames)
 
On Error Resume Next
 
'======================================
'Establishing connection with log files
'======================================
		
Set objOffline = objFSO.OpenTextFile(Offline, ForWriting)
Set objDeleted = objFSO.OpenTextFile(Deleted, ForAppending)
set objChecked = objFSO.OpenTextFile(Checked, ForWriting)
Set objMachineNames = objFSO.OpenTextFile(MachineNames, ForReading)
 
set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.DisplayAlerts = True
objExcel.Workbooks.Open(strExcelPath)
Set objSheet = objExcel.Worksheets(1)
objSheet.Name = "Profile Cleanup"
 
Do Until objMachineNames.AtEndOfStream
 
	strComputer = objMachineNames.readline
	strCurrentObject = strComputer
	intDel = cint(intDel)
		if not objFSO.FolderExists("\\" & strComputer & "\c$") then
				objOffline.writeLine strComputer
				
		else
			
			Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
			Set colFolders = objWMIService.ExecQuery ("Select * From Win32_Directory Where Path Like '%\\Documents and Settings\\'")
				
			For Each objFolder in colFolders
				strFoldername = objFolder.Name
								
				strNameLength=Len(strFoldername)
				strNewNameLength = strNameLength - 26
				strNewFolderName = Right(strFoldername, strNewNameLength)
			
				objChecked.writeline strComputer & " , " & strNewFolderName
				'msgbox(strComputer & ", " & strNewFolderName)
				If strNewFolderName = "administrator" OR strNewFolderName = "all users" OR strNewFolderName = "default user" OR strNewFolderName = "localservice" OR strNewFolderName = "networkservice" OR strNewFolderName = "brian.whitted" then
					
					'Nothing
				
				Else
				
					set ColFiles = objWMIService.ExecQuery ("Select * From CIM_DataFile Where Extension = 'dat' AND Path Like '%\\" & strNewFoldername & "\\'")
							
						For Each objFile in ColFiles
							strLongMod = objFile.LastModified
							strShortMod = left(strLongMod,8)
							strModYear = left(strShortMod,4)
							strModMD = right(strShortMod,4)
							strModDay = right(strModMD,2)
							strModMonth = left(strModMD,2)
							strCorrectModMonth = right(strModMonth,2)
							strModDate = strCorrectModMonth & "/" & strModDay & "/" & strModYear 
							strLastModDif = cint(DateDiff("d", strModDate, strDate))
							'msgbox(strLastModDif & " days since modification")
							
							If strLastModDif >= intDel then
							strDeletePath = "\\" & strComputer & "\c$\Documents and Settings\" & strNewFolderName
								'msgbox(strNewFolderName & " is being processed for deletion!")
								strSizePath = "\\" & strComputer & "\c$\Documents and Settings\" & strNewFolderName
								Call FolderSize(strSizePath, strFolderSize)
								strTotalSize = strTotalSize + strFolderSize
								strFolderSizeKB = strFolderSize / 1000
								strFolderSizeMB = strFolderSizeKB / 1000
								objFSO.DeleteFolder strDeletePath,TRUE
								If objFSO.FolderExists(strDeletePath) then
									'Folder failed to delete, will not log
								Else
								objDeleted.writeline "\\" & strComputer & "\c$\Documents and Settings\" & strNewFolderName
								objSheet.cells(x,1).Value = strSizePath
								objSheet.Cells(x,2).Value = strFolderSizeMB
								x = x + 1
								End If
								Set objShell = nothing
							else
								'msgbox("This folder is not old enough")
							end if
						Next
					End if
			Next
	end if
 
Loop
 
strCurrentObject = ""
 
objSheet.SaveAs strExcelSavePath & "\profile cleanup group_" & strFileDate & ".xls"
objExcel.Application.Quit
Set objApp = Nothing
	
CurrentObject.innerText = ""
CurrentFolder.innerText = ""
CurrentStatus.innerText = "Action Complete"
Set objChecked = Nothing
Set objDeleted = Nothing
Set objOffline = Nothing
Set objFSO = Nothing
			
End Function
	
</script>
 
</HEAD>
<BODY onload="vbs:Window_OnLoad">
<DIV id="Background_DIV">
<img src= "\\baker\boiseIT$\scripts\script central\images\UAM background.bmp" height=100% width=100%/>
<script type="text/javascript">
	{
	window.resizeTo(400,300)
	window.moveTo(0,0);
	}	
</script>
 
<DIV id="LocationSelect_DIV">
<select size="1" width="30" name="SelectLocation" onchange="RunLocation">
    <option selected value="">Make a Selection</option>
    <option value="Boise">Boise</option>
    <option value="Seattle">Seattle</option>
</select>
</DIV>
 
<DIV id="GroupSelect_DIV" align="Center">
<span id="GroupSelect"></span>
</DIV>
<DIV id="ActionButton_DIV" align="Center">
<span id="StartAction"></span>
</DIV>
<DIV id="Status_DIV">
<span id="CurrentStatus"></span><br>
<span id="CurrentObject"></span><br>
<span id="CurrentFolder"></span>
</DIV>
</DIV>
</BODY>
</HTML>

Open in new window

0
 
LVL 12

Author Comment

by:piattnd
ID: 22933152
I will give that a shot Thursday.  I am out until then.
0
 
LVL 12

Author Closing Comment

by:piattnd
ID: 31514682
Thank you both of you for the assistance.  I've split points between both of you because your answers are correct, but in the way the script functions and the way I wrote it, it won't apply properly.  I appreciate both of your help!
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello again, all.  For those of you that have been following along, you'll know that this is my third article on this topic (though it is not Part III).  This article is sort of remedial, and probably the topic with which I should have started the s…
Well hello again!  Glad to see you've made it this far without giving up.  In this, the fourth installment of my popular series, I'm going to cover functions and subroutines, what they are, and why they are useful.  Just in case you stumbled onto th…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses
Course of the Month21 days, 5 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question