hinfie Posted February 27, 2005 Share Posted February 27, 2005 I tried to read a output file from a WMIC command, but i keep getting garbage back... does anyone have a idea? The file is can be opend by notepad.. This only happens with WMIC output.. _RunDOS("WMIC.EXE LOGICALDISK GET FREESPACE,SIZE,NAME /format:textvaluelist.xsl >" & @TempDir & "\disk.txt") $file = FileOpen(@TempDir & "\disk.txt", 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; Read in lines of text until the EOF is reached While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop MsgBox(0, "Line read:", $line) Wend FileClose($file) Func _RunDOS($sCommand) Return RunWait(@ComSpec & " /C " & $sCommand, "", @SW_HIDE) EndFunc ;==>_RunDOS Raymond Link to comment Share on other sites More sharing options...
therks Posted February 27, 2005 Share Posted February 27, 2005 (edited) That's really odd... actually. I can't seem to get FileRead to work for me at all right now. I just tried this script for myself: $file = "C:\temp\stuff.txt" $filesize = FileGetSize($file) $fileread = FileRead($file, $filesize) MsgBox(0, $filesize, $fileread) Stuff.txt just says "Hello world" But the script only returns "ÿþH" Edited February 27, 2005 by Saunders My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
SlimShady Posted February 27, 2005 Share Posted February 27, 2005 (edited) @Saunders That means the file uses the Unicode code page. Edited February 27, 2005 by SlimShady Link to comment Share on other sites More sharing options...
hinfie Posted February 28, 2005 Author Share Posted February 28, 2005 SlimShady, Thanks for the unicode tip!Found the solution in http://www.autoitscript.com/forum/index.ph...637entry61637i added the following line:;Line below parses UniCode to ASCII RunWait(@ComSpec & ' /c type ' & @TempDir & '\disk.txt>' & @TempDir & '\disk1.txt', '', @SW_HIDE)and read the disk1.txt fileRaymond Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now