autorun code for metro application
Monkey Forums/Monkey Programming/autorun code for metro application
| ||
//auto install..Execute "powershell Set-ExecutionPolicy unrestricted" Local currentdir$=CurrentDir() Local guid$=GetCfgVar( "PROJECT_GUID" ) Local cnid$=GetCfgVar( "PROJECT_PUBLISHER_ID" ) if platform.ToLower() = "win32" Then platform = "x86" Endif If CASED_CONFIG.ToLower() = "debug" Then currentdir = currentdir + "/AppPackages/monkey/monkey_1.0.0.0_" + platform + "_Debug_Test/Add-AppDevPackage.ps1" Else currentdir = currentdir + "/AppPackages/monkey/monkey_1.0.0.0_" + platform + "_Test/Add-AppDevPackage.ps1" Endif 'first try uninstall local uninstall$ = guid + "_1.0.0.0_" + platform + "__" + cnid Execute "powershell get-appxpackage > installpakcage.txt" local list$ = LoadString("installpakcage.txt") local i = list.Find( guid + "_", 0 ) if ( i <> -1 ) then local p = list.Find( "__", i ) if ( p <> -1 ) then ' found local result$ = list[i..p] Execute "powershell remove-appxpackage " + result + "__" + cnid, False endif endif DeleteFile( "installpakcage.txt") Execute "powershell " + currentdir + " -force" Local cmd$ = guid + "_" + cnid + "!App" Execute ROOTDIR + "/WinStoreBootup " + cmd,False //WinStoreBootup code // Win32 Console project... #include "stdafx.h" #include <shlobj.h> #include <stdio.h> #include <shobjidl.h> #include <objbase.h> #include <atlbase.h> #include <string> HRESULT LaunchApp(const std::wstring& strAppUserModelId, PDWORD pdwProcessId) { CComPtr<IApplicationActivationManager> spAppActivationManager; HRESULT hrResult = E_INVALIDARG; if (!strAppUserModelId.empty()) { // Instantiate IApplicationActivationManager hrResult = CoCreateInstance(CLSID_ApplicationActivationManager, NULL, CLSCTX_LOCAL_SERVER, IID_IApplicationActivationManager, (LPVOID*)&spAppActivationManager); if (SUCCEEDED(hrResult)) { // This call ensures that the app is launched as the foreground window hrResult = CoAllowSetForegroundWindow(spAppActivationManager, NULL); // Launch the app if (SUCCEEDED(hrResult)) { hrResult = spAppActivationManager->ActivateApplication(strAppUserModelId.c_str(), NULL, AO_NONE, pdwProcessId); } } } return hrResult; } int _tmain(int argc, _TCHAR* argv[]) { HRESULT hrResult = S_OK; if (SUCCEEDED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED))) { if (argc == 2) { DWORD dwProcessId = 0; ++argv; hrResult = LaunchApp(*argv, &dwProcessId); } else { hrResult = E_INVALIDARG; } CoUninitialize(); } return hrResult; } |