15599

C# application not running on startup

Question:

I can't for the life of me figure this one out. I have created a fairly large C# application that basically runs a bunch of separate components and reboots the machine periodically. The idea of this application is basically to automate a process that we have at my company. So I had it working previously so that after the machine reboots it launches after an account is logged into.

Anyways the app no longer will launch on startup. Please see the code below which I have implemented to add an entry to the <strong>Run</strong> key in the registry:

RegistryKey winStartUpKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run"); string shieldStartVal = (string)winStartUpKey.GetValue("SHIELDCustomizer"); if (shieldStartVal == null) { string currentName = System.AppDomain.CurrentDomain.FriendlyName; string currentDIR = Directory.GetCurrentDirectory() + @"\" + currentName; RegistryKey startUpKey = Registry.LocalMachine.OpenSubKey (@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", RegistryKeyPermissionCheck.ReadWriteSubTree); startUpKey.SetValue("SHIELDCustomizer", "\"" + currentDIR + "\"", RegistryValueKind.String); }

The above code has worked in the past. And I have verified that the startup entry is in-fact added to the registry. When I copy the path in the registry into a run prompt and click OK, the app starts without an issue.

I have made some small changes to the code (rather lengthy code, not sure where to begin posting this code) that I can't imagine having an impact on whether or not the app launches on startup. All of my images and files have been added as a resource to the project. The only reference I could really find that outlined this similar scenario is on this forum here: <a href="https://stackoverflow.com/questions/15137300/application-wont-start-on-startup-after-adding-a-notifyicon" rel="nofollow">application won't start on startup after adding a notifyicon</a> which actually doesn't look like it pertains to my current setup because my notifyIcon object and properties have been added using Visual Studio and I have not coded it manually.

Does anyone have any idea as to what might be causing a program to not launch at startup when the correct entry is in the registry? I know I haven't provided much code, please let me know if there is any additional information I can provide and I will be happy to do so.

Thank you so much in advance!

Answer1:

Startup Tasks can be disabled using Task Manager in Windows 8.1 or msconfig in Windows 7. For example, I have disabled Box Sync from running at startup on my machine:

<img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/9OUxH.png" data-original="https://i.stack.imgur.com/9OUxH.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" />

Enabling/Disabling though task manager sets a registry key at

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\Run

or

HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\Run

If the value starts with 02 00 00 then it is enabled. If it starts with another value (like 03 00 in my example) then it is disabled:

<img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/ZOSGI.png" data-original="https://i.stack.imgur.com/ZOSGI.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" />

Recommend

  • Build failed in TFS
  • To check installed software using a program
  • Failed to connect to server. Error: 0x8007000E
  • How to save Windows theme part using GetThemeStream? (other than DWMWINDOW)
  • jquery ui datepicker error on beforeShowDay
  • How to toggle “Use automatic configuration script”
  • FSC: Error FS2024: Static linking may not use assembly that targets different profile
  • lodash _.get function in typescript
  • How can I use 'addChildEventListener()' accurately for following purpose?
  • JavaFX TableView click sorters not working?
  • Get current day's steps during datapointListener google Fit
  • How to prevent TreeItem selection?
  • Reading a file into a multidimensional array
  • how to upload multiple files in c# windows application
  • how to find common suffix in java by using method
  • App restarts from wrong activity
  • How to convert workspace coordinates to screen coordinates?
  • How to add git credentials to the build so it would be able to be used within a shell code?
  • How to define custom class, title, and target in Link Browser for content elements and the new rte_c
  • MVC3 Razor - ListBox pre-select not working
  • How to install a .deb file on a jailbroken iphone programmatically?
  • How to delay loading a property with linq to sql external mapping?
  • Recording logins for password protected directories
  • SignalR .NET Client Invoke throws an exception
  • Lost migrations and Azure database is now out of sync
  • Java Scanner input dilemma. Automatically inputs without allowing user to type
  • How do I fake an specific browser client when using Java's Net library?
  • Sony Xperia Z Tablet not found by adb
  • How to get a value (ex: baseURL) in every Karate feature?
  • Validaiting emails with Net.Mail MailAddress
  • sending/ receiving email in Java
  • How to set my toolbar fixed while scrolling android
  • Timeout for blocking function call, i.e., how to stop waiting for user input after X seconds?
  • AT Commands to Send SMS not working in Windows 8.1
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Proper folder structure for lots of source files
  • How do I configure my settings file to work with unit tests?
  • How does Linux kernel interrupt the application?
  • apache spark aggregate function using min value
  • Sorting a 2D array using the second column C++