Sponsored Content
Special Forums Windows & DOS: Issues & Discussions Running perl script from a VB.NET windows service Post 302461082 by hansini on Friday 8th of October 2010 12:08:07 PM
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
 

9 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

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

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

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

8. 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

9. 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
SERVICE(8)						      System Manager's Manual							SERVICE(8)

NAME
service - run a System V init script SYNOPSIS
service SCRIPT COMMAND [OPTIONS] service --status-all service --help | -h | --version DESCRIPTION
service runs a System V init script or systemd unit in as predictable an environment as possible, removing most environment variables and with the current working directory set to /. The SCRIPT parameter specifies a System V init script, located in /etc/init.d/SCRIPT, or the name of a systemd unit. The existence of a systemd unit of the same name as a script in /etc/init.d will cause the unit to take precedence over the init.d script. The supported val- ues of COMMAND depend on the invoked script. service passes COMMAND and OPTIONS to the init script unmodified. For systemd units, start, stop, status, and reload are passed through to their systemctl/initctl equivalents. All scripts should support at least the start and stop commands. As a special case, if COMMAND is --full-restart, the script is run twice, first with the stop command, then with the start command. service --status-all runs all init scripts, in alphabetical order, with the status command. The status is [ + ] for running services, [ - ] for stopped services and [ ? ] for services without a status command. This option only calls status for sysvinit jobs. EXIT CODES
service calls the init script and returns the status returned by it. FILES
/etc/init.d The directory containing System V init scripts. /{lib,run,etc}/systemd/system The directories containing systemd units. ENVIRONMENT
LANG, LANGUAGE, LC_CTYPE, LC_NUMERIC, LC_TIME, LC_COLLATE, LC_MONETARY, LC_MESSAGES, LC_PAPER, LC_NAME, LC_ADDRESS, LC_TELEPHONE, LC_MEA- SUREMENT, LC_IDENTIFICATION, LC_ALL, TERM, PATH The only environment variables passed to the init scripts. SEE ALSO
/etc/init.d/skeleton update-rc.d(8) init(8) invoke-rc.d(8) systemctl(1) AUTHOR
Miloslav Trmac <mitr@redhat.com>, Petter Reinholdtsen <pere@hungry.com> Licence: GNU Public Licence v2 (GPLv2) COPYRIGHT
2006 Red Hat, Inc., Petter Reinholdtsen <pere@hungry.com> Jan 206 SERVICE(8)
All times are GMT -4. The time now is 12:13 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy