blob: ded93cf612c188f77ebcde0485cf948e852472ab [file] [log] [blame]
<#
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
#>
$code = @"
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace StoreAppRunner
{
public enum ActivateOptions
{
None = 0,
DesignMode = 0x1,
NoErrorUI = 0x2,
NoSplashScreen = 0x4
}
[ComImport]
[Guid("2e941141-7f97-4756-ba1d-9decde894a3d")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IApplicationActivationManager
{
IntPtr ActivateApplication([In] String appUserModelId, [In] String arguments, [In] ActivateOptions options, [Out] out UInt32 processId);
IntPtr ActivateForFile([In] String appUserModelId, [In] IntPtr itemArray, [In] String verb, [Out] out UInt32 processId);
IntPtr ActivateForProtocol([In] String appUserModelId, [In] IntPtr itemArray, [Out] out UInt32 processId);
}
[ComImport]
[Guid("45BA127D-10A8-46EA-8AB7-56EA9078943C")]
public class ApplicationActivationManager : IApplicationActivationManager
{
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
public extern IntPtr ActivateApplication([In] String appUserModelId, [In] String arguments, [In] ActivateOptions options, [Out] out UInt32 processId);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
public extern IntPtr ActivateForFile([In] String appUserModelId, [In] IntPtr itemArray, [In] String verb, [Out] out UInt32 processId);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
public extern IntPtr ActivateForProtocol([In] String appUserModelId, [In] IntPtr itemArray, [Out] out UInt32 processId);
}
}
"@
function Uninstall-App {
param(
[Parameter(Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)]
[string] $ID <# package.appxmanifest//Identity@name #>
)
$package = Get-AppxPackage $ID
if($package) {
Remove-AppxPackage $package.PackageFullName
}
}
function Install-App {
param(
[Parameter(Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)]
[string] $Path <# Full path to Add-AppDevPackage.ps1 #>
)
Invoke-Expression ($Path + " -force")
}
function Start-Locally {
param(
[Parameter(Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)]
[string] $ID <# package.appxmanifest//Identity@name #>
)
$package = Get-AppxPackage $ID
$manifest = Get-appxpackagemanifest $package
$applicationUserModelId = $package.PackageFamilyName + "!" + $manifest.package.applications.application.id
Write-Host "ActivateApplication: " $applicationUserModelId
add-type -TypeDefinition $code
$appActivator = new-object StoreAppRunner.ApplicationActivationManager
$appActivator.ActivateApplication($applicationUserModelId,$null,[StoreAppRunner.ActivateOptions]::None,[ref]0)
}