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

x
  • 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.

Thanks,
sandeep



0
cognos79
Asked:
cognos79
  • 4
  • 2
1 Solution
 
dcp002Commented:
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
http://www.coretechnologies.com/products/AlwaysUp/
I have used this for software that is not a service, and must re-start reliably after an unattended re-boot.

0
 
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 = _
        "http://schemas.microsoft.com/cdo/configuration/sendusing"
    Const cdoSendUsingPort = 2
    Const cdoSMTPServer = _
        "http://schemas.microsoft.com/cdo/configuration/smtpserver"
    Const cdoSMTPServerPort = _
        "http://schemas.microsoft.com/cdo/configuration/smtpserverport"
    Const cdoSMTPConnectionTimeout = _
        "http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"
    Const cdoSMTPAuthenticate = _
        "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"
    Const cdoBasic = 1
    Const cdoSendUserName = _
        "http://schemas.microsoft.com/cdo/configuration/sendusername"
    Const cdoSendPassword = _
        "http://schemas.microsoft.com/cdo/configuration/sendpassword"
   
    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    
        .Update
    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
               
        .Send
    End With
   
    Set Fields = Nothing
    Set objMessage = Nothing
    Set objConfig = Nothing
0
 
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.

0
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.
0
 
dcp002Commented:
You simply need to put an "END" statement at the end of the program so it closes once it has done its job.
0
 
cognos79Author Commented:
cool. it worked. you rock.
0

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