Ok here is the whole script. everything works EXCEPT the line to map the users Home drive (i
Option Explicit
' Declare basic objects
dim wshFSO : Set wshFSO = CreateObject("Scripting.FileSystemObject")
dim wshShell : Set wshShell = CreateObject("WScript.Shell")
dim wshSysEnv': Set wshSysEnv = wshShell.Environment ("system")
Dim wshUsrEnv : Set wshUsrEnv = wshShell.Environment("User")
dim wshPrcEnv : Set wshPrcEnv = wshShell.Environment("Process")
Dim wshNet : Set wshNet = WScript.CreateObject("WScript.Network")
Dim wshArgs : Set wshArgs = WScript.Arguments
Const WindowsFolder = 0
Const SystemFolder = 1
Const TemporaryFolder = 2
Const Deleteall1 = True
Const Deleteall2 = True
On Error Resume Next
Set wshFSO = CreateObject("Scripting.FileSystemObject")
wshFSO.DeleteFile("C:\Temp\*.*")
On Error Resume Next
Set wshFSO = CreateObject("Scripting.FileSystemObject")
wshFSO.DeleteFolder("C:\Temp\*.*")
On Error Resume Next
dim I
dim blnVerbose : blnVerbose = False
dim blnQuiet : blnQuiet = False
dim blnAskRegistry : blnAskRegistry = False
For I = 0 to wshArgs.Count - 1
blnVerbose = blnVerbose Or (wshArgs(I)="/v") Or (wshArgs(I)="/V")
blnQuiet = blnQuiet Or (wshArgs(I)="/q") Or (wshArgs(I)="/Q")
blnAskRegistry = blnAskRegistry Or (wshArgs(I)="/r") Or (wshArgs(I)="/R")
Next
dim blnShowErrors : blnShowErrors = Not blnQuiet
' Get the system temporary folder
dim strSysTempFolder
strSysTempFolder = Replace(strSysTempFolder, "%SystemRoot%", wshPrcEnv("SYSTEMROOT"), 1, -1, vbTextCompare)
dim arrFolderList
arrFolderList = array( _
wshShell.SpecialFolders(""), _
strSysTempFolder, _
wshFSO.GetSpecialFolder(TemporaryFolder).Path, _
WshShell.RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Cache") _
)
dim strFolderI
For Each strFolderI in arrFolderList
If blnVerbose Then
Echo("- " & strFolderI)
End If
FolderDelete strFolderI, True, blnShowErrors
Next
dim arrRegistryList
arrRegistryList = array( _
"[-HKEY_CURRENT_USER\Software\Microsoft\MediaPlayer\Player\RecentFileList]")
Dim strTempName : strTempName = wshFSO.GetTempName
dim oTempFile : Set oTempFile = CreateTempFile(strTempName)
oTempFile.WriteLine "REGEDIT4"
dim strRegistryI
For Each strRegistryI in arrRegistryList
If blnVerbose Then
Echo("- " & strRegistryI)
End If
oTempFile.WriteLine strRegistryI
Next
oTempFile.Close
dim strCommand : strCommand = "Regedit "
If Not blnAskRegistry Then strCommand = strCommand & "/s "
strCommand = strCommand & strTempName
wshShell.Run strCommand, 1, True
wshFSO.DeleteFile strTempName
Sub FolderDelete(strBaseFolder, blnContentOnly, blnShowErrors)
If wshFSO.FolderExists(strBaseFolder) Then
dim oBaseFolder : Set oBaseFolder = wshFSO.GetFolder(strBaseFolder)
dim oFolderI, oFileI
For Each oFolderI in oBaseFolder.SubFolders
FolderDelete oFolderI.Path, False, blnShowErrors
Next
For Each oFileI in oBaseFolder.Files
On Error Resume Next
oFileI.Delete
If Err.number <> 0 Then
If blnShowErrors Then
End If
Err.Clear
End If
On Error Goto 0
Next
If not blnContentOnly Then
On Error Resume Next
oBaseFolder.Delete
If Err.number <> 0 Then
If blnShowErrors Then
End If
Err.Clear
End If
On Error Goto 0
End If
End If
End Sub
Function CreateTempFile(ByRef strTempName)
Dim oTempFolder, oTempFile
Set oTempFolder = wshFSO.GetSpecialFolder(TemporaryFolder)
Set oTempFile = oTempFolder.CreateTextFile(strTempName)
strTempName = oTempFolder.Path & "\" & strTempName
Set CreateTempFile = oTempFile
End Function
Sub Echo(ByVal strMessage)
If Not blnQuiet then
Wscript.Echo(strMessage)
End If
End Sub
Dim oNetwork
set oNetwork = CreateObject("WScript.Network")
On Error Resume Next
oNetwork.MapNetworkDrive "g:", "\\CSCFS\common"
On Error Resume Next
oNetwork.MapNetworkDrive "h:", "\\CSCFS\prod"
On Error Resume Next
wshNet.MapNetworkDrive "i:", "\\CSCAPP1\%username%$"
On Error Resume Next
oNetwork.MapNetworkDrive "x:", "\\CSCAPP1\apps"
On Error Resume Next
oNetwork.MapNetworkDrive "k", "\\CSCAPP1\ServicemailPool"
On Error Resume Next
oNetwork.MapNetworkDrive "O", "\\Dap\image$"
On Error Resume Next
oNetwork.MapNetworkDrive "s", "\\CSCAPP1\Information Resource Center for EDS"
'The End
'-------