How to auto-start my own .NET app when Windows starts?

Page 3 of 5 FirstFirst 12345 LastLast

  1. Posts : 35,546
    Win 10 Pro (21H2) (2nd PC is 21H2)
       #21

    As an experiment just to see if it launches, try putting this line
    in as your scheduled task:
    cmd.exe /C "C:\HA\Homeautomation.Manager.exe"

    Does the program have to be run with admin rights?
      My Computers


  2. Posts : 5,209
    21H1 64 Bit Home
       #22

    yesyes said:
    I have also tried the "Register this program for restart" checkbox under Properties - Compatibility. With this enabled the app now seems to auto-start but it closes again after a second or two.
    Undo then try scheduled task again.
      My Computer


  3. Posts : 14
    Windows 10 Pro [Version 10.0.19041.329]
    Thread Starter
       #23

    Matthew Wai said:
    Run the following via an elevated Command Prompt:

    sfc /scannow
    this doesn't find anything wrong.

    Code:
    C:\Windows\system32>sfc /scannow
    
    Beginning system scan.  This process will take some time.
    
    Beginning verification phase of system scan.
    Verification 100% complete.
    
    Windows Resource Protection did not find any integrity violations.
    
    C:\Windows\system32>
    I'll try the rest tomorrow. The wife insists this is not a Friday evening activity. ;-)
    Thanks all for your help so far. Much appreciated!

    - - - Updated - - -

    One more thing to add...
    Looking at my application logs I noticed that, when the app starts briefly, it doesn't always crash at the same time after start. It seems to get to different points in the program before it crashes. I get a different number of log lines each time.

    It's almost as if something is killing it just after it starts but takes different amounts of time to detect it.
      My Computer


  4. Posts : 5,209
    21H1 64 Bit Home
       #24

    Just a guess:

    Download Visual C++ Runtime Installer (All-In-One) - MajorGeeks

    What does this app do? Is it something that you could upload for testing?
      My Computer


  5. Posts : 14
    Windows 10 Pro [Version 10.0.19041.329]
    Thread Starter
       #25

    The plot thickens....
    It just occurred to me to test with another app. There is a small helper app that is a separate executable in the same project. It's also C# .NET 4.5.2 and WinForms but uses no additional libraries.

    Long story short this one starts fine when I copy a shortcut to
    C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp

    So it seems this an issue with my main application somehow. But why, then, does it run absolutely fine when I start it manually? What is the difference?

    - - - Updated - - -

    If that was missing, it wouldn't run when I start it manually. I don't think is some missing components...

    Callender said:
    What does this app do? Is it something that you could upload for testing?
    It's quite a big and complex project that I've been working on for 9 years now. It is the back-end "server" of my own home automation system. It uses several own DLLs and 2 3rd party libraries (SQLite and Open_ZWave). I'll check what the smallest set of files is so that the app is still working.
      My Computer


  6. Posts : 35,546
    Win 10 Pro (21H2) (2nd PC is 21H2)
       #26
      My Computers


  7. Posts : 14
    Windows 10 Pro [Version 10.0.19041.329]
    Thread Starter
       #27

    dalchina said:
    OK, installed and tried to run the app from within the debugger. Not sure what I'm doing here. Will have to read up about it. ;-)
    It did help to find an unrelated (I think) bug where I used relative paths to load some files. When running the app from command prompt / power shell / task scheduler the default path of the app isn't its actual location. Changed to full paths. Still won't auto-start though.
      My Computer


  8. Posts : 16,159
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
       #28

    Callender said:
    What does this app do? Is it something that you could upload for testing?
    Good idea!
      My Computer


  9. Posts : 14
    Windows 10 Pro [Version 10.0.19041.329]
    Thread Starter
       #29

    Callender said:
    What does this app do? Is it something that you could upload for testing?
    OK, I've made a minimal version that should run fine. The executable is exactly the same, but I removed most of the "plug-in" DLLs and created a minimal config.
    It's in the attached zip file.
    How to auto-start my own .NET app when Windows starts? Attached Files
      My Computer


  10. Posts : 35,546
    Win 10 Pro (21H2) (2nd PC is 21H2)
       #30

    Have you tried my post #21? It launches from the command line, so.. (no idea what the underlying problem is though!)
      My Computers


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 00:34.
Find Us




Windows 10 Forums