Hello,
I have the following script which works fine however its being run as a group policy now when the first machine runs it everything works fine however the next machine comes along and gets a permission denied error on the following line:
The Error Line:
Set objTextFile = objFSO.OpenTextFile ("\\server1\Share\Error.txt", 8, true)
objTextFile.WriteLine (varHostname & "," & PCMAKE & "," & PCMODEL & "," & LogonName)
The Script:
<code>
'On Error Resume Next
TxtEncryptionChecked = "C:\EncryptionChecked4.txt"
'Set Paths of Variables - Local files
strDirectory = "C:\DcppDiskInfo\"
strFileEncrypted = "DcPPDiskInfo.txt"
strFileUnencrypted = "DcPPError.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const ForAppending = 8
'Find Hostname
Set objNTInfo = CreateObject("WinNTSystemInfo")
varHostname = lcase(objNTInfo.ComputerName)
'********************************
Set WshNetwork = CreateObject("WScript.Network")
LogonName = WshNetwork.UserName
'ThisHostName = WshNetwork.ComputerName
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSettings = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")
For Each objComputer in colSettings
PCMAKE = objComputer.Manufacturer
PCMODEL = objcomputer.Model
Next
'********************************
If objFSO.FileExists(TxtEncryptionChecked) Then
wscript.quit
else if objFSO.FileExists(strDirectory & strFileEncrypted) Then
Set objTextFile = objFSO.OpenTextFile ("\\server1\Share\Encrypted.txt",8, true)
objTextFile.WriteLine (varHostname & "," & PCMAKE & "," & PCMODEL & "," & LogonName)
objTextFile.Close
objFSO.CopyFile "\\server1\Share\EncryptionChecked4.txt", "C:\SESins\EncryptionChecked4.txt"
else If objFSO.FileExists(strDirectory & strFileUnencrypted) Then
Set objTextFile = objFSO.OpenTextFile ("\\server1\Share\Error.txt", 8, true)
objTextFile.WriteLine (varHostname & "," & PCMAKE & "," & PCMODEL & "," & LogonName)
objTextFile.Close
Else
Set objTextFile = objFSO.OpenTextFile ("\\server1\Share\No Result.txt",8, true)
objTextFile.WriteLine (varHostname & "," & PCMAKE & "," & PCMODEL & "," & LogonName)
objTextFile.Close
End If
end If
End If
</code>
Does anyone know why this is happening? Its been working for a good year and now we have just started to recieve this error? I am thinking because the file is not closing however its written in to close the file...
Any idea's?
Many Thanks
James