VB.NET | Convert EXE to Service

I have a vb.net exe program that stays minimized all day and moves files every 15 minutes. Would it be more efficient converting it to a Windows Service, and if so, how do I go about it? It is currently a Windows Form that uses the Timer fuction in Visual Studio.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

The easiest way is to start a new project using the Windows Service template, and then cut and paste your exe project into it or vice versa. What I then do is to copy the application from C:\Windows\Microsoft.NET\Framework\v1.1.4322 (?) \InstallUtil.exe to my \bin folder and use run InstallUtil myapp.exe. I do this through another application which includes the following code:-

Dim Prcs() as Process = Process.GetProcessesByName("mylog")
if UBound(Prcs) < 0 then
 Dim prc as new Process
 prc.StartInfo.FileName = MyPath & "\InstallUtil.Exe"
 prc.StartInfo.Arguments = "myapp.exe"
 prc.Start ()
End if
Dim myControl as New System.ServiceProcess.ServiceController("mylog")
 If myControl.Status = ServiceProcess.ServiceControllerStatus.Stopped then mtControl.Start()

To start or stop the timer, you need to use OnCustomCommand(Byval command as integer)
where command is an integer number. I've tried 1 and 2 and these don't work. 201 and 202 etc do, but I haven't worked out the limits.
Then do
Select Case Command
Case 201: timer.stop

so going back to your code in the vb app, add the following to stop your timer.

That done, I haven't been able to get my service to write an entry to a file.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
potpourrigroup / broadbent,

You may also need to set the service to "interact with the desktop", by going to its properties under SERVICES, and going to the "Log On" tab.

potpourrigroupAuthor Commented:
I have Visual Studio Express and I don't see the Windows Service template. Can I download it or do I need the "real" version of studio? This is a company project so purchasing VS wouldn't be OK if I really need it. I'm sure I could do a lot more with the full version anyway.
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

potpourrigroupAuthor Commented:
Oops... Meant it WOULD be OK.
And I can't find how to "interact with the desktop"
I have VS 2003, and 2005 Express
As I meantioned above, go to SERVICES (control panel>administrative tools), "log On" tab, and it's there
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.