Creating installer for a c++ windows service Dynamically - c++

I have created a windows service which checks for the status of the printer.
The user can download this service from a website. I need to query for the status of printers used by this user. So when the user clicks on the download button I want to store the user information in a file which my service can use. The service will use this information to fetch the printers from the database. I want to include this file in my installer. So I have to create the installer at runtime(i.e. when the user click the download button on my website).
How can I create the installer for the win service dynamically using C#?
NOTE: my win service is written in C++. I know about WIX.

quite a few years ago, when I did some work with InstallShield, it was possible to specify in the installer project which file(s) you don't want to be compressed and packed into the .cab files (or whatever they are called nowadays) when generating the installation package. Such a file would be left as-is and separate in the package, and you could later replace it with another file with the same name (I think I actually did something of the sort). So you can have a dummy file when building the install package, and then replace it on the fly with the right one.
I am not familiar with modern tools, but am quite sure this functionality is preserved as it is quite useful.

In WiX you can create custom actions which are arbitrary code you write (You provide the .dll which can be built using C++). In the custom action you can generate your user/location customization file.

Related

How to add layer on top of file system? Like cache in OneDrive or Google Drive

I'm looking for a way (using C# .Net or C++ and WinApi or anything) to add a layer between filesystem and client application to add custom behaviour.
Like OneDrive and Google drive application on Windows. You can browse files normally but if given file is missing from a drive it will be downloaded. I need to do something similar. And I need this solution to be transparent to other software (explorer and any other software that accesses files on drive).
I really even know what to call it. So if you have a name for that type of functionality please let me know.
Here are some approaches to building a virtual file system on Windows:
Using Cloud Files API. OneDrive is built using this API. It is designed for slow-speed remote (cloud) storage, such as Document Management System. Here are some features that it provides:
On-demand loading. You can load the file content into the local drive only when an application is accessing it the first time. The folder listing can be done during the first access to the folder.
Offline files support. You can pin/unpin files to keep on the local drive when the server is unavailable.
Download/upload progress reporting.
Integration with Windows File Manager. Each item shows offline status, pinned/unpinned status, in-sync status, and download progress.
Messages and error notifications to the user, as well as file system status reporting.
The driver that this API is using is installed with Windows by default and does not require installation. Here are some tools to build an OneDrive-like application:
CloudMirror sample in C++ from Microsoft. Code on GitHub.
User File System from IT Hit provides example in .NET. Code on GitHub.
Using Projected File System (ProjFS). It allows you to represent (project) some hierarchical technical data as a file system. It is designed for high-speed back-end storage, such as for example registry. Here is its major feature:
Hides the fact that the data is remote. The user "thinks" that the files are in the local file system and does not have any status information. The user does not know if the file content is available/unavailable or online/offline.
ProjFS is not installed by default and requires Windows component installation (thank you IInspectable for this info). Here are some tools to build with it:
Programming guide. Sample: Virtual File System for Git.
Using Shell Namespace Extensions. Typically used to create a UI extension for Windows File Manager. For example, Windows Recycle Bin and Printers are namespace extensions. They are not available via standard Windows File API and applications can not read/write to it unless it redirects to a real file system behind it. Here some features that it provides:
You can customize the Windows File Manager toolbar, shortcut menus, folder view, tree view, and status bar.
You can extend the Windows File Manager hierarchy, adding new custom nodes that look and behave like files and folders (cut/copy/paste, drag-and-drop, etc), without building a functional file system behind it.
Shell Namespace Extensions are part of Windows and does not require additional components installation. In many cases, you will use Shell Extension to add shortcut menus and items on a toolbar in Windows File Manager while building the actual file system using Cloud Files API or ProjFS. Links to start working with Shell Namespace Extensions:
Understanding Shell Namespace Extensions
Extending Shortcut Menus
What you are looking for is commonly called a "Virtual File System". To applications it looks like a file system, but the implementation is at your discretion, allowing you to materialize objects in any way you see fit.
On Windows you have several options to implement a virtual file system. The most common and widely supported infrastructure is the Shell Namespace. It allows you to register extensions, that appear as items (e.g. files or folders) in the file system. It's not entirely trivial to write a Shell Namespace Extensions, but it's not rocket science either.
A more recent addition to Windows is the Projected File System, that provides everything you need to build a virtual file system in user code. It ships as an optional component in Windows, and needs to be explicitly installed first. For an implementation that uses the ProjFS, see the VFS for Git github repository.

