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

Re: I'm missing something obvious... by Tom

Tom
Fri Mar 07 09:50:53 CST 2008

On Mar 7, 10:19 am, William Anderson
<WilliamAnder...@discussions.microsoft.com> wrote:
> 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:
>
{snip}

SET LogFile = FSO.OpenTextFile("M:\Test.txt", ForAppending, True)
>
{snip}
Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/

Re: I'm missing something obvious... by WilliamAnderson

WilliamAnderson
Fri Mar 07 10:11:00 CST 2008

HAHA!

As soon as I stop crying I think I'll get another cup of coffee. :-p

Thanks Tom!

"Tom Lavedas" wrote:

> On Mar 7, 10:19 am, William Anderson
> <WilliamAnder...@discussions.microsoft.com> wrote:
> > 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:
> >
> {snip}
>
> SET LogFile = FSO.OpenTextFile("M:\Test.txt", ForAppending, True)
> >
> {snip}
> Tom Lavedas
> ===========
> http://members.cox.net/tglbatch/wsh/
>

Re: I'm missing something obvious... by Paul

Paul
Fri Mar 07 10:36:16 CST 2008


"Tom Lavedas" <tglbatch@cox.net> wrote in message
news:f36490ed-5565-427e-a182-763041546bb7@u69g2000hse.googlegroups.com...
> On Mar 7, 10:19 am, William Anderson
> <WilliamAnder...@discussions.microsoft.com> wrote:
>> 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:
>>
> {snip}
>
> SET LogFile = FSO.OpenTextFile("M:\Test.txt", ForAppending, True)

This shows the importance of naming variables to indicate its data
type and being a reminder as to when the key word Set must be used.

Why the strange error message: Object doesn't support this property or
method"? Is it perhaps because this object has no default property?
The error occurs after the file is created.

-Paul Randall