How to write a service program that can call and run a script?

  • Thread starter Thread starter misaki
  • Start date Start date
M

misaki

Hi all!
My name Hùng. I'm a new member. I'm from Viet Nam.
I want to ask "How to write a service program that can call and run a
script?". Please tell me about this.
Thank you very much.

Goodbyel.
 
Hi Misaki

In a lot of ways, however probably you will always need this to start the
script

Beneath 2 methods

I hope this helps?

Cor

\\\
Dim p As New System.Diagnostics.ProcessStartInfo()
p.Verb = "print"
p.WindowStyle = ProcessWindowStyle.Hidden
p.FileName = "C:\filename.doc"
p.UseShellExecute = True
System.Diagnostics.Process.Start(p)
///
\\\
Dim p As New Process
p.StartInfo.UseShellExecute = False
p.StartInfo.RedirectStandardOutput = False
p.StartInfo.Arguments = "\?"
p.StartInfo.WorkingDirectory = "C:\mydir"
p.StartInfo.FileName = "myProg.exe"
p.Start()
///
 
* "Cor Ligthert said:
\\\
Dim p As New Process
p.StartInfo.UseShellExecute = False
p.StartInfo.RedirectStandardOutput = False
p.StartInfo.Arguments = "\?"
p.StartInfo.WorkingDirectory = "C:\mydir"
p.StartInfo.FileName = "myProg.exe"
p.Start()
///

Always remember that 'Start' is a shared method of the 'Process' class.
 
* "misaki said:
I want to ask "How to write a service program that can call and run a
script?".

In general, that's not recommended, because the application will run in
the same context as the service.
 
Always remember that 'Start' is a shared method of the 'Process' class.
Just a note because you called 'p.Start'.

Now we can see even more messages from you, you note to everyone who use a
shared method.

:-))))))))))))))

Cor
 
* "Cor Ligthert said:
Now we can see even more messages from you, you note to everyone who use a
shared method.

It's just about "best practice" ;-).
 
Hi!
What I mean is using service to run some task, for example to
scandisk,
defragment disk... or shutdown the computer. The service can be called
by
hot key in whenever we want, even logged on Windows or not. (sorry for
my
bad English).
Please, help me.......
 
dim pr as process
Sub OnStart()
Timer1.Enabled=True
MySub()
End Sub
Sub OnStop()

End Sub
Sub Timer1_tick()
MySub()
End Sub

Sub MySub()
Dim p() as Process=pr.GetProcesses()
For Each pr in p
if pr.ProcessName="Sqlsever" then
pr.kill()
end if
Next
End Sub

Remember to use the Components Timer and not Windows Timer. Set the
interval property to 500.

Right Click on the Design of the Service1.vb (or whatever name) and
click Add Installer. Using the Installer you can install the Service to
the Service Catalogue. Select the Mode as LocalSystem in the properties
of the ServiceInstaller.

In the command prompt, use the following

installutil C:\service1\bin\service1.exe (or whatever is the path)

To uninstall,

installutil /u C:\service1\bin\service1.exe (or whatever is the path)

with regards,


J.V.Ravichandran
- http://www.geocities.com/
jvravichandran
- http://www.411asp.net/func/search?
qry=Ravichandran+J.V.&cob=aspnetpro
- http://www.southasianoutlook.com
- http://www.MSDNAA.Net
- http://www.csharphelp.com
- http://www.poetry.com/Publications/
display.asp?ID=P3966388&BN=999&PN=2
- Or, just search on "J.V.Ravichandran"
at http://www.Google.com
 
Back
Top