[font="times new roman"]Hello,

I am trying to read an inf file (ntprint.inf) to retrieve the DriverVer of the inf file.
When i open the file with OpenTextfile, it returns some strange characters. "yb;" and that is all.
when opening it with notepad, there is no problem.
I have tried to add the unicode option but that didn't help either
Does anyone has an idea? If more info is needed let me know.

kind regards,
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Community Chosen Answer

1
Not sure what you're trying to do, but it sound printer related. If you can, use the prnmngr.vbs file which comes with Windows XP (maybe the resource kit). In any case, look on your machine and google it. It's a canned script file from MSFT that does a lot of printer management, takes arguments, etc. I've used it a few times and it's saved me hours of scripting.
Answered 03/19/2008 by: aogilmor
Ninth Degree Black Belt

Please log in to comment
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
OpenTextfile ORIGINAL: Rave
[font="times new roman"]I have tried to add the unicode option but that didn't help either
I ran into this when writing my .REG merging script. You say you tried the Unicode option but, following the experience with my script, I now routinely use the 'Use default system setting', as in:

Const intFSOTristateFalse = 0
Const intFSOTristateTrue = -1
Const intFSOTristateUseDefault = -2

objFSO.OpenTextFile(strSourceFile, intFSOForReading, intFSOTristateUseDefault)
Answered 03/19/2008 by: VBScab
Red Belt

Please log in to comment
0
actually what i am trying to do is just to read out the value "DriverVer=02/05/2002, 1", out of an printer inf-file.
My code 'works' if it is an inf file from the vendor, but it can't read the ntprint.inf file,
probably the inf-file is corrupt, but i am able to open it wiht Notepad.
Still thanks a lot for the replies.

Rave.
Answered 03/19/2008 by: Rave
Senior Yellow Belt

Please log in to comment
0
ORIGINAL: Rave
actually what i am trying to do is just to read out the value "DriverVer=02/05/2002, 1", out of an printer inf-file.
My code 'works' if it is an inf file from the vendor, but it can't read the ntprint.inf file,
probably the inf-file is corrupt, but i am able to open it wiht Notepad.


Rave, you may want to check out this article....if the problem is that it's unicode (?)
https://www.microsoft.com/technet/scriptcenter/resources/qanda/apr06/hey0419.mspx
Try opening the file and doing a save as, and see what type it defaults to. It could be corrupt but if it's readable otherwise that seems unlikely.
Answered 03/19/2008 by: aogilmor
Ninth Degree Black Belt

Please log in to comment
1
ORIGINAL: Rave
probably the inf-file is corrupt, but i am able to open it wiht Notepad.
This is SO weird. I got the same result experimenting with the exact same file and no difference was observed using the other 2 constants. In the course of those experiments, I managed to turn it into a zero-byte file. Of course I had a back-up but copying that back to the original made no difference. However, my mind turned to the dark side and I began to wonder about what's going on,. Thus, I opened the INF in my normal editor (TextPad) copied the contents to a new document, closed the original INF and then saved the new document over the top of the INF. Bingo! Now, the script displays the file's content as expected.

In this case, I'd be tempted to test the file's size before opening and, if it looks suspect (my text version is750K, original is 1.5Mb...), open the file, copy its content to another, temporary file, save that file and read ITS content instead. Ugly, true, but it'll probably work.

BTW, there's a nice INI class on JSWare's web site which you could use for reading the INF's entries, once you have a text version, since INFs are exactly the same format as INIs.
Answered 03/20/2008 by: VBScab
Red Belt

Please log in to comment
0
Was it a unicode file?
Answered 03/20/2008 by: aogilmor
Ninth Degree Black Belt

Please log in to comment
1
Thanks VBScab,

Did now the same thing as you did manually and indeed, the inf-file supported by windows XP is a bit messy, 1.5 MB and when copying it to another file it is only 733 Kb.
So i am going to add a function to check on the size of the ntprint.inf.
Thanks very much for all the posts.

Rave
Answered 03/20/2008 by: Rave
Senior Yellow Belt

Please log in to comment
0
ORIGINAL: aogilmor
Was it a unicode file?
Hi, Owen. The result of the ReadAll suggests that it is but using the relevant Tristate constant *ought* to make it readable in VBS - it's the constant which my registry contatenation script uses (and which I know works on non-WinNT .REG files) - but it doesn't. V, v, weird...
Answered 03/26/2008 by: VBScab
Red Belt

Please log in to comment
0
OK, thanks for reminding me of that. I hadn't used it on anything but ascii, had forgotten tristate constant.
Answered 03/26/2008 by: aogilmor
Ninth Degree Black Belt

Please log in to comment
0
ORIGINAL: Rave
So i am going to add a function to check on the size of the ntprint.inf.
Thinking about it, I think it would be safer to check on what gets returned by the call to ReadAll. If it contains more than one null character - generally speaking, the giveaway to Unicode content - which is Chr(0) in VBS, action accordingly.
Answered 03/27/2008 by: VBScab
Red Belt

Please log in to comment
Answer this question or Comment on this question for clarity