Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Windows Service to call a vbscript

Status
Not open for further replies.

crwill

Programmer
May 22, 2012
3
0
0
US
I have written to Windows Services that call asp pages. Now I am needing filewatcher service to call a vbscript whenever something changes in a specific folder. The vbscript runs perfectly but I haven't been able to get the Windows Service to run the vbscript. The code for my service is below. Any suggestions would be greatly appreciated.

Imports System.IO

Public Class ConvertExcel

Dim fsw As FileSystemWatcher

Protected Overrides Sub OnStart(ByVal args() As String)
' Add code here to start your service. This method should set things
' in motion so your service can do its work.
fsw = New FileSystemWatcher()

fsw.Path = "C:\Windows\activePDF\DocConverter\Excel"
fsw.Filter = "*.xls"
fsw.IncludeSubdirectories = False
fsw.EnableRaisingEvents = True

AddHandler fsw.Created, New FileSystemEventHandler(AddressOf file_created)

End Sub

Public Sub file_created(ByVal obj As Object, ByVal e As FileSystemEventArgs)
Dim foo As New System.Diagnostics.Process
foo.StartInfo.WorkingDirectory = "C\BatchFiles\"
foo.StartInfo.RedirectStandardOutput = True
foo.StartInfo.FileName = "cmd.exe"
foo.StartInfo.Arguments = "%comspec% /C cscript.exe //Nologo C:\BatchFiles\Upload_Converted_Excel_File.vbs"
foo.StartInfo.UseShellExecute = False
foo.StartInfo.CreateNoWindow = True
foo.Start()
foo.WaitForExit()
foo.Dispose()
End Sub
Protected Overrides Sub OnStop()
' Add code here to perform any tear-down necessary to stop your service.
End Sub

End Class

 
Can you include the complete service code so I can try to trace where the problem is?

---------------------------------------
Bob Beck
Systems Administrator
 
I built the service in MVS 10 and this is all the code that it shows. If there is more I'm not sure where to find it.

I did find the code for the installer:

Imports System.ComponentModel
Imports System.Configuration.Install

Public Class ProjectInstaller

Public Sub New()
MyBase.New()

'This call is required by the Component Designer.
InitializeComponent()

'Add initialization code after the call to InitializeComponent

End Sub

End Class


Let me know what else you need. Thanks for the help.
 
Has anyone had a chance to look at my issue?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top