Daniel Toplak
Daniel Toplak

Reputation: 345

UWP JavaScript APP: run win32 EXE with parameters

What is the best working way to call a win32 executable from JavaScript UWP app (Windows Anniversary update)

I have tried to configure the win32 via an AppService:

<uap:Extension Category="windows.appService" StartPage="www\index.html">
    <uap:AppService Name="CommunicationService" />
</uap:Extension>

<desktop:Extension Category="windows.fullTrustProcess" Executable="mywin32app.exe" EntryPoint="Windows.FullTrustApplication" />

Now I can launch it with Windows.ApplicationModel.FullTrustProcessLauncher.launchFullTrustProcessForCurrentAppAsync() from JavaScript, but how do I launch It with parameters?

Upvotes: 2

Views: 1100

Answers (2)

Hannes Nel
Hannes Nel

Reputation: 532

The provided mechanism for passing parameters doesn't seem to allow you to do them dynamically at the moment, which is not ideal. You can only pass through hard-coded parameters to your process. I suggest using an App Service extension in your UWP app to make data available to your full trust process. The process is documented here.

Do it this way:

Launch full trust process. Add a parameter to indicate that it is launched from UWP.

In your full trust process, check if the parameter was passed in, and call back to the UWP process' app service task to get the data you would otherwise pass in as a parameter.

Upvotes: 0

Elvis Xia - MSFT
Elvis Xia - MSFT

Reputation: 10831

but how do I launch It with parameters

There is a with-parameter version of this method that you can use: FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync(String).

And declear the parameters in appxmanifest file:

<desktop:Extension Category="windows.fullTrustProcess" Executable="fulltrustprocess.exe"> 
      <desktop:FullTrustProcess> 
        <desktop:ParameterGroup GroupId="SyncGroup" Parameters="/Sync"/> 
        <desktop:ParameterGroup GroupId="OtherGroup" Parameters="/Other"/> 
      </desktop:FullTrustProcess> 
</desktop:Extension> 

Upvotes: 1

Related Questions