Kazekage Gaara
Kazekage Gaara

Reputation: 15052

Run code only once in entire Windows Forms Application Lifetime

I am working on a Windows Forms Application using Visual Studio 2010 IDE. My need is that I have certain block of code that needs to be run only once, at the starting of the application and never again for the entire lifetime(by lifetime I mean never again on the same system,unless the system is reconfigured). I have placed that code in a separate .cs file and for now, I run it's assembly(.exe) manually for testing purposes. But for deployment purposes, how do I go about it? It contains code for creating scheduled tasks using the schtasks command through command prompt. I know there are workarounds for the same, but I need to stick to the schtasks approach. I know there is something like Setup Projects that help us configure all the files that are required for the installation of our project and also create an installation file in the end, but can I write some code in it to ensure that it runs once, during installation, before my application is executed?

Upvotes: 1

Views: 1206

Answers (1)

Kevin
Kevin

Reputation: 562

Yes you can have a Setup and Deployment package run an exe during installation. You will have to create a Custom Action in the setup to do that.

Upvotes: 5

Related Questions