How do I show the output of a command called within a gui script

I'm starting from scratch on a project I've been tasked with.  My intention is a quick down-and-dirty way to apply an image within winPE to apply a windows image to the machine I've booted to a usb drive loaded with winPE.
Here's my start.  It's rough, but, I have to start somewhere.
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
$objForm = New-Object System.Windows.Forms.Form
$objForm.Text = "DISM"
$objForm.Size = New-Object System.Drawing.Size(600,400)
$objForm.AutoSizeMode = "GrowAndShrink"
$objForm.StartPosition = "CenterScreen"
$objForm.FormBorderStyle = "Fixed3D"
$objForm.KeyPreview = $True
Function do_DISM{
$dism = "dism /apply-image /imagefile:D:\W7x86.wim /index:1 /applydir:C:\"
Invoke-Expression $dism
$DISMButton = New-Object System.Windows.Forms.Button
$DISMButton.BackColor = "ButtonFace"
$DISMButton.Location = New-Object System.Drawing.Size(12,27)
$DISMButton.Size = New-Object System.Drawing.Size(120,25)
$DISMButton.TabIndex = 1
$DISMButton.Text = “Start DISM”
$DISMButton.Add_Click({do_DISM})
$objForm.Controls.Add($DISMButton)
$objForm.Add_Shown({$objForm.Activate()})
[void] $objForm.ShowDialog()
Now, this does work, and it will in fact apply the windows image to c:\ which is what I need it to do.  But, I have a few quesitons.
Am I correct to use "Invoke-Expression" in the function do_DISM to start the command?  According to technet's articles, yes, but, want to make sure I'm doing this the proper way, since I'm learning that calling Invoke-Expression isn't always
the way to do things.
Also, since this will be used by others in my group, I'm going to need to show some sort of progress report on how far along DISM is getting along, otherwise, 5 minutes into DISM running, some people are going to think nothing's happening, and just power
down the computer no matter what I tell them.  I know that running DISM from the command line, it will show a progress bar that is adequate for what I'm needing.  Running the script above and clicking the button, it does run, but, all in the background
with no progress indication.  Is there a way I can tell either in the function or when the function calls Invoke-Expression to run DISM, to open in a new command window which shows the live progress of the command running?
Again, my disclaimer: VERY new to writing bits of code, and am trying my best here, so, thanks in advance for patience with me.

That's exactly what I was looking for!  Thank you!
Changed code to:
$dism = "X:\Windows\System32\Cmd.exe /c start CMD /k dism /apply-image /imagefile:D:\W7x86.wim /index:1 /applydir:C:\"
And voila, new window opened with the live output of dism.
new... and have a glazed over look about my eyes to prove it...

Similar Messages

  • How to run the report and show the output in excel file

    salam
    how to run the report and show the output in excel file,
    how to run the report and print the o/p via printer
    how to run the report and send the o/p via mail
    thank u all

    Hi,
    There are Parameters DESTTYPE, DESFORMAT and DESNAME. You can set these parameters to get as you want.
    1) Output in Excel File
         ADD_PARAMETER(PL_ID, 'DESTYPE', TEXT_PARAMETER, 'FILE');
         ADD_PARAMETER(PL_ID, 'DESFORMAT', TEXT_PARAMETER, 'DELIMITED');
         ADD_PARAMETER(PL_ID, 'DESNAME', TEXT_PARAMETER, '<file_name>.XLS');2) output to printer
         ADD_PARAMETER(PL_ID, 'DESTYPE', TEXT_PARAMETER, 'PRINTER');
         ADD_PARAMETER(PL_ID, 'DESNAME', TEXT_PARAMETER, '<printer_name>');3) Email - Have to configure SMTP and all. ( i didn't checked it)
         ADD_PARAMETER(PL_ID, 'DESTYPE', TEXT_PARAMETER, 'MAIL');
         ADD_PARAMETER(PL_ID, 'DESNAME', TEXT_PARAMETER, '<email_id>');Regards,
    Manu.
    If this answer is helpful or correct, please mark it. Thanks.

  • How i can show the selection screen input field in the top of page in alv

    hi ,
              how i can show the selection screen input field in the top of page in alv  grid output.
    tell me the process

    Hi,
    excample from my program:
    FORM topof_page.
      DATA: l_it_header   TYPE TABLE OF slis_listheader WITH HEADER LINE,
            l_info        LIKE l_it_header-info.
      DATA: l_it_textpool TYPE TABLE OF textpool WITH HEADER LINE.
      DATA: l_key LIKE l_it_textpool-key.
      READ TEXTPOOL c_repid INTO l_it_textpool LANGUAGE sy-langu.
      DEFINE m_selinfo.
        if not &1 is initial.
          clear l_it_header.
          l_it_header-typ   = 'S'.
          l_key = '&1'.
          translate l_key to upper case.
          read table l_it_textpool with key key = l_key.
          if sy-subrc = 0.
            shift l_it_textpool-entry left deleting leading space.
            l_it_header-key = l_it_textpool-entry  .
          endif.
          loop at &1.
            case &1-option.
              when 'EQ'
                or 'BT'
                or 'CP'.
                write &1-low to l_it_header-info.
              when others.
                write &1-low to l_it_header-info.
                concatenate &1-option
                            l_it_header-info
                       into l_it_header-info
                       separated by space.
            endcase.
            if not &1-high is initial.
              write &1-high to l_info left-justified.
              concatenate l_it_header-info
                          l_info
                     into l_it_header-info
                     separated by space.
            endif.
            if &1-sign = 'E'.
              concatenate ']'
                          l_it_header-info
                     into l_it_header-info.
            endif.
            append l_it_header.
            clear: l_it_header-key,
                   l_it_header-info.
          endloop.
        endif.
      END-OF-DEFINITION.
      m_selinfo: s_trmdat,
                 s_trmext,
                 s_trmint,
                 s_fkdat,
                 s_delno,
                 s_vbeln,
                 s_deact,
                 s_kdmat.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
           EXPORTING
                it_list_commentary = l_it_header[].
    ENDFORM.
    I hope, this will help you.
    Regards
    Nicole

  • AppBuilder Application doesnt show the output

    Hi All,
      I am doing the sample application in AppBuilder, when i run the application it opens a new browser window but it doesnt show the output.
    this is the problem, how to resolve this?
    If any body come across this issue please help me.
    Regards,
    Sravanya

    Hi Sravanya K,
    There seems to be some compatibility issue with latest Chrome update. (All the other pre requisites have nt had any releases very recently)
    Last release of other Pre requisites :
    Node JS - 5th june 2014 ( Node.js ChangeLog )
    JDK - (its to be manually updated).
    APP Builder (appbuilder-1.0.1252.zip is the last release which happened a long time back )
    Google Chrome - Can find latest release logs in Chrome Releases and chrome has an Update almost everyday
    UI5 Liraries - As per OpenUI5 - Download  16 th July 2014 is the last release of Ui5 libraries.
    More over App builder does not need any internet connectivity to atleast run the sample applications / templates of SuperList,Chart. (so the issue might be internally in the system using these pre requisites )
    So i certainly doubt the Auto Update feature of Google Chrome , causing this issue.
    Though this currently have nt worked in latest version of chrome in my system , other major browsers are still supported .
    As a work around can suggest to work with other browsers.
    I also tried with Safari , Firefox and  safari  worked satisfactorily -
    (Chrome, Safari are recommended for App Builder ) (Firefox worked partially)
    attached is the screenshot of Sample Application running in Safari
    Regards
    Virinchy

  • How do you load the Output Mod in Bridge

    How do you load the Output Mod in Bridge?

    I downloaded the AOM_Mac zip file from Adobe and copied the contents 1
    Adobe Output Module and 2 Adobe output Module workspace to
    Library/AppSupport/Adobe/BridgeCCExtensions.  When I open Bridge the Output
    Module shows in preferences under Startup Scrips, but not in the menu bar
    or in the Window/workspace bar.  So I can not access it.  I'm thinking of
    just not using bridge and just going with Lightroom and photoshop, as I
    think I can do more in Lightroom than bridge anyway.  cheers~photoick

  • I had to restore my iPhone 4s and now my recent calls show only phone numbers instead of the contact's name.  How can I restore the names to my recent calls list?

    I had to restore my iPhone 4s and now my recent calls show only phone numbers instead of the contact's name.  How can I restore the names to my recent calls list?

    Are the contact details in your contacts app, the phone app uses the contact app to put names against telephone numbers.

  • How to stop showing the pop-up window to change password

    Hi,
    How to stop showing the pop-up windows of changing password if the password is expired in dba_users table. This is related to form6.
    Pls advice.
    Thanks
    Raj

    Raj,
    Please do not start a new thread with the same problem. If you still need help, respond to your former thread, and we will still try to help you. But you haven't provided an answer to why you can't trap the error.
    Re: Trapping of error ora-28001, user expired in daa_users table

  • How do you show the number of days per month?

    How do you show the number of days per month?
    I am working on a budget.  I want to know how much to amortize each month to fund an investment.  Income comes monthly, but expenses leave in days, or weeks.  The number of days and weeks in months vary. 
    I want to figure out income and expenses per day, per month and per year, so I know how much can be invested each month, week or day.  For a start I would like a formula that shows how many days are in each month?

    thanks..
    I solve my problem as
    public class MyExample {
        public static void main(String a[]) {
            String stdate = "2009-03-01";
            java.sql.Date currentDate = new java.sql.Date(System.currentTimeMillis());
            java.sql.Date preDate = java.sql.Date.valueOf(stdate);
            System.out.println(currentDate);
            System.out.println(preDate);
    //        int dateCom = preDate.compareTo(currentDate);
    //        System.out.println(dateCom);
            long diff = currentDate.getTime() - preDate.getTime();
            int days = (int) Math.floor(diff / (24 * 60 * 60 * 1000));
             System.out.println(days);
    }

  • How can I show the chart in forms?

    Dear all:
    I want to create a line chart. I use the chart wizard and it is successful to create the chart. But, it can't show the chart when I run the form. How can I show the chart in form6i?
    Besides, I see a document that refer to 'OG.pll'.
    I can't find the OG.pll in form6i. Do I need 'OG.pll' to show the chart when I run the form? Thank you very much!!

    Hi Carlos,
    You can try to create a code node for check which signature to print.
    In global variable declare a variable ie named g_sign type TDOBNAME.
    Then pass this var to name of graphics &g_sign&
    please check and reply.
    regards,

  • How do i show the filename.type instead of the entire file path?

    How do i show the filename.type instead of the entire file path?
    I want it to show "ProgramSetup.exe" instead of "C:/Program Files/Oracle/JavaFX/ProgramSetup.exe"
    I have created a JavaFX program with the help of my manager
    below are the code
                   File file = fileChooser.showOpenDialog(Admin.mainStage);
                   if (file != null) {
                        textFiles.setText(file.getAbsolutePath());
                        String absolutePath = file.getAbsolutePath();
                        //String fileName = new File(absolutePath).getName();the reason i put the last line as // because it has error on that line....
    if i remove the last line, it will display but with the full path....
    i search through google and the guide on many forums aren't clear to me.....some said there are 2 ways but i tried and it is not working, atleast for me...maybe i left out something or what....can anyone help me on this?

    You don’t need the absolutePath:
    File file = fileChooser.showOpenDialog(Admin.mainStage);
                   if (file != null) {
                        textFiles.setText(file.getName());
                               }

  • How can i retrieve the output of procedure using a select statement ?

    Hi every one.
    this mite be dumm ?
    how can i use the output of the a procedure containing multiple rows of data in a select statement ?

    This is not  a SQL Developer question. You should ask it in the SQL and PL/SQL forum.
    The short answer is you can't.  Sounds is if you are trying to use MSSQL techniques in oracle. Learn oracle techniques

  • How do I show the details of a customer when they are logged in a secure zone?

    How do I show the details of a customer when they are logged in a secure zone?
    I want to show the customer details as well as some customer CRM fields that are applied to the customer. None of these are entered via a form, they would be entered by the client. The customer would need to be able to log in to view the information and get an email alert when it is updated. Help!?

    Hi,
    You might want to look into customer service zones which allows customers once logged in to see their case, order and own details. 
    - http://kb.worldsecuresystems.com/133/bc_133.html
    - http://kb.worldsecuresystems.com/kb/customer-service-area-orders.html
    - http://kb.worldsecuresystems.com/kb/allowing-customers-view-update-crm.html
    Kind regards,
    -Sidney

  • How we can show the xml data without any attribute in a flex tree (without having any label field) ?

    how we can show the following data in a flex tree (without having any
    label field) ?
    <?xml version="1.0"?>
    <rootNode>
            <childNode>
            < subchildNode >
                    <valueNode>1000</valueNode >
                    < valueNode >999-888-777</valueNode >
                    < valueNode >STORTZ</valueNode >
                    < valueNode >PAM STORTZ</valueNode >
                    < valueNode >88 ST. MORTON ROAD</valueNode>
            </subchildNode>
            </childNode >
    </rootNode >

    as is - no how
    wrap those xml chunk with a class having clear public properties like:
    public class dataRecord {
         protected var xml:XML;
         function dataRecord(xml:XML) {
              this.xml = xml;
         public function get id ():String {
              return XML(xml.descendants("valueNode")[0]).toString();
         // and so on
    simpliest way is to change xml structure to use attributes than wrapping that thing with AS code, it's time consuming and non efficient.

  • How can i see the output of a form

    I am having one driver program and form.From these two how can i see the output.

    Hi Sunny
    You might already know; but for the driver program; a smartform is just a function module.
    (In the smartform; this function module name can be found in the menu tab Environment -> Function Module Name.)
    Note: The FM 'SSF_FUNCTION_MODULE_NAME' is obviously the correct way of getting the FM name from the smartform name !!
    So all you need to do is call this function module passing any variable / tables you need to pass to the smartform from your driver program.
    Hope it helps
    Neer

  • How to Hide/show the columns data while doing Drill down or drill up

    Hi ,
    How to Hide/show the columns data while doing Drill down or drill up in webi report .
    Does it possible BO 3.1 version ?
    Please suggest me on this.
    Thanks & Regards
    Venkat

    While that is not there yet, you can make use of the show when empty yes/no in combination with alerters.
    So I have an alerter applied to every cell of the table.
    When a condition is true (say I drilled down) I just put = "" in every cell, emptying the table,
    because its now empty and doesn't need to show, it wont.
    For the detail table I use the opposite, so when you drilled down it becomes visible...
    Hope this helps all that do not have 40 yet
    Good luck,
    Marianne

Maybe you are looking for