Jump to content

Need help with Autoit scripe to execute exe and


Recommended Posts

Greetings,

I am trying to figure out how I can execute a few USMT commands with an autoit script. Any help would be much appreciated.

I am trying to restore a users profile using USMT. There is a mapped drive share that stores the users captured profiles and I need to restore it on another computer.

The way this works if you manually input it into a command prompt is by having a folder called USMT on the root of the drive and calling loadstate.exe with these parameters  M:"profilename" /i:C:USMTx86MigUser.xml /i:C:USMTx86MigApp.xml /i:C:USMTx86wallpaper.xml /c

The above method works, but you have to type the exact profile name in the "profilename" field. 

However, since there are multiple profiles, I want to prompt the user to specify the profile name. 

This is where the AutoiT script comes in:

Right now it prompts the user for the old computer name, if it find it, it executes the loadstate.exe, then looks for the $file variable that the user inputted to determine what profile to restore with the appropriate parameters. 

The part that I am stuck at (highlighted in red)  is that after calling the loadstate on the c: drive, I am not sure how to include the user input so that it executes the exact same commands as the one that works when you do it through a command prompt. 

$WineDOS = "C:USMT"
$share = "my share path"
 
$read = InputBox ("", "Please Enter in your Old Computer Name")
 
Local $Search = FileFindFirstFile ($share & $read)
$file = FileFindNextFile($search)
 
If $search = -1 Then
        MsgBox(0, "Restore Profile", "No profile was found - Please check name and try again")
    Else
        MsgBox(0, "Restore Profile", "Profile found: " & $file)
ShellExecuteWait($WineDOS & "x86loadstate.exe", & $File & /v:13 /c /all /i:" & $WineDOS & "x86MigApp.xml /i:" & $WineDOS & "x86MigSys.xml /i:" & $WineDOS & "x86MigUser.xml", $WineDOS)
        Exit
EndIf
 
I have tried several combinations but I cannot get it to work.   Any help would be much appreciated. 
Link to comment
Share on other sites

hello nousername56, welcome to AutoIt and to the forum!

you are missing a double-quote before teh /v:13 parameter, to indicate a string is starting. SciTe use coluring to help you see what's wrong, and also use the code tag (the button marked A in the toolbar) when you post code to the forum, it makes it much clearer.

the 1st line is yours, the 2nd is mine, see the color differences:

ShellExecuteWait($WineDOS & "\x86\loadstate.exe", & $File & /v:13 /c /all /i:" & $WineDOS & "\x86\MigApp.xml /i:" & $WineDOS & "\x86\MigSys.xml /i:" & $WineDOS & "\x86\MigUser.xml", $WineDOS)
ShellExecuteWait($WineDOS & "\x86\loadstate.exe", & $File & "/v:13 /c /all /i:" & $WineDOS & "\x86\MigApp.xml /i:" & $WineDOS & "\x86\MigSys.xml /i:" & $WineDOS & "\x86\MigUser.xml", $WineDOS)

also, you have $WineDOS end with backslash, and the appended strings "x86..." begins with backslash, so combined it makes 2 adjacent backslashes.

also, i'd use RunWait() instead of ShellExecuteWait() - i find it easier to write the parameters line, and easier to perform my next advice:

before you call RunWait(), call ConsoleWrite() with the same parameter. then you see the actual command that is about to be executed, you can better troubleshoot it then. if console output is less convenient, use FileWriteLine() instead for the same purpose.

Edited by orbs

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

@orbs : I think you forgot to remove the & before $file in the 2nd parameter (and a space after) ;)

ShellExecuteWait($WineDOS & "\x86\loadstate.exe", $File & " /v:13 /c /all /i:" & $WineDOS & "\x86\MigApp.xml /i:" & $WineDOS & "\x86\MigSys.xml /i:" & $WineDOS & "\x86\MigUser.xml", $WineDOS)
Edited by jguinch
Link to comment
Share on other sites

 

@orbs : I think you forgot to remove the & before $file in the 2nd parameter (and a space before) ;)

ShellExecuteWait($WineDOS & "\x86\loadstate.exe", $File & " /v:13 /c /all /i:" & $WineDOS & "\x86\MigApp.xml /i:" & $WineDOS & "\x86\MigSys.xml /i:" & $WineDOS & "\x86\MigUser.xml", $WineDOS)

 

 

quite right!

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...