vb.net - Sending And Receiving Messages To/from Command Prompt -
i'm using vb 2010. problem is:
i can send , display sent command in textbox without problem when try use .exe in cmd can't display in textbox source code is:
private results string 'the "delegate" used correct threading issue (can't update control directly in vb.net 08/10), , invokes needed text update. private delegate sub delupdate() private finished new delupdate(addressof updatetext) private sub updatetext() textbox2.text = results end sub private sub form1_load(byval sender system.object, byval e system.eventargs) handles mybase.load end sub private sub button1_click(byval sender system.object, byval e system.eventargs) handles button1.click dim cmdthread new threading.thread(addressof cmdautomate) cmdthread.start() end sub private sub cmdautomate() dim myprocess new process dim startinfo new system.diagnostics.processstartinfo 'starts cmd prompt startinfo.filename = "cmd.exe" startinfo.redirectstandardinput = true startinfo.redirectstandardoutput = true 'required redirect startinfo.useshellexecute = false 'disables creation of cmd prompt outside application. startinfo.createnowindow = true myprocess.startinfo = startinfo myprocess.start() dim sr system.io.streamreader = myprocess.standardoutput dim sw system.io.streamwriter = myprocess.standardinput 'runs command entered... sw.writeline(textbox1.text) 'exits cmd prompt sw.writeline("exit") 'displayes results... results = sr.readtoend sw.close() sr.close() 'invokes finished delegate, updates textbox results text invoke(finished) end sub end class
for example when use command fastboot
@ cmd
usage: fastboot [ <option> ] <command> commands: update <filename> reflash device update.zip flashall flash boot + recovery + system flash <partition> [ <filename> ] write file flash partition erase <partition> erase flash partition format <partition> format flash partition getvar <variable> display bootloader variable boot <kernel> [ <ramdisk> ] download , boot kernel flash:raw boot <kernel> [ <ramdisk> ] create bootimage , flash devices list connected devices continue continue autoboot reboot reboot device reboot-bootloader reboot device bootloader show message options: -w erase userdata , cache (and format if supported partition type) -u not first erase partition before formatting -s <specific device> specify device serial number or path device port -l "devices", lists device paths -p <product> specify product name -c <cmdline> override kernel commandline -i <vendor id> specify custom usb vendor id -b <base_addr> specify custom kernel base address -n <page size> specify nand page size. default: 2048 -s <size>[k|m|g] automatically sparse files greater th size. 0 disable
but when use program
microsoft windows [version 6.1.7600] copyright (c) 2009 microsoft corporation. tous droits r‚serv‚s. c:\users\badro@istambul\documents\visual studio 2010\projects\windowsapplication1\windowsapplication1\bin\debug>fastboot c:\users\badro@istambul\documents\visual studio 2010\projects\windowsapplication1\windowsapplication1\bin\debug>exit
the syntax output fastboot.exe
when ran without arguments displayed through error stream; use redirectstandarderror capture this;
startinfo.redirectstandarderror = true dim se system.io.streamreader = myprocess.standarderror
Comments
Post a Comment