1

I am making a simple program that:

  1. Automatically Runs on Startup (Invisibly)
  2. Finishes task within 5-10 seconds (Invisibly)
  3. Exits

I am a beginner and have one challenge here. There are two programs. One which user can open to change settings (Windows Forms) and another that runs on startup, finishes task & exit. How can I make two programs in a single project?

Also, where to save configuration so that both the programs can read/write it?

Thanks for help in advance.

Update: The program is basically to clean the desktop on startup. Please check attached design of my software as well for better idea.

Software Interface

1 Answer 1

2

There are two answers:

  1. You can make a program that reads the arguments in the Main method to decide in which mode it should run. If run without arguments (such as when double clicked), it presents the user interface, and if run with some specific argument, like say /run, it does not present the user interface and instead performs the task you want. You don't specify how you get the task to happen at startup, but it will have to run this program with that argument (/run).

  2. The easier way to do this is to just make a new project for the program performing the task - that also lets you start and debug the task directly in Visual Studio.

If you're making a conventional Windows application, you're free to save the settings wherever you'd like. Saving them under a subfolder of the AppData folder in the user's home folder/"profile" is the recommended way. You can use Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) to get the path to the AppData folder and then make your own folder and files within it.

You can also use the registry.

Sign up to request clarification or add additional context in comments.

7 Comments

Thanks for your response. I completely understood First answer. Can you please guide me how to call program with arguments? It will be called using a file placed in startup folder.
If you're using the Startup folder, you can make a shortcut to the program - a shortcut can send arguments by providing them after the path to the program in the Target field (TargetPath in the question linked).
I tested passing arguments in Location Field of the shortcut I placed in startup folder. It worked well. Thanks a lot for your help.
You're welcome. If you want the task to run on a schedule instead of only when the user logs in (which could be months until the next time), you can create a Scheduled Task instead.
That's a great idea. I can program to clean desktop when the computer is idle for sometime.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.