I have a script to delete the %TEMP% files and folders, but the path is hard coded. This will not work on all the machines on my network sinse each machine has a different path to temp depending on who is using the machine. How can I substitute this path C:\Documents and Settings\user\Local Settings\Temp to be act more like
%temp% Here is the code I use now.
Set fso = CreateObject("Scripting.FileSystemObject")
Path = "C:\Documents and Settings\user\Local Settings\Temp"
Set oFolder = fso.GetFolder(Path)
For Each oFile In oFolder.files
fso.DeleteFile oFile
Next
For Each oSubFolder In oFolder.SubFolders
Call KillSubFolders (oSubFolder)
Next
MsgBox "Done"
Sub KillSubFolders (SubPath)
fso.DeleteFolder SubPath
End Sub
%temp% Here is the code I use now.
Set fso = CreateObject("Scripting.FileSystemObject")
Path = "C:\Documents and Settings\user\Local Settings\Temp"
Set oFolder = fso.GetFolder(Path)
For Each oFile In oFolder.files
fso.DeleteFile oFile
Next
For Each oSubFolder In oFolder.SubFolders
Call KillSubFolders (oSubFolder)
Next
MsgBox "Done"
Sub KillSubFolders (SubPath)
fso.DeleteFolder SubPath
End Sub