Is it possible to create a windows installer for combine an application built with Electron Framework and AutoHotkey Tool? - build

I have try many way to built the electron app with AutoHotKey tool as one exe file but still it's didn't work, if you find any way please help me. Here is the build.js code:
// C:\Users\sdkca\Desktop\electron-workspace\build.js
var electronInstaller = require('electron-winstaller');
// In this case, we can use relative paths
var settings = {
// Specify the folder where the built app is located
appDirectory: './KIT Online Examination System-win32-x64',
// Specify the existing folder where
outputDirectory: './KIT-online-exam-installers',
// The name of the Author of the app (the name of your company)
authors: 'Kirirom Institute of Technology.',
// The name of the executable of your built
exe: './KIT Online Examination System.exe',
exe: './AutoHotKey.exe'
};
resultPromise = electronInstaller.createWindowsInstaller(settings);
resultPromise.then(() => {
console.log
("The installers of your application were succesfully created !");
}, (e) => {
console.log(`Well, sometimes you are not so lucky: ${e.message}`)
});

Related

How to pass parameters from UWP app to pure C++ console app?

I have a UWP app that launches a C++ console app (not a Windows runtime component or anything related to UWP). I need the UWP app to pass a file path to the C++ console app so the console app can process it.
For reference, I followed these blog posts:
https://stefanwick.com/2018/04/06/uwp-with-desktop-extension-part-1/
https://stefanwick.com/2018/04/06/uwp-with-desktop-extension-part-2/
As for the parameters, I have this code in my Package.appxmanifest file:
<Extensions>
<desktop:Extension xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10"
Category="windows.fullTrustProcess"
Executable="PTSExtractionWRT\PTSExtractionWRT.exe">
<desktop:FullTrustProcess>
<desktop:ParameterGroup GroupId="ExistingFile" Parameters="/existingFile"/>
</desktop:FullTrustProcess>
</desktop:Extension>
</Extensions>
and I launch the console app like so from MainPage.xaml.cs
if (ApiInformation.IsApiContractPresent("Windows.ApplicationModel.FullTrustAppContract", 1, 0))
{
// store command line parameters in local settings so Launcher can retrieve them
ApplicationData.Current.LocalSettings.Values["parameters"] = filePath;
var appData = ApplicationData.Current.LocalSettings;
await Windows.ApplicationModel.FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync("ExistingFile");
}
The problem is that the filePath variable I'm sending is getting stored in the C:\Users\14087\AppData\Local\Packages\23930191-5d12-44d5-81c3-808263a5b2f9_qe1bgctg42gkj\Settings\settings.dat file with this path, and I can't find a way to access this file from the C++ console app.
What is being sent as arguments to the C++ app is "/existingFile" from the Package.appxmanifest file.
How can I retrieve the real parameter?
Referring to the document, you could configure your pure c++ console app with the Microsoft.Windows.CppWinRT NuGet package to enable the c++ console app use C++/WinRT APIs, so that you can get the parameters by using ApplicationData API in C++ console project.
Please check the following steps for your c++ console project:
Open the NuGet Package Manager(option Tools > NuGet Package Manager > Manage NuGet Package for Solution…).
Input cppwinrt in Browse page, find Microsoft.Windows.CppWinRT and install it for your c++ console project.
Open the Properties page for your c++ console project, in Configuration Properties > General page, set the option C++ Language Standard as ISO C++ 17 Standard(/std:c++ 17).
In your c++ console project, add the necessary header file and code to test the ApplicationData API, for example:
#include <iostream>
#include <winrt/Windows.Storage.h>
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Foundation.Collections.h>
int main()
{
std::cout << "Hello World!\n";
winrt::Windows::Storage::ApplicationDataContainer localSettings= winrt::Windows::Storage::ApplicationData::Current().LocalSettings();
auto values = localSettings.Values();
//values.Insert(L"exampleSetting", winrt::Windows::Foundation::PropertyValue::CreateString(L"Hello Windows"));
winrt::hstring val = winrt::unbox_value<winrt::hstring>(values.Lookup(L"parameters"));
std::wcout << val.c_str() << std::endl;
system("PAUSE");
}
For more information about C++/WinRT, you could refer to the document.

Test fails with `flutter test` but passes when debugged from test file

