Good evening,

I have a simple dos command, I use to stop a java service which I am trying to execute within VB.NET, however it doesn't seem to stop my service.

My DOS command which works is as follows:
NET STOP "Java Quick Starter"

My VB.NET attempt is as follows but it doesn't work:

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

       Me.Visible = False

       Shell("cmd.exe /k net stop (""Java Quick Starter"")")

    End Sub
End Class

Could I ask for a tip on how to fix this?

Thank you

John

Changing your code to:

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim str As String
        str = " /k net stop " & Chr(40) & Chr(34) & "Java Quick Starter" & Chr(34) & Chr(41)
        Process.Start("cmd.exe", str)
    End Sub
End Class

It said that the service name is invalid. You should check it.

Thank you for your help,

It did seem to run but as you said it gave me that invalid error message, which is a little strange because as you can see in the attached picture the name appears correct, further more my DOS command does function correctly.

Any clue perhaps?

Thanks again,

John

Try to double click on the service and see what is the name of the file that runs this service. This may help.

Otherwise, I think that you'll need to search about stopping services from command line, since there is no VB.net error or problem here =)

I'll see if I can find something, I'll keep you updated.

It really seems to be a mispell. I've tried with SuperFetch (just replacing Java Quick Starter with SuperFetch) and it ran fine.

Try removing the spaces.

Thank you,

I had done that and copied & pasted the named displayed there, just in case I mispelled it but no luck.
Attached is the snap shot of that window.

Thanks again,

John

Try using JavaQuickStarterService.

I did, same error message.
So I opened a command prompt and typed NET START to view a list of services in DOS. Java Quick Starter was one of them. So I typed NET STOP "Java Quick Starter" which worked.
attached is the snap shot

This is weird. Try using upper-case chars.I don't have Java quick starter here (which is even more weird), but I'll do what I can.

it might be something with the quotes I've used. I really don't know other way to use quotes than this. Someone might help more than me in this question.

Thanks, I will also try to spell out the whole thing in char?
However I will do that tomorrow, I am a bit tired for the day.

Thanks again,
If I find the fix I will post it.

John

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.