Jump to content
Sign in to follow this  
hinfie

Cannot read _RunDos output file

Recommended Posts

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.. o:):lmao:

_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

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 by Saunders

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...