How can I read a file using a relative path when running flutter test?
When running flutter test the File('path/to/file') needs an absolute path but a relative path works when debugging.
I feel like I'm missing something obvious. Using VS Code, I can run a test by starting debug while in one of the test files. By doing so, the test will pass when using a relative path to read a file. However, when I run flutter test from the terminal, the same test fails because it is unable to find the file unless I change it to use an absolute path in which case the test will pass.
This is the line of code in the test that tries to create a model from the json file:
final tUserModel = UserModel.fromJson(json.decode(fixture('user_cached.json')));
The fixture function is imported from a different file and implemented as follows:
import 'dart:io';
String fixture(String name) => File('test/fixtures/$name').readAsStringSync();
When using that relative path I get the following output from terminal:
flutter test
00:03 +3 ~1 -1: loading /home/user/MyApp/test/features/user/data/datasources/user_local_data_source_test.dart [E]
Failed to load "/home/user/MyApp/test/features/user/data/datasources/user_local_data_source_test.dart": Cannot open file, path = 'test/fixtures/user_cached.json' (OS Error: No such file or directory, errno = 2)
dart:io _File.readAsStringSync
fixtures/fixture_reader.dart 3:60 fixture
features/user/data/datasources/user_local_data_source_test.dart 27:40 main.<fn>
package:test_api Declarer.group
package:flutter_test/src/test_compat.dart 226:13 group
features/user/data/datasources/user_local_data_source_test.dart 25:3 main
===== asynchronous gap ===========================
package:test_api RemoteListener.start
/tmp/flutter_tools.DRSZQD/flutter_test_listener.IPDUJJ/listener.dart 16:25 serializeSuite
/tmp/flutter_tools.DRSZQD/flutter_test_listener.IPDUJJ/listener.dart 43:36 main
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, 1.19.0-4.1.pre, on Linux, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.0)
[✓] VS Code (version 1.46.0)
[✓] Connected device (3 available)
• No issues found!
How can I get flutter test to work with a relative file path?
Is there another way to run all tests from VS Code?
Try this.
String fixture(String name) {
var dir = Directory.current.path;
if (dir.endsWith('/test')) {
dir = dir.replaceAll('/test', '');
}
return File('$dir/test/fixtures/$name').readAsStringSync();
}
The issue has been raised a few times here: https://github.com/flutter/flutter/issues/20907
This worked for me:
import 'dart:io';
import 'package:path/path.dart';
String fixture(String name) {
final testDirectory = join(
Directory.current.path,
Directory.current.path.endsWith('test') ? '' : 'test',
);
return File('$testDirectory/fixtures/$name').readAsStringSync();
}
Thanks to: https://github.com/flutter/flutter/issues/20907#issuecomment-466185328

Qt installer unregister filetype on Windows

I'm working with Qt installer to deploy my software on Windows machines. So far, everything works as expected: I can install stuff and register file extensions to be launched with my software.
Let's say my app is named MyApp and the extension is .myapp.
Here is the code that I use to do so in an installscript.qs script:
Component.prototype.createOperations = function()
{
component.createOperations();
if (systemInfo.productType === "windows") {
component.addOperation(
"RegisterFileType",
"myapp",
"#TargetDir#\\MyApp.exe" + " \"%1\"",
"Company - MyApp file",
"application/this.is.awesome",
"#TargetDir#\\MyApp.exe" + "," + 1,
"ProgId=Company.MyApp." + "myapp"
);
}
}
Now, when I uninstall the app using the Qt's uninstaller, it correctly removes the files from my PC but the filetype registration remains in Windows' settings and when reinstallating the app again, the installer simply adds another filetype registration regardless of the existing one(s). So at this point if I install/uninstall my app 20 times, I'll have 20 copies of the same filetype registration.
Any idea what's going on ?

Need to Programmatically Recompile all Script Tasks in DTSX Packages after Mass Find-And-Replace

