473,385 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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:\pscp"" -pw *******
mg*@192.168.1.240:/var/log/qmail/current
C:\_var_log_qmail_current.txt", AppWinStyle.MaximizedFocus)

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

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

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

Try

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

Catch ex As Exception

End Try



"BROQ" <ch**************@gmail.com> wrote in message
news:29**************************@posting.google.c om...
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:\pscp"" -pw *******
mg*@192.168.1.240:/var/log/qmail/current
C:\_var_log_qmail_current.txt", AppWinStyle.MaximizedFocus)

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

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

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.Diagnostics.Process
foo.StartInfo.WorkingDirectory = "c:\"
foo.StartInfo.RedirectStandardOutput = True
foo.StartInfo.FileName = "pscp.exe"
foo.StartInfo.Arguments = "-pw ****
mg*@192.168.1.57:/var/log/qmail/current C:\_var_log_qmail_current.txt"
foo.StartInfo.UseShellExecute = False
foo.StartInfo.CreateNoWindow = True
foo.Start()
foo.WaitForExit()
foo.Dispose()

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

"JohnFol" <Ou************@WibbleObbble.Com> wrote in message news:<hc*****************@newsfe2-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.NormalFocus)

Catch ex As Exception

End Try



"BROQ" <ch**************@gmail.com> wrote in message
news:29**************************@posting.google.c om...
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:\pscp"" -pw *******
mg*@192.168.1.240:/var/log/qmail/current
C:\_var_log_qmail_current.txt", AppWinStyle.MaximizedFocus)

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

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

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.Diagnostics.Process
foo.StartInfo.WorkingDirectory = "c:\"
foo.StartInfo.RedirectStandardOutput = True
foo.StartInfo.FileName = "pscp.exe"
foo.StartInfo.Arguments = "-pw ****
mg*@192.168.1.57:/var/log/qmail/current C:\_var_log_qmail_current.txt"
foo.StartInfo.UseShellExecute = False
foo.StartInfo.CreateNoWindow = True
foo.Start()
foo.WaitForExit()
foo.Dispose()

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

"JohnFol" <Ou************@WibbleObbble.Com> wrote in message news:<hc*****************@newsfe2-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.NormalFocus)

Catch ex As Exception

End Try



"BROQ" <ch**************@gmail.com> wrote in message
news:29**************************@posting.google.c om...
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:\pscp"" -pw *******
mg*@192.168.1.240:/var/log/qmail/current
C:\_var_log_qmail_current.txt", AppWinStyle.MaximizedFocus)

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

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

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
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...
1
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...
4
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#...
3
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...
3
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...
7
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? ...
25
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...
1
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...
3
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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...

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.