How do I create a TFS2017 Build Task equivalent to Visual Studio's Web Deploy Publish method?

I am trying to complete Continuous Integration/Continuous Deployment automation for a web application project. I have been helped by a series of SO posts link1, link2, link3 and things are now running, except the upload to the hosting server is longer than it needs to be; I currently upload all files instead of just the ones that changed.
When creating the TFS2017 Build (or Release) there are many Task options, including some from the marketplace. I'm referring to, in this case, the dialogue for a Build as shown below:
I'm currently using a PowerShell script which seems a little archaic and inefficient as noted above. Do any of the tasks available to us mimic the Visual Studio 2017 Web Deploy Publish Method which runs quite nicely and quickly? If not, what can I use for an 'intelligent' upload process that checks whether or not a file must be uploaded?
Unfortunately, there is no this kind of build task could mimic the Visual Studio 2017 Web Deploy Publish Method for now.
The method trough VS IDE will dynamically check if some files need to be uploaded or not.
However through TFS build task or powershell script will not do this, just simply copy all files you assigned. Afraid there is no workaround for an 'intelligent' upload process that checks whether or not a file must be uploaded. Since we don't how VS IDE did this.

Windows Store deployment file from folder instead of MSI

I want to ask you a couple of questions i looked in internet and didn't found an answer though...
I have an application for windows 10 PCx64 (artifacts of a built project C++/x64)
Is it possible to create odrinary Windows Store deployment file from folder?
How to do that? As i see MS is pushing new 'universal applciations' concept. But i don't want to rewrite apps entirely to .net/c#/Universal Apps. I just want to change build process so it will produce windows store deployment file, not MSI
Thanks!
You will soon be able to create a Windows Store package for a Win32 app and deploy it through the Windows Store. You'll even get access to UWP APIs and services :)
Subscribe to the "Windows Developer Preview Programs" to get some fresh news about "Project Centennial".
https://devpreviewsignup.windows.com/

(How) can I select a Windows Store app with a file browser?

I'm working on an introspection utility which eventually asks the user to specify the executable to use for launching the application. Now I'd like to add support for so-called "Windows Store apps" (formerly known as "Metro" apps, I believe). However, it's not clear to me how they are stored locally.
I read about how Windows Store apps are packaged and deployed, and apparently it's common to distribute them as .appx files, generated by tools like makeappx. However, I don't see if/where they are stored locally.
Does it make sense to address them like ordinary executables at all, i.e. via a file name? Or is there rather a more appropriate method? I noticed that in the registry, some (all?) of the Windows Store apps I have installed are listed beneath
HKCU\Software\Classes\ActivatableClasses\Package
Is there some API available for handling this registry tree, to do stuff like "Get me the user-visible name" or "Get me the AppUserModelId so that I can launch the app"?

How to run my own C++ source files in the installation wizard?

I have created a windows install deployment for my C++ application using VS2010. However my problem is that I don't know how can I squeeze in some of my own code to the installation wizard (and is it possible at all?). The problem is that during installation I want:
ask the user to provide his installation key,
grab the hardware fingerprint (I already have an algorithm for that with WMI),
sent both keys using my own c++ communication libraries (so NOT the browser),
continue the installation after receiving a confirmation from the server.
Moreover, this would require adding custom items to the installation wizard like the input field for installation key, or pop up boxes witch error warring like:
Couldn't connect to the server. Please check your internet connection before continuing with the installation.
So it's in fact a 2 level question:
How to run my C++ source files during the installation wizard?
How to add custom element to the installation wizard GUI?
So far it has been hard to find anything helpful in Google. :/
Check Windows Installer, more specifically Custom Actions:
The developer of an installer package may write code to serve their own purpose, delivered in a DLL. This can be executed during the installation sequences, including when the user clicks a button in the user interface, or during the InstallExecuteSequence. Custom Actions typically validate product license keys, or initialise more complex services. Developers should normally provide inverse custom actions for use during uninstallation.
Msiexec provides a way to break after loading a specified custom action DLL but before invoking the action.