Running perl script from a VB.NET windows service

 
Thread Tools Search this Thread
Special Forums Windows & DOS: Issues & Discussions Running perl script from a VB.NET windows service
# 1  
Old 10-08-2010
Running perl script from a VB.NET windows service

Here is the snippet of the code that I'm trying to execute.

Stat of the service does not launch perl script. OnStop works fine. Please could you help here.

Public Class Service1

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.
If Not Diagnostics.EventLog.SourceExists("vbMgr") Then
Diagnostics.EventLog.CreateEventSource("vbMgr", "Application")
End If
EventLog.Source = "vbMgr"
EventLog.WriteEntry("vbMgr service starting")


Dim oShell = CreateObject("WScript.Shell")
oShell.Run("cmd.exe /K perl c:\runtm.pl")
oShell = Nothing
'Shell("cmd.exe /K perl c:\runtm.pl ", AppWinStyle.MaximizedFocus)

End Sub

Protected Overrides Sub OnStop()
' Add code here to perform any tear-down necessary to stop your service.
If Not Diagnostics.EventLog.SourceExists("vbMgr") Then
Diagnostics.EventLog.CreateEventSource("vbMgr", "Application")
End If
EventLog.Source = "vbMgr"
EventLog.WriteEntry("vbMgr service stopped")

Dim oShell = CreateObject("WScript.Shell")
oShell.Run("cmd.exe /K echo > c:\\test.log")
oShell = Nothing

End Sub

End Class


Thanks,
Hansini
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Checking to see if windows service is running

Hi I have created a PowerShell script which successfully checks whether windows service pgsql-9.2 is running. I have tried to call that PowerShell script with a shell/bash script within a LINUX machine but have been unsuccessful. Is there a way of a shell/Perl script to check whether a... (5 Replies)
Discussion started by: simpsa27
5 Replies

2. Solaris

Cannot get sma (net-snmp) service to start.

Hey everyone, so I recently installed sma and disabled snmpdx for system monitoring in Solarwinds on 7 Oracle servers running Solaris 10. It was running just fine until we had to shutdown all systems and power back up (hurricane). Since then I cannot get the sma service to start, it goes into... (4 Replies)
Discussion started by: Zeus18
4 Replies

3. Shell Programming and Scripting

Running Linux Script from Windows

forgive me if i am posting this question in wrong forum. I have a rsync script that runs on one server for rsync with another server (both linux) . Now I want to get control of that script from my windows 7 machine. Means I want to run that script from my windows machine whenever i want... (1 Reply)
Discussion started by: HarryReid
1 Replies

4. Shell Programming and Scripting

Unable to get the size of remote file using Net::FTP Perl Script

Hi, I am using below piece of code to get the size of the remote file. $ftp->cwd($destination) or $error=$ftp->message; if(!$error) { $ftp->put($file) or $error=$ftp->message; print "FTP size = \n"; ... (3 Replies)
Discussion started by: FarooqOnline
3 Replies

5. Solaris

Running unix script from windows.

Hi All, I need to call a unix script from windows bat file, please help if that can be done. I cant install cygwin or putty or any other ssh on server.....! do we have anything else? (8 Replies)
Discussion started by: fidelis
8 Replies

6. Shell Programming and Scripting

checking to see if a service is running in a shell script

How can I tell, in a shell script, if a certain service is running? I know how to do this on the command line, but not in a script. Is an error thrown somehow that I can check? Thanks. (6 Replies)
Discussion started by: daflore
6 Replies

7. UNIX for Dummies Questions & Answers

Need help configuring Active Perl on Windows Vista.: Perl Scripting on Windows

Hi All, Need help configuring Active Perl on Windows Vista. I am trying to install Active Perl on Windows Vista. The version of Active Perl i am trying to install is : ActivePerl 5.10.1 Build 1006 After installing it through cmd, When i try to run perl -v to check the version, i get the... (2 Replies)
Discussion started by: Vabiosis
2 Replies

8. Shell Programming and Scripting

Broke Perl Script Second pair of eyes NET::FTPSSL

Hi all, Let me first start out by saying I'm a perl newbie and hope somebody can help, for the life of me I can't figure out why my script will not find and download a remote file via FTPSSL. What it's supposed to do is find the latest file named... (4 Replies)
Discussion started by: Styles
4 Replies

9. Programming

Writing a .NET service to be Hosted in UNIX

Has anyone here written an MS compatible .NET service that is hosted and served from a UNIX server instead of a W2K server? I love programming and writing .NET services with Visual Studio.NET and C#, but there is a fundamental problem --the Win2k server itself. It is not near as reliable as Sun... (0 Replies)
Discussion started by: yeslekmc
0 Replies
Login or Register to Ask a Question