Command line progress

USB Image Tool support forum
Post Reply
quantum1976
Posts: 2
Joined: Wed Nov 09, 2011 4:54 pm

Command line progress

Post by quantum1976 » Wed Nov 09, 2011 5:29 pm

First let me say that this is a great tool, very flexible.

I wanted to create my own UI based imaging tool to perform some of the custom tasks I require. To do this I used the command line version of USB Image Tool (usbitcmd.exe). My plan is to use a HTA/VBScript program to launch the command line version and then capture the output to update a progress bar.

Code: Select all

	Set WshShell = CreateObject("WScript.Shell")
	Set oExec = WshShell.Exec("usbitcmd.exe r 2440 usb.img /i /d")
	Do While oExec.Status = 0
		strTempLine = oExec.stdout.readline
		if instr(strTempLine, "%") > 0 then
			intCurrentProg = cint(mid(strTempLine, instr(strTempLine, "%") - 3, 3))
			progressBar.Value = intCurrentProg
		end if		
	Loop
I've used this method with other command line tools (ImageX) and it works fine. The problem I'm having is that I don't see any of the output from usbitcmd.exe until after it completes imaging. To test this I launched it from a console window and redirected the output to a text file (usbitcmd.exe r 2440 usb.img /i /d > stdout.txt). When I run this, the text file remains empty until after the imaging completes.

Is there any way I can capture the imaging progress while it is running to show the user how much is left?


Thanks,

Rich

Alex
Site Admin
Posts: 235
Joined: Fri Jul 29, 2011 11:59 pm

Re: Command line progress

Post by Alex » Wed Nov 09, 2011 6:55 pm

Hm, never tested that myself. I'm using plain C printf command for output here + SetConsoleCursorPosition. Don't know if it has anything to do with that. Also I'm not sure with the output piping. Maybe the file is locked until the usbitcmd.exe process finished.

quantum1976
Posts: 2
Joined: Wed Nov 09, 2011 4:54 pm

Re: Command line progress

Post by quantum1976 » Thu Nov 10, 2011 3:47 am

Thanks for the quick reply. I did a little checking and it seems that the output can't be redirected until a carriage return and/or line feed is sent.

Would it be possible to update the program to add another optional parameter that would scroll the output by adding a carriage return-line feed to each percentage update?

The Microsoft Imagex program (http://technet.microsoft.com/en-us/libr ... s.10).aspx) that I referred to earlier does this. The /scroll optional parameter (e.g. Images /apply /scroll) does this so the progress can be redirected to another program.


Thanks,
Rich

Alex
Site Admin
Posts: 235
Joined: Fri Jul 29, 2011 11:59 pm

Re: Command line progress

Post by Alex » Thu Nov 10, 2011 7:07 pm

Thanks for checking that. I think I can implement it with the next version.

Alex
Site Admin
Posts: 235
Joined: Fri Jul 29, 2011 11:59 pm

Re: Command line progress

Post by Alex » Thu Feb 21, 2013 9:44 pm

implemented with version 1.60 (command line tool)

Post Reply