[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 196
  • Last Modified:

run a vb application as a service

I created an .exe file using a vb program. can anyone tell how to schedule this as a service. I am using windows server 2003 R2. I want this vb program to run once a day. Is there any other way to do this other than scheduling this a service.


  • 4
  • 2
1 Solution
I don't think you need to run it as a service.
Windows Task scheduler can run a program without it being a service, providing your program requires no user inputs.
You can find it in Control Panel - scheduled tasks.
You can schedule daily, selected days of week, and even repeat every xx miutes / hours etc.

If the program needs no network access, it is probably OK to run under system account (the default). If network access required, you will need to supply details of a user account.

If you really want to run as a service (a program that remains running) you could use AlwaysUp (shareware) - see
I have used this for software that is not a service, and must re-start reliably after an unattended re-boot.

cognos79Author Commented:
hey dcp002,

    i used windows task scheduler. I dont think its working correctly for me. I have an .exe program which sends out email. its a simple program. I scheduled it to send email every 2 mins. this is just for testing purpose. But its not sending email as intended. It only sends out email once at the scheduled time and  after every 2 mins it should send email again. its not doing that. do you have any ideas.

when i just click the .exe it sending out email. I am also pasting here the code i used.

 Const cdoSendUsingMethod = _
    Const cdoSendUsingPort = 2
    Const cdoSMTPServer = _
    Const cdoSMTPServerPort = _
    Const cdoSMTPConnectionTimeout = _
    Const cdoSMTPAuthenticate = _
    Const cdoBasic = 1
    Const cdoSendUserName = _
    Const cdoSendPassword = _
    Dim objConfig  ' As CDO.Configuration
    Dim objMessage ' As CDO.Message
    Dim Fields     ' As ADODB.Fields
    ' Get a handle on the config object and it's fields
    Set objConfig = CreateObject("CDO.Configuration")
    Set Fields = objConfig.Fields
    ' Set config fields we care about
    With Fields
        .Item(cdoSendUsingMethod) = cdoSendUsingPort
        .Item(cdoSMTPServer) = ServerName
        .Item(cdoSMTPServerPort) = 25
        .Item(cdoSMTPConnectionTimeout) = 10
        .Item(cdoSMTPAuthenticate) = cdoBasic
        .Item(cdoSendUserName) = UserName
        .Item(cdoSendPassword) = Password    
    End With
    Dim filepath
    filepath = "E:/WebFiles/" & FileName
    Set objMessage = CreateObject("CDO.Message")
    Set objMessage.Configuration = objConfig
    With objMessage
        .To = "sandeep_saladi@yahoo.com"
        .From = "newbus@editmycreditnow.com"
        .Subject = "testing"
        .TextBody = "this is test version"
        '.AddAttachment filepath
    End With
    Set Fields = Nothing
    Set objMessage = Nothing
    Set objConfig = Nothing
cognos79Author Commented:
one thing i noticed is when i schedule the job on my local computer its working only if i close the application after it runs. when it runs the .exe file its opening up the vb form and i have to close it. then only its running the job after 2 minutes. if i dont close it its not running again.

But on the server i dont see the vb form popping up to close it.

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

cognos79Author Commented:
do i have to use a kill statement in the program.
You simply need to put an "END" statement at the end of the program so it closes once it has done its job.
cognos79Author Commented:
cool. it worked. you rock.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now