result = ShellExecuteW(
NULL, // hwnd
L"runas", // "runas" to run as administrator
cmd, // executable to run
parameters, // command-line parameters
NULL, // default directory
SW_HIDE // show the window
);
Request you to share if there are any concerns or recommended precautions while using a non-signed INF for this purpose.
Why don't you just write a simple application to do this? You're already elevated. Also, it's incredibly bad practice to embed full pathnames in an INF. Someday, you'll want to run that on a different computer.
Yes, we have tested a simple application that performs operations like DeleteFolder, DeleteFile, CreateDirectory, and CopyFile. However, we observed the following issues even when running the application with elevated privileges:
Some application files (especially .dll files) could not be deleted or overwritten.
We ensured the file attributes were set to normal and explicitly removed the ReadOnly attribute, yet deletion and replacement failed.
We attempted to mark the files for deletion on reboot, but this naturally requires a system restart.
Additionally, we have .sys files (mini-filter drivers) that are loaded into kernel space. Since they are in use by the system, deleting or updating them while running is not possible.
The INF-based approach has proven reliable in this scenario, as it supports:
File renaming
Copying in-use files
Deferred operations requiring restart
This is well-documented under the [INF CopyFiles Directive]
Although we may consider transitioning to an MSI-based (WiX) deployment in the future, the current deployment model is based on INF, and we plan to continue with it for the time being due to its compatibility with our installation scenarios.
Please share if we missed anything. Also, we are going to create the full path at runtime dynamically. I have just shared an example.
Request you to share your suggestions. Thank you very much for your help.