Hey guys,
For some reason, when I run the following script, I'm getting a "Object
doesn't support this property or method" error on line 20. (LogFile =) and i
just can't seem to figure out what I'm getting wrong. Think you guys can
take a look?
Thanks!
Code:
Option Explicit
'On Error Resume Next
Dim objShell
Dim FSO
Dim RegUserName
Dim RegCompName
Dim User
Dim Comp
Dim LogFile
Set FSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")
RegUserName =
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\LastLoggedOnUser"
RegCompName =
"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName\ComputerName"
User = objShell.RegRead(RegUserName)
Comp = objShell.RegRead(RegCompName)
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
LogFile = FSO.OpenTextFile("M:\Test.txt", ForAppending, True)
LogFile.Write " "
LogFile.Write "ComputerName" & " " & Comp
LogFile.Write "is being used by" & " " & User
LogFile.Write Date
LogFile.Write " "
LogFile.Close