Jump to content
Sign in to follow this  

StdOutRead Question

Recommended Posts


This might be a long shot, but someone may have run into a similar issue.

I have created an AutoIt script used to backup user data. It has a GUI which collects input about the PC to be backed up, and then copies the data to a network store. It calls the Microsoft User State Migration Tool (USMT) to backup user profiles.

Everything works great, but I am messing with a progress bar and status indicator, and that is where the problem is. I am using StdOutRead to redirect the output of the USMT (scanstate.exe) to my GUI, updating a label control and progress bar.

Here is the code:

$scanstate = Run(@ComSpec & " /c " & "scanstate.exe U:\PCNum\Profiles /i:users.inf /i:miguser.inf /i:migsys.inf /v:15 /l:U:\PCNum\Profiles\sstatelog.txt /progress:U:\PCNum\Profiles\ssprogress.txt /user:DOMAIN\username","",@SW_HIDE)
While 1
    $line = StdOutRead($scanstate)
    If @error = -1 Then ExitLoop
    $proftemp = StringRight($line,4)
    $proftemp2 = StringLeft($proftemp,2)
    $percent = Int($proftemp2)
    If $percent > 0 Then

The problem is with the way the output is read from scanstate.exe. The first letter of each output line is getting put either on the previous line, or on a line of it's own. I redirected the output to a text file, and here is what I got:

rocessing INF files...  0%P
rocessing INF files...  50%P
rocessing INF files...  100%
rocessing INF files...  0%P
rocessing INF files...  50%P
rocessing INF files...  100%P
rocessing INF files...  100%
omputing what settings to collect...  0%C
omputing what settings to collect...  30%
omputing estimates...C
omputing estimates...
canning the system...S
canning the system...
omputing what settings to collect...  30%S
YSTEM: Computing what settings to collect...  35%

And so on. I'm guessing it has something to do with how scanstate.exe outputs to the command prompt window. Normally, it updates as the percentage goes up, overwriting the previous percentage. There must be some sort of character that it sends when this happens that I can read. Anyone have any idea what that might be. Sorry if my explanation isn't clear. Thanks!

Edited by mikeqf

Share this post

Link to post
Share on other sites

I'm not sure I can help with the issue you asked about above, however I'm also looking to Automate the USMT and was wondering if you would share your code. I have a 1,200+ PC Replacement Plan this year and I'm the only one on the automation and image project team at this time. I would greatly appreciate it as well as offer any help on the enterprise level scripts.

So far I've done Dial Up, VPN with an Auto un-installed for older versions before the newest version of the Cisco Client. Working on a few more such as IBM Auto Software/Driver application for all IBM Thinkpads. I've got over 50 X41's already staged and on the domain. All for VIP's and Elected officials.

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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.