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

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?
LVL 12
piattndAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David LeeCommented:
0
rejoinderCommented:
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
piattndAuthor Commented:
I've tried using the window.settimeout and it doesn't work  :(
0
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

piattndAuthor Commented:
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
RobSampsonCommented:
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
piattndAuthor Commented:
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
RobSampsonCommented:
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
piattndAuthor Commented:
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
rejoinderCommented:
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
piattndAuthor Commented:
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
RobSampsonCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
piattndAuthor Commented:
I will give that a shot Thursday.  I am out until then.
0
piattndAuthor Commented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.