hinfie 0 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 Share this post Link to post Share on other sites
therks 33 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 Share this post Link to post Share on other sites
SlimShady 1 Posted February 27, 2005 (edited) @Saunders That means the file uses the Unicode code page. Edited February 27, 2005 by SlimShady Share this post Link to post Share on other sites
hinfie 0 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 Share this post Link to post Share on other sites