cognos79
asked on
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
Thanks,
sandeep
ASKER
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.Configur ation")
Set Fields = objConfig.Fields
' Set config fields we care about
With Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = ServerName
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPConnectionTim eout) = 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.co m"
.Subject = "testing"
.TextBody = "this is test version"
'.AddAttachment filepath
.Send
End With
Set Fields = Nothing
Set objMessage = Nothing
Set objConfig = Nothing
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.Configur
Set Fields = objConfig.Fields
' Set config fields we care about
With Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = ServerName
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPConnectionTim
.Item(cdoSMTPAuthenticate)
.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.co
.Subject = "testing"
.TextBody = "this is test version"
'.AddAttachment filepath
.Send
End With
Set Fields = Nothing
Set objMessage = Nothing
Set objConfig = Nothing
ASKER
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.
But on the server i dont see the vb form popping up to close it.
ASKER
do i have to use a kill statement in the program.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
cool. it worked. you rock.
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.