An upcoming move of our Data Warehouse has us needing to change many Connection Strings and UNC File Paths located in VBA Script Tasks within DTSX Packages.
We've performed a mass find-and-replace but when changing Script Tasks using this method, the binaries run during DTSX Package execution don't get recompiled at run time, resulting in the find-and-replaced changes not being reflected in the Script Task's execution.
I've found some articles on how to do it in SQL Server 2008 and 2012, but we're using SQL Server 2014 and the code examples here aren't working for me:(https://blogs.msdn.microsoft.com/jason_howell/2013/03/05/script-component-recompile-in-sql-server-2012-integration-services-ssis-to-refresh-metadata/).
Some of the questions in the comments speak to my problem but none of the "I fixed this this way [navigate to path and include references]" are working for me -- I don't see these assemblies, and with the changes between 2008 to 2012, and now us on 2014, I'm uncertain whether these libraries are even included in my distribution...
So, I have a whole bunch of DTSX files in various sub directories that require their script tasks be recompiled in order for us to go live with these changes.
I'm hoping to not-have to open every script task in every package manually to force the build of each task.
Thanks in advance for any potential solutions!
I create a Console application with the code necesary to recompile every ScriptTask inside a dtsx package, using Visual Studio 2013 and C# up to two levels. Path for every assembly that needs to be referenced are included as comments in the code. pkgLocation is the path to the package(in the ends I build a Windows Form app, but this is the base and working code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SqlServer.Dts.Design;
using Microsoft.SqlServer.Dts.Runtime;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Pipeline;
using Microsoft.SqlServer.VSTAHosting;
using Microsoft.SqlServer.IntegrationServices.VSTA;
using Microsoft.SqlServer.Dts.Tasks.ScriptTask;
using System.IO;
//Libraries
//C:\windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SqlServer.Dts.Design\v4.0_12.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.Dts.Design.dll
//C:\Program Files (x86)\Microsoft SQL Server\120\SDK\Assemblies\Microsoft.SqlServer.DTSPipelineWrap.dll
//C:\Program Files (x86)\Microsoft SQL Server\120\SDK\Assemblies\Microsoft.SQLServer.DTSRuntimeWrap.dll
//C:\windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SqlServer.IntegrationServices.VSTA\v4.0_12.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.IntegrationServices.VSTA.dll
//C:\Program Files (x86)\Microsoft SQL Server\120\SDK\Assemblies\Microsoft.SQLServer.ManagedDTS.dll
//C:\windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SqlServer.PipelineHost\v4.0_12.0.0.0__89845dcd8080cc91\Microsoft.SQLServer.PipelineHost.dll
//C:\windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SqlServer.ScriptTask\v4.0_12.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.ScriptTask.dll
//C:\windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SqlServer.TxScript\v4.0_12.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.TxScript.dll
//C:\windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SqlServer.VSTAScriptingLib\v4.0_12.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.VSTAScriptingLib.dll
namespace recompApp
{
class Program
{
static void Main(string[] args)
{
string pkgLocation;
Package pkg;
Application app;
//This is the folder where the test package lives!!
pkgLocation =
#"C:\TestPackage.dtsx";
app = new Application();
pkg = app.LoadPackage(pkgLocation, null);
//It's Alive!!!!!!!
try
{
Executables pExecs = pkg.Executables;
foreach (Executable pExec in pExecs)
{
switch (pExec.GetType().Name)
{
case "TaskHost":{
TaskHost taskHost = (TaskHost)pExec;
Console.WriteLine("Executable name = " + taskHost.Name);
//Script Task Outside of a Sequence
if (taskHost.InnerObject.ToString().Equals("Microsoft.SqlServer.Dts.Tasks.ScriptTask.ScriptTask"))
{
ScriptTask task = (ScriptTask)taskHost.InnerObject;
//Load the script project, build and save
task.ScriptingEngine.LoadProjectFromStorage();
task.ScriptingEngine.VstaHelper.Build("");
task.ScriptingEngine.SaveProjectToStorage();
//Cleanup
task.ScriptingEngine.DisposeVstaHelper();
}
break;
}
case "Sequence":{
Executables seqExecs = ((Microsoft.SqlServer.Dts.Runtime.Sequence)(pExec)).Executables;
foreach(Executable seqExec in seqExecs){
switch (seqExec.GetType().Name)
{
case "TaskHost":
{
TaskHost taskHost = (TaskHost)seqExec;
//Script Task inside a Sequence Container
if (taskHost.InnerObject.ToString().Equals("Microsoft.SqlServer.Dts.Tasks.ScriptTask.ScriptTask"))
{
Console.WriteLine("Executable name = " + taskHost.Name);
ScriptTask task = (ScriptTask)taskHost.InnerObject;
//Load the script project, build and save
task.ScriptingEngine.LoadProjectFromStorage();
task.ScriptingEngine.VstaHelper.Build("");
task.ScriptingEngine.SaveProjectToStorage();
//Cleanup
task.ScriptingEngine.DisposeVstaHelper();
}
break;
}
}
}
break;
}
}
}
//Save the updated xml in the package
string xml;
pkg.SaveToXML(out xml, null);
File.WriteAllText(pkgLocation, xml);
}
catch (Exception e)
{
Console.WriteLine(e.Message.ToString());
}
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
}
}
I hope this helps a lots of people outside. I also have the Visual Basic version if you need it.

Problems with de-registering of COM (advanced installer)

Definition of problem:
Hangs up for sometime during COM de-registering and says The setup was unable to automatically close all requested applications. Please ensure that the applications holding files in use are closed before continuing with the installation. But actually my extension is successfully unloaded and uninstalled.
Definition of environment:
I created some kind of dummy shell namespace extension for tests. It implements IContextMenu and all methods returnS_OK and do nothing else and rgs file is
HKCR
{
xxx.sergz.dummyShellExt.1 = s 'DummyNSE Class'
{
CLSID = s '{6C0FBE00-9898-4BB0-806F-3ED7D2F1170D}'
}
xxx.sergz.dummyShellExt = s 'DummyNSE Class'
{
CurVer = s 'xxx.sergz.dummyShellExt.1'
}
NoRemove CLSID
{
ForceRemove {6C0FBE00-9898-4BB0-806F-3ED7D2F1170D} = s 'DummyNSE Class'
{
ProgID = s 'xxx.sergz.dummyShellExt.1'
VersionIndependentProgID = s 'xxx.sergz.dummyShellExt'
ForceRemove Programmable
InprocServer32 = s '%MODULE%'
{
val ThreadingModel = s 'Apartment'
}
TypeLib = s '{3DC947F0-6691-4043-B414-29F749209905}'
Version = s '1.0'
}
}
NoRemove Directory
{
NoRemove Background
{
NoRemove ShellEx
{
NoRemove ContextMenuHandlers
{
ForceRemove DummyShellExt = s '{6C0FBE00-9898-4BB0-806F-3ED7D2F1170D}'
}
}
}
}
}
HKLM
{
NoRemove Software
{
NoRemove Microsoft
{
NoRemove Windows
{
NoRemove CurrentVersion
{
NoRemove Shell Extensions
{
NoRemove Approved
{
val '{6C0FBE00-9898-4BB0-806F-3ED7D2F1170D}' = s 'xxx.sergz Dummy shell extension.'
}
}
}
}
}
}
}
I choose Professional installer and added only my dll file. On file properties Registration tab I choose Auto register file..., Extract registration info... and Synchronization is Enabled. In Product Information->Install Parameters->PackageType I choose 64-bit package for x64....
Now I build the MSI and install the extension.
Launch explorer and do right click somewhere on folder background. According to my log my extension is loaded and is DLL_PROCESS_ATTACH and a few times DLL_THREAD_ATTACH.
I launch the MSI again and choose Remove. It says that you have to close ... applications are using files... and there is only Windows Explorer in the list. I choose Automatically close ... and press OK.
All Explorer windows are closed but it seems that Explorer was not shutdown.
The status is "Shutting down applications", according to my log the dll is already unloaded. The problem is here. The dll is already unloaded but the MSI is still waiting for something and then it says The setup was unable to automatically close all requested applications. Please ensure that the applications holding files in use are closed before continuing with the installation.
I click OK and the process continues and my DLL is successfully removed in the end.
I use windows 8 64bit.
What are the reasons of this waiting and the message that applications can not be closed. How can I figure it out?
Right, this isn't going to work, the shell extension is very likely to be loaded and MSI isn't going to kill Explorer.exe. Nor would you want it to, it is rather a ghastly sight to the user.
You'll need to use an alternative way to un/register the extension. It isn't clear what "Professional installer" might mean. But you can always un/register a COM server by modifying the registry yourself rather than leaving it up to the DLL to do so. It is in fact the recommended way. You already know the registry keys from your .rgs file. You can also use the Heat.exe harvester from the WiX toolset. The DLL needs to be removed by delay-deleting it at the next user login, done by adding it to the PendingFileRenameOperations registry key. Check your installer creator tool for the proper procedure.