Programatic launching of application on windows startup - windows

I have a particular piece of software that i wish to load on windows startup. Under normal circumstances i would simply place a shortcut in the startup folder or an entry in the run key in the registry.
Unfortunately and for an unknown reason this application throws a win32 execption whenever that is done - and i am assuming it is because an element of windows has not been loaded that is vital to this application.
Once windows has actually loaded i can double click on the icon and it runs fine. So my question is - is there a programmatic solution to this? I have already tried a console app launcher that sleeps for n seconds and then launches but all that seems to do is delay the startup of windows.
Does anyone have any creative solutions? I am open to anything from a windows service to c#, vb, batch files.. etc
Thx

Can you run it as a service, or write a shell service which will attempt to start it up? That way you will have built in support for response on failure and delay time before trying again.

Have a look at AUTOEXEC.BAT. But be careful!!

Related

How to hide terminal shell on server application like Warp in Windows?

I have a small warp server project on Windows that listen to a particular port and do something whenever I send a command to it by REST (for example: POST http://10.10.10.1:5000/print). It's a small client for printing PDF / receipt directly from another computer.
It works. But my problem is when I had to package the whole project, the Rust compiler give me an executable file (.exe). The application displays a terminal window when I run it. I want this terminal to be hidden somehow.
I try to run the program as a windows service (by using NSSM). It doesn't work for me since I had to access the printer. Windows doesn't allow my app to access any devices or any other executable as a windows service. (The reasons are explained here: How can I run an EXE program from a Windows Service using C#?)
So I plan to run my app as a tray-icon application so user can control or close the app. (https://github.com/olback/tray-item-rs)
Unfortunately, I still cannot hide the app's terminal window.
Another solution that I found is hstart (https://www.ntwind.com/software/hstart.html). But I would like to use this as "the last resort" solution since many antivirus/windows defender mark it as a malware.
Do anyone know how to hide or get rid of it ?
After lot of searching, It turns out to be easier than I thought. Just add
#![windows_subsystem = "windows"]
on top of your main.rs file. (for rust > 1.18) and the terminal is gone.
These control the /SUBSYSTEM flag in the linker. For now, only
"console" and "windows" are supported.
When is this useful? In the simplest terms, if you're developing a
graphical application, and do not specify "windows", a console window
would flash up upon your application's start. With this flag, it
won't.
https://doc.rust-lang.org/reference/runtime.html#the-windows_subsystem-attribute
https://blog.rust-lang.org/2017/06/08/Rust-1.18.html
https://learn.microsoft.com/en-us/cpp/build/reference/subsystem-specify-subsystem?view=msvc-170

Is there a way to trick GUI applications in docker to think their window loaded?

I try to run an windows 10 application inside a windows servercore container.
The app can run without user input via COM-Interface (and without visible GUI), but it seems that it needs to load a hidden window in the background. When I start it on docker, the application log file indicates that it's stuck on starting this window.
Is there a way to make the app assume it successfully loaded the window?
All information I found so far was about users who want to see the GUI or about Linux/Windows combinations. None of that helped me.

Why don't some programs appear on the task manager startup tab?

Many applications start at startup, however, some of them do not appear on the task manager startup tab. What is that due to?
Is there any way to do this with a program, for example, spotify?
What do I need to do in order for a program to start at startup, but not showing in the startup applications tab?
Setting it in HKCU/Microsoft/Windows/CurrentVersion/Run doesn't seem to work, as it starts, but still shows on the mentioned tab.
Thank you in advance.
Its mostly a factor of how the program itself is written. If its written to run as a service, or as a System Tray application, or otherwise.
I know there are wrappers for running any exe as a service NSSM being the main one I have experience with (but this is mostly for when there is going to be NO user interaction)
I do not know if there is anything that can allow an application to run in the system tray only, not in the taskbar, if it doesn't support it.
But since Spotify does support running minimized to the tray, it does seem like there are some ways to "start spotify minimized", Spotify or other applications might have command line options or other settings to tell them to start "hidden"

Word COM in scheduled task on Windows Server

I have an application that uses COM to automate Word. It needs to run even when a user is not logged in. I achieved this on Windows 7 by making it run as a scheduled task which runs at startup and doesn't require a user to be logged on. I also had to use the 'hack' where you add a 'Desktop' folder in 'C:/Windows/SysWow64/config/systemprofile'.
I tried this same method in Windows Server 2012, but it doesn't work. I can see in the task scheduler that the application is starting an instance of Word. However, it then appears to 'hang' and nothing happens. I think perhaps the invisible instance of Word is showing an error message which causes the whole thing to hang, as I cannot dismiss the message.
Has anyone else had trouble getting COM to work on windows server? Is there any way of showing hidden instances of Word to see if an error dialog is showing? Or any other way of diagnosing what the problem is?
I know ideally we would have an app that created the word documents without using COM, but this is not an option at the moment.
Does your app work when run as a logged-in user?
In the past I've run into what sound like similar problems, when running programs that try to use COM interfaces; some tasks work, but others simply don't function unless run as a logged-in user with an interactive desktop.
For me the simplest solution was to set up the machine to log in as a user at boot (which you can set up in the control panel - or I think there might also be a sysinternals tool that supports configuring that nowadays), then make sure that task scheduler/Jenkins/whatever you use launches the app as the logged-in user.

MSMQ Trigger opens executable as background process

I'm using a Microsoft Message Queuing (MSMQ) Trigger to launch a standalone executable on Windows 8.1. The exe was not launching so I tried opening Notepad instead (thanks John). That did not work either so I peaked at the Task Manager and noticed that it was opening as a Background Process.
My question is: why does the application open as a background process and how do I prevent this?
Is it possible to add a launch Parameter, for example?
Edit
I should note that I'm okay with the exe running in the background once my application goes live. I would like to prevent it from doing so during development, however.

Resources