Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Window Services Stopped

 
Logged in as: Guest
arrSession:exec spGetSession 2,7,63108
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [General Forum] >> Other Programming/Scripting Languages >> Window Services Stopped
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Window Services Stopped - 8/4/2008 5:01:52 PM   
  gray d newbie

 

Posts: 22
Score: 0
Joined: 7/29/2008
Status: offline
Greetings All,

This is my first time creating a Window Service and I am having this error message when I try to start my window service (currently known as Service1). Below is my code for Window Service and also the line which I suspected is the caused of the problem.

Protected Overrides Sub OnStart(ByVal args() As String)
Dim i As Integer
i = Shell("\\202.186.196.128\c$\Inetpub\wwwroot\WebAdmin\Rewards\print.exe", vbNormalFocus)

Dim fs As FileStream = New FileStream("c:\temp\mcWindowsService.txt", FileMode.OpenOrCreate, FileAccess.Write)
Dim m_streamWriter As StreamWriter = New StreamWriter(fs)
m_streamWriter.BaseStream.Seek(0, SeekOrigin.End)
m_streamWriter.WriteLine("BLPrinting Service: Service Started at " & Date.Now & Constants.vbLf)
m_streamWriter.Flush()
m_streamWriter.Close()
End Sub

Protected Overrides Sub OnStop()
Dim fs As FileStream = New FileStream("c:\temp\mcWindowsService.txt", FileMode.OpenOrCreate, FileAccess.Write)
Dim m_streamWriter As StreamWriter = New StreamWriter(fs)
m_streamWriter.BaseStream.Seek(0, SeekOrigin.End)
m_streamWriter.WriteLine("BLPrinting Service: Service Stopped at " & Date.Now & Constants.vbLf)
m_streamWriter.Flush()
m_streamWriter.Close()
End Sub

Above are the START and STOP functions for my Window Service, which I got it from some online tutorial. Since my window service is intended to call an EXE from a specific folder, hence I added in the 2 new lines, which I bolded. When I try to start my service again, it pops me this message:

The Service1 service on Local Computer started and then stopped. Some services stop automatically if they have no work to do, for example, the Performance Logs and Alerts service.

For your information, my window service was working fine before I added in the 2 new lines of code. Maybe they way I'm supposed to call an EXE is incorrect. Please correct me if I'm wrong.

Thank you very much.

Best Regards
Gray d' Newbie
 
 
Post #: 1
 
 RE: Window Services Stopped - 8/4/2008 6:15:06 PM   
  ginolard


Posts: 1062
Score: 21
Joined: 8/10/2005
Status: offline
That's VB.NET, this is a VBSCRIPT forum.  I suggest you try http://www.vbforums.com

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to gray d newbie)
 
 
Post #: 2
 
 RE: Window Services Stopped - 8/4/2008 6:24:33 PM   
  gray d newbie

 

Posts: 22
Score: 0
Joined: 7/29/2008
Status: offline
Thank you very much and sorry for the trouble caused

(in reply to ginolard)
 
 
Post #: 3
 
 RE: Window Services Stopped - 8/4/2008 7:59:38 PM   
  ginolard


Posts: 1062
Score: 21
Joined: 8/10/2005
Status: offline
I wouldn't use Shell to launch a remote exe.  Take a look at the Process Class instead.

_____________________________

Author of ManagePC - http://managepc.net
AD Query Template - http://www.visualbasicscript.com/m_40609/tm.htm
Consolidated Scripting Framework - http://www.visualbasicscript.com/m_59109/tm.htm

(in reply to gray d newbie)
 
 
Post #: 4
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [General Forum] >> Other Programming/Scripting Languages >> Window Services Stopped Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts