Skip to main content
Power Automate
    • Connectors
    • Templates
    • Take a guided tour
    • Digital process automation
    • Robotic process automation
    • Business process automation
    • Process advisor
    • AI Builder
  • Pricing
  • Partners
    • Blog
    • Documentation
    • Roadmap
    • Self-paced learning
    • Webinar
    • Business process and workflow automation topics
    • Overview
    • Issues
    • Give feedback
    • Overview
    • Forums
    • Galleries
    • Submit ideas
    • User groups
    • Register
    • ·
    • Sign in
    • ·
    • Help
    Go To
    • Microsoft Power Automate Community
    • Welcome to the Community!
    • News & Announcements
    • Get Help with Power Automate
    • General Power Automate Discussion
    • Using Connectors
    • Building Flows
    • Using Flows
    • Power Automate Desktop
    • Process Advisor
    • AI Builder
    • Power Automate Mobile App
    • Translation Quality Feedback
    • Connector Development
    • Power Platform Integration - Better Together!
    • Power Platform Integrations
    • Power Platform and Dynamics 365 Integrations
    • Galleries
    • Community Connections & How-To Videos
    • Webinars and Video Gallery
    • Power Automate Cookbook
    • Events
    • 2021 MSBizAppsSummit Gallery
    • 2020 MSBizAppsSummit Gallery
    • 2019 MSBizAppsSummit Gallery
    • Community Engagement
    • Community AMA
    • Community Blog
    • Power Automate Community Blog
    • Community Support
    • Community Accounts & Registration
    • Using the Community
    • Community Feedback
    cancel
    Turn on suggestions
    Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
    Showing results for 
    Search instead for 
    Did you mean: 
    • Microsoft Power Automate Community
    • Galleries
    • Power Automate Cookbook
    • [Power Automate UI flows]Executing any command or ...

    [Power Automate UI flows]Executing any command or script via a script

    01-08-2020 22:09 PM - last edited 04-06-2021 08:19 AM

    kinuasa
    Resolver IV
    1564 Views
    LinkedIn LinkedIn Facebook Facebook Twitter Twitter
    kinuasa
    kinuasa Resolver IV
    Resolver IV
    • Mark as New
    • Bookmark
    • Subscribe
    • Mute
    • Subscribe to RSS Feed
    • Permalink
    • Print
    • Report Inappropriate Content

    [Power Automate UI flows]Executing any command or script via a script

    ‎01-08-2020 10:09 PM

    *This post is written in Japanese. Please translate and read it.

     

    [ Create and test desktop UI flows ]にある通り、現時点ではUI flowsは対話形式による操作をサポートしていません。

    そこで、簡単なスクリプトを介して、任意のコマンドやスクリプトを実行する方法を紹介します。

     

    ・準備

     

    コマンドを実行するためのスクリプトを準備します。
    下記コードをテキストエディタに貼り付け、vbsファイルとして適当なフォルダ(e.g. C:\Scripts\exec.vbs)に保存してください。

     

     

     

    Option Explicit
     
    Dim ret
     
    ret = InputBox("Enter a command path.", "Exec Any Commands")
    If IsEmpty(ret) = True Then WScript.Quit
    If Len(Trim(ret)) < 1 Then WScript.Quit
    On Error Resume Next
    With CreateObject("Scripting.FileSystemObject")
      Select Case LCase(.GetExtensionName(ret))
        Case "vbs"
          CreateObject("WScript.Shell").Run """" & ret & """", 1, False
        Case Else
          With CreateObject("WbemScripting.SWbemLocator").ConnectServer.Get("Win32_Process")
            .Create ret, Null, Null, Null
          End With
      End Select
    End With
    On Error GoTo 0

     

     

     

    ・UI flowsの作成

     

    UI flowsを新規作成します。

     

    01.jpg

    02.jpg

    03.jpg

     

    スクリプト(exec.vbs)を実行した状態でレコーダーを起動し、操作を記録します。

     

    04.jpg

     

    InputBoxに実行したいコマンド(e.g. cmd /k ping www.microsoft.com)を入力し、[ Enter ]キーを押します。

     

    05.jpg

     

    コマンドの実行を確認し、記録を終了します。

     

    06.jpg

     

    記録されたフローは下図のようになります。

     

    07.jpg

     

    起動部分のアプリケーションパスが[ C:\WINDOWS\System32\WScript.exe ]となっているので、スクリプトのパスに修正します。

     

    08.jpg

     

    SendKeysの値としてEnterキーが記録されていないので、[ <Keys.Return> ]を追加します。

     

    09.jpg

     

    フロー保存後テストを実行すると、スクリプト経由でコマンドが呼び出されていることが確認できます。

     

    10.gif

     

    ・UI flowsを呼び出すフローの作成

     

    UI flowsを呼び出すフローを新規作成します。

     

    11.jpg12.jpg13.jpg

     

    保存してテスト実行すると、UI flowsが呼び出され、コマンドが実行されます。

     

    14.gif

     

    簡単なスクリプトを介することで、UI flowsから任意のコマンドやスクリプトを実行することができます。

    標準でWindowsとの対話がサポートされれば、この方法は不要になります。
    そのため、この方法はあまり推奨されるものではないでしょう。

    Preview file
    68 KB
    callflow-cmd_20200109054406.zip
    Labels:
    • Labels:
    • Desktop flows
    Message 1 of 1
    1,564 Views
    0 Kudos
    Reply
    • All forum topics
    • Previous Topic
    • Next Topic

    Power Platform

    • Overview
    • Power BI
    • Power Apps
    • Power Pages
    • Power Automate
    • Power Virtual Agents

    • Sign up free
    • Sign in

    Browse

    • Templates
    • Connectors
    • Partners

    Downloads

    • Mobile
    • Gateway

    Learn

    • Documentation
    • Learn
    • Support
    • Community
    • Give feedback
    • Blog
    • Pricing

    • © 2023 Microsoft
    • Contact us
    • Trademarks
    • Privacy & cookies
    • Manage cookies
    • Terms of use
    • Terms & conditions
    California Consumer Privacy Act (CCPA) Opt-Out Icon Your California Privacy Choices