Hi Guys,
Got an odd problem - but persistent whereby a script we use to copy the profile from a network share runs, but occasionally (like today) it won't?
Give the machines a reboot (or two) and it will - logon locally and run the script and it runs fine?
Any ideas or direction would be great as this is now causing me a headache
Cheers :-)
Script is as follows:-
On Error Resume Next
Set shell = CreateObject("Wscript.Shell")
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
shell.Popup "Waiting 2 seconds....", 2, Timer, 64
wscript.sleep(2000)
'Delete profile if it already exists:
If objFSO.FolderExists("C:\Documents and Settings\Default User") Then
objFSO.DeleteFolder("C:\Documents and Settings\Default User")
objFSO.CopyFolder "\\server.domain.local\profile$\Default User", "C:\Documents and Settings\Default User", True
objFSO.CopyFile "\\server.domain.local\profile$\version.txt", "C:\Documents and Settings\version.txt", True
objFSO.CopyFile "\\server.domain.local\profile$\wallpaper.bmp" , "C:\wallpaper.bmp", True
' Error Handling:
If Err.Number <> 0 Then
shell.Popup "An error occured replacing an existing profile on: "& WshNetwork.ComputerName &". Please report this error message to ITS: "& CStr(Err.Number) & " " & Err.Description, 30, Timer, 64
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Profile Problems - " & WshNetwork.ComputerName
objMessage.From = "blah@blah.co.uk"
objMessage.To = "blah@blah.co.uk"
objMessage.TextBody = "There is an issue replacing an existing profile on : "& WshNetwork.ComputerName &" - Error Message: "& CStr(Err.Number) & " " & Err.Description
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp@blah.co.uk"
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.Fields.Update
objMessage.Send
'Clear the error message
Err.Clear
End If
shell.Popup "Default User Profile Replaced", 2, Timer, 64
'Copy profile if it doesnt exist:
Else
objFSO.CopyFolder "\\server.domain.local\profile$\Default User", "C:\Documents and Settings\Default User", True
objFSO.CopyFile "\\server.domain.local\profile$\version.txt", "C:\Documents and Settings\version.txt", True
objFSO.CopyFile "\\server.domain.local\profile$\wallpaper.bmp" , "C:\wallpaper.bmp", True
' Error Handling:
If Err.Number <> 0 Then
shell.Popup "An error occured copying a new profile on: "& WshNetwork.ComputerName &". Please report this error message to ITS: "& CStr(Err.Number) & " " & Err.Description, 30, Timer, 64
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Profile Problems - " & WshNetwork.ComputerName
objMessage.From = "blah@blah.co.uk"
objMessage.To = "blah@blah.co.uk"
objMessage.TextBody = "There is an copying a new profile on : "& WshNetwork.ComputerName &" - Error Message: "& CStr(Err.Number) & " " & Err.Description
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.blah.co.uk"
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.Fields.Update
objMessage.Send
'Clear the error message
Err.Clear
End If
shell.Popup "New Default User Copied", 2, Timer, 64
End If
'Set Default Background
const HKEY_USERS = &H80000003
strComputer = "."
Set StdOut = WScript.StdOut
Set oReg=GetObject("winmgmts:{impersonationLevel=imper sonate}!\\" &_
strComputer & "\root\default:StdRegProv")
strKeyPath = ".DEFAULT\Control Panel\Desktop"
strValueName = "Wallpaper"
strValue = "C:\wallpaper.bmp"
oReg.SetStringValue HKEY_USERS,strKeyPath,strValueName,strValue
' Error Handling:
If Err.Number <> 0 Then
shell.Popup "An error occured setting the wallpaper on: "& WshNetwork.ComputerName &". Please report this error message to ITS: "& CStr(Err.Number) & " " & Err.Description, 30, Timer, 64
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Profile Problems - " & WshNetwork.ComputerName
objMessage.From = "blah@blah.co.uk"
objMessage.To = "blah@blah.co.uk"
objMessage.TextBody = "An error occured setting the wallpaper on : "& WshNetwork.ComputerName &" - Error Message: "& CStr(Err.Number) & " " & Err.Description
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp@blah.co.uk"
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.Fields.Update
'objMessage.Send
'Clear the error message
Err.Clear
End If
shell.Popup "Wallpaper set", 2, Timer, 64
On Error GoTo 0
Would suggest it's possibly more of a GPO issue, have you got "Wait for Network at computer startup" enabled somewhere on the computers OU's if not give it a go.
There are currently 1 users browsing this thread. (0 members and 1 guests)