473,661 Members | 2,432 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

shell command in windows service doesn't execute

Hi,

I am using a windows service to extract every hour a log from our
mailserver in order to parse the logfile.
To do this I used the folowing code:

Shell("""C:\psc p"" -pw *******
mg*@192.168.1.2 40:/var/log/qmail/current
C:\_var_log_qma il_current.txt" , AppWinStyle.Max imizedFocus)

I know the """ isn't needed but i added them for testing reasons.
So what happens: nothing. The shell command doesn't get executed.
I did some help lookup and tried to test with the windows example:

Shell("C:\WINNT \system32\calc. exe", AppWinStyle.Nor malFocus)

And even this one doest work.
I try-catched it and debugged with the service debugger, but there are
no errors on that line.
Anyone knows what the problem could be?

I have this import: Imports Microsoft.Visua lBasic

Tnx a lot !
Nov 21 '05 #1
3 8653
What happens when you do this and put a break point on the catch?

Try

Shell("C:\WINNT \system32\calc. exe", AppWinStyle.Nor malFocus)

Catch ex As Exception

End Try



"BROQ" <ch************ **@gmail.com> wrote in message
news:29******** *************** ***@posting.goo gle.com...
Hi,

I am using a windows service to extract every hour a log from our
mailserver in order to parse the logfile.
To do this I used the folowing code:

Shell("""C:\psc p"" -pw *******
mg*@192.168.1.2 40:/var/log/qmail/current
C:\_var_log_qma il_current.txt" , AppWinStyle.Max imizedFocus)

I know the """ isn't needed but i added them for testing reasons.
So what happens: nothing. The shell command doesn't get executed.
I did some help lookup and tried to test with the windows example:

Shell("C:\WINNT \system32\calc. exe", AppWinStyle.Nor malFocus)

And even this one doest work.
I try-catched it and debugged with the service debugger, but there are
no errors on that line.
Anyone knows what the problem could be?

I have this import: Imports Microsoft.Visua lBasic

Tnx a lot !

Nov 21 '05 #2
It just does nothing

I've been looking around for some other solution and this works fine:

Dim foo As New System.Diagnost ics.Process
foo.StartInfo.W orkingDirectory = "c:\"
foo.StartInfo.R edirectStandard Output = True
foo.StartInfo.F ileName = "pscp.exe"
foo.StartInfo.A rguments = "-pw ****
mg*@192.168.1.5 7:/var/log/qmail/current C:\_var_log_qma il_current.txt"
foo.StartInfo.U seShellExecute = False
foo.StartInfo.C reateNoWindow = True
foo.Start()
foo.WaitForExit ()
foo.Dispose()

That works fine. I left the shell command behind me now.

"JohnFol" <Ou************ @WibbleObbble.C om> wrote in message news:<hc******* **********@news fe2-gui.ntli.net>.. .
What happens when you do this and put a break point on the catch?

Try

Shell("C:\WINNT \system32\calc. exe", AppWinStyle.Nor malFocus)

Catch ex As Exception

End Try



"BROQ" <ch************ **@gmail.com> wrote in message
news:29******** *************** ***@posting.goo gle.com...
Hi,

I am using a windows service to extract every hour a log from our
mailserver in order to parse the logfile.
To do this I used the folowing code:

Shell("""C:\psc p"" -pw *******
mg*@192.168.1.2 40:/var/log/qmail/current
C:\_var_log_qma il_current.txt" , AppWinStyle.Max imizedFocus)

I know the """ isn't needed but i added them for testing reasons.
So what happens: nothing. The shell command doesn't get executed.
I did some help lookup and tried to test with the windows example:

Shell("C:\WINNT \system32\calc. exe", AppWinStyle.Nor malFocus)

And even this one doest work.
I try-catched it and debugged with the service debugger, but there are
no errors on that line.
Anyone knows what the problem could be?

I have this import: Imports Microsoft.Visua lBasic

Tnx a lot !

Nov 21 '05 #3
It just does nothing

I've been looking around for some other solution and this works fine:

Dim foo As New System.Diagnost ics.Process
foo.StartInfo.W orkingDirectory = "c:\"
foo.StartInfo.R edirectStandard Output = True
foo.StartInfo.F ileName = "pscp.exe"
foo.StartInfo.A rguments = "-pw ****
mg*@192.168.1.5 7:/var/log/qmail/current C:\_var_log_qma il_current.txt"
foo.StartInfo.U seShellExecute = False
foo.StartInfo.C reateNoWindow = True
foo.Start()
foo.WaitForExit ()
foo.Dispose()

That works fine. I left the shell command behind me now.

"JohnFol" <Ou************ @WibbleObbble.C om> wrote in message news:<hc******* **********@news fe2-gui.ntli.net>.. .
What happens when you do this and put a break point on the catch?

Try

Shell("C:\WINNT \system32\calc. exe", AppWinStyle.Nor malFocus)

Catch ex As Exception

End Try



"BROQ" <ch************ **@gmail.com> wrote in message
news:29******** *************** ***@posting.goo gle.com...
Hi,

I am using a windows service to extract every hour a log from our
mailserver in order to parse the logfile.
To do this I used the folowing code:

Shell("""C:\psc p"" -pw *******
mg*@192.168.1.2 40:/var/log/qmail/current
C:\_var_log_qma il_current.txt" , AppWinStyle.Max imizedFocus)

I know the """ isn't needed but i added them for testing reasons.
So what happens: nothing. The shell command doesn't get executed.
I did some help lookup and tried to test with the windows example:

Shell("C:\WINNT \system32\calc. exe", AppWinStyle.Nor malFocus)

And even this one doest work.
I try-catched it and debugged with the service debugger, but there are
no errors on that line.
Anyone knows what the problem could be?

I have this import: Imports Microsoft.Visua lBasic

Tnx a lot !

Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
9890
by: Kartik | last post by:
Hi, I have an ASP.NET application using VB.NET.I am sending a DOS command to a machine on the network to print a file. This is achieved using xp_cmdshell Dim str As String = "xp_cmdshell ""type " & nwkfilepath & " > " & pPrinterName & " """
1
4991
by: tuckkhai | last post by:
Hi, I am a newbie in this area. I would like to know whether is it possible to execute shell command in windows service. I had install a program in the server which i would like it to be executed using windows services. Is it possible. If yes, how? Thanks
4
15532
by: Primo | last post by:
Hi, This problem has been frustrating me for days and I hope you experts can help me out. I am trying to run a command, which I would normally run from the command line, from within my C# application. The command runs successfully from a Windows Form but fails if the application is recasted as a Windows service. The application is essentially a File Watcher that should run the process when a file is dropped into a specific directory. ...
3
6272
by: David Eadie | last post by:
G'Day all, I cant for the God in me work out how to execute the following command line in vb.net: (watch for the word wrapping also) Sub(ByVal username As String) Shell("ECHO Y| cacls h:\finance\" & username & "\" & "+Common /G " & username & ":R", AppWinStyle.Hide, True) End Sub
3
1925
by: Rob R. Ainscough | last post by:
I have a Windows Service with a timer that use the .NET 2.0 Shell command. The Shell command returns a non-zero number but Task Manager shows the shelled exe running but there is NO visible interface (there should be one) -- I pass AppWinStyle.NormalFocus. If I execute the exact same in a Windows form test app, the Shell works flawlessly. I've tried Diagnostics.Process approach rather than Shell but have the same results -- my app...
7
2981
by: spec | last post by:
Hi all, I know nothing about Python. What I need to do is to get a Python script to execute a local shell script. I do not need any output. What would be th eeasiest way to accomplish this? Thanks!
25
62505
by: dennijr | last post by:
ok, shell always used to be easy for me, now its starting to get annoying cause i dont know wats wrong heres the simplist code possible: Private Sub IExplorer_Click() a = Shell("C:\Program Files\Internet Explorer\Iexplore.exe http://www.google.ca", vbMaximizedFocus) End Sub i have a program thats been on my desktop for about a month now that uses these 3 lines of code(supposed to be 3 lines but it doesnt quite fit) and its been...
1
3550
by: raocheng | last post by:
Please see the following code. Suppose I have many shell commands to be executed. And I don't want to fork a sub shell for each command(eg: status,output = commands.getstatusoutput(cmd)) because it is too expensive. I want to use only one sub shell to execute all these commands and want to get each command's output. How can I accomplish this task ? Thanks in advance. =========================================== #!/usr/bin/env python
3
6727
by: Max Vit | last post by:
I have come across a strange issue whilst trying to use a shell command call from Access and have spent some time trying to figure this out but can't find the cause as yet. The issue is: I need to execute a command call from within Access to execute a batch file (sample.bat). To do this, we use the Shell function, something like: Shell "cmd /c sample.bat"
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8341
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8754
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8542
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8630
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4177
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4343
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.