Reading an inf file give strange output
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)
Please log in to answer
Posted by:
aogilmor
16 years ago
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
ORIGINAL: RaveThis 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.
probably the inf-file is corrupt, but i am able to open it wiht Notepad.
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
Posted by:
anonymous_9363
16 years ago
OpenTextfile
ORIGINAL: RaveI 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:
[font="times new roman"]I have tried to add the unicode option but that didn't help either
Const intFSOTristateFalse = 0
Const intFSOTristateTrue = -1
Const intFSOTristateUseDefault = -2
objFSO.OpenTextFile(strSourceFile, intFSOForReading, intFSOTristateUseDefault)
Posted by:
Rave
16 years ago
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.
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
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:
anonymous_9363
16 years ago
ORIGINAL: aogilmorHi, 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...
Was it a unicode file?
Posted by:
aogilmor
16 years ago
Posted by:
anonymous_9363
16 years ago
ORIGINAL: RaveThinking 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.
So i am going to add a function to check on the size of the ntprint.inf.
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.