/build/static/layout/Breadcrumb_cap_w.png

Reading an inf file give strange output

[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

Answers (10)

Posted by: aogilmor 16 years ago
9th Degree Black Belt
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.
Posted by: anonymous_9363 16 years ago
Red Belt
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.
Posted by: Rave 16 years ago
Senior Yellow Belt
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
Posted by: anonymous_9363 16 years ago
Red Belt
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)
Posted by: Rave 16 years ago
Senior Yellow Belt
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.
Posted by: aogilmor 16 years ago
9th Degree Black Belt
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.
Posted by: aogilmor 16 years ago
9th Degree Black Belt
0
Was it a unicode file?
Posted by: anonymous_9363 16 years ago
Red Belt
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...
Posted by: aogilmor 16 years ago
9th Degree Black Belt
0
OK, thanks for reminding me of that. I hadn't used it on anything but ascii, had forgotten tristate constant.
Posted by: anonymous_9363 16 years ago
Red Belt
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.
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