As requested by Danp, here is the solution for my problem....
Issue: Students are on a mandatory profile in a windows 7 environment, this means they have no local user profile on the PCs. If they open a file from web mail (using IE as it's the only thing available), they invariable enable editing, then work on the file without saving it to thier file storage location!! When they save later on they tend not to do 'save as' (and believe me we have told them lots to do that). By default IE stores any document in the IE temp folder on the profile.
If you don't have a profile on the PC then the files are deleted when you log off......cue wailing students "I worked for hours on it and now it's lost!!!"
Solution: I have enable a log off script in GPO to run a .vbs, this in turn calls a powershell script to save the files. Seems complicated - yes but it works and if you set the powershell script to run at log off it run as the student, who don't have execution rights.The VB script also waits until the powershell code has completed before it ends, this makes sure that the files have been copied over.
VB code
on error resume next
'-----initialize-------------------------------------------
const overwriteExisting = true
const forceRemoval=true
const forceDelete=true
const updateProfile=true
set objshell=wscript.createobject("wscript.shell")
set objnet=wscript.createobject("wscript.network")
Set objFSO=wscript.createObject("Scripting.FileSystemObject")
'------run copy-----------------------------------
objShell.run("powershell -executionpolicy bypass -noexit -file \\yourfilelocationhere\netlogon\filesavetemp.ps1")
WaitForIdle ".", "powershell", "3"
Sub WaitForIdle(strComputer, strProcessName, intIdleSec)
Dim bolIdle : bolIdle = False
Dim objWMIService : Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Dim strObjKeyPath : strObjKeyPath = "Win32_PerfRawData_PerfProc_Process.Name='" & strProcessName & "'"
Dim objPerfInstance : Set objPerfInstance = objWMIService.get(strObjKeyPath)
Dim intPercProcTime1 : intPercProcTime1 = objPerfInstance.PercentProcessorTime
Dim intProcTimeStamp1 : intProcTimeStamp1 = objPerfInstance.TimeStamp_Sys100NS
Dim intElemCount : intElemCount = CInt(intIdleSec) - 1
ReDim arrProcPercents(intElemCount)
Dim i : i = 0
Dim PercentProcessorTime, arrTemp, intPercProcTime2, intProcTimeStamp2
Do While Not bolIdle
WScript.Sleep 1000
Set objPerfInstance = objWMIService.get(strObjKeyPath)
intPercProcTime2 = objPerfInstance.PercentProcessorTime
intProcTimeStamp2 = objPerfInstance.TimeStamp_Sys100NS
If (intProcTimeStamp2 - intProcTimeStamp1) = 0 Then
WScript.Echo "Error, probably " & strProcessName & " not found running"
Exit Do
Else
PercentProcessorTime = ((intPercProcTime2 - intPercProcTime1) _
/ (intProcTimeStamp2 - intProcTimeStamp1))
' WScript.Echo FormatPercent(PercentProcessorTime)
' add value to array
arrProcPercents(i) = FormatPercent(PercentProcessorTime)
' if the number of seconds have been met then check the array
If i = (intElemCount) Then
' look at the array and filter for values of 0.00%
arrTemp = Filter(arrProcPercents, "0.00%")
' if the array size of the filtered and the original is the same then
' all the values for the time specified where 0.00%
If UBound(arrTemp) = intElemCount Then
' set bolIdle = True to exit the Do...Loop
bolIdle = True
End If
' if all the values where not 0.00% then reset the counter and
' array index to update
i = 0
Else
' increment the counter/array index
i = i + 1
End If
End If
intPercProcTime1 = intPercProcTime2
intProcTimeStamp1 = intProcTimeStamp2
Loop
End Sub
The Powershell script....this checks who the user is and then checks to see if they have a folder created yet (forward planning FTW - next years intake are automatically catered for), then it copies the temp files to the folder....but only the ones you specify, so we don't fill yp your servers with all the images and stuff from IE
$strUser = $env:username
$path = "\\yourfileserver\saved\$strUser"
if(!(test-path -Path $path))
{
new-item -Path $path -type directory
}
get-childitem "C:\users\TEMP.COLLEGE*\AppData\local\microsoft\windows\Temporary Internet Files\content.IE5\*\*" -include @("*.docx","*.ppt","*.xlsx","*.doc","*.csv","*.xls","*.pptx","*.pub") -force -recurse |
where-object { (-not $_.PSIsContainer) -and ($_.LastWriteTime -lt (get-date).AddDays(+60)) } | Copy-item -Destination "\\yourfileserver\saved\$strUser" -recurse -force
I know the code is not overly clean on either one but I was rushed slightly