Hello,

The following script is giving me this error:


Object required: {string: '["""D:\Program Files\Ju"]'


I've tried %20 and that did not work. What changes need to be made to
the VBScrit below to get rid of the above error.


Dim regedit, nFile
set regedit = CreateObject("WScript.Shell")
set nFile = """D:\Program Files\Just BASIC v1.01\My Programs
\eBookErrFix\eBookErrFix\eBookErrFix\CurrentFile.txt"""
nFile.write(regedit.RegRead("HKEY_LOCAL_MACHINE\Software\Microsoft
\Windows NT\CurrentVersion\Winlogon\DefaultUserName"))


Thank you for your help,
jfcby

Re: VBScript Error by mayayana

mayayana
Tue Mar 11 22:20:23 CDT 2008


You shouldn't need the triple quotes. But the
error is caused by trying to treat a file path
as an object. You can open the file as a Textstream
object, but you can't just assign the path to an
object.

You need something like:

Set FSO = CreateObject("Scripting.FileSystemObject")
Set TS = FSO.OpenTextFile(path, 2)
TS.Write usernamevalue
TS.Close
Set TS = Nothing

TS is a Textstream object. Look that up in the WSH
docs to see how it's used. Both FSO.OpenTextFile and
FSO.CreateTextFile return a Textstream.

> Hello,
>
> The following script is giving me this error:
>
>
> Object required: {string: '["""D:\Program Files\Ju"]'
>
>
> I've tried %20 and that did not work. What changes need to be made to
> the VBScrit below to get rid of the above error.
>
>
> Dim regedit, nFile
> set regedit = CreateObject("WScript.Shell")
> set nFile = """D:\Program Files\Just BASIC v1.01\My Programs
> \eBookErrFix\eBookErrFix\eBookErrFix\CurrentFile.txt"""
> nFile.write(regedit.RegRead("HKEY_LOCAL_MACHINE\Software\Microsoft
> \Windows NT\CurrentVersion\Winlogon\DefaultUserName"))
>
>
> Thank you for your help,
> jfcby
>
>