PC Review


Reply
Thread Tools Rate Thread

Automation Question: How do you stop a process from a .bat file?

 
 
mickey
Guest
Posts: n/a
 
      5th Aug 2008
Problem: An application I run utilizes a service (supplied with the
application) to connect to a special USB device. When the application
terminates it leaves the service running. When the application is run again
it fails to connect to it's hardware. I have found that if I manually
terminate the service, an then run the application, the application re-starts
the service and always connects to the hardware. I have advised the
manufacturer of the issue, but as a temporary work-around I would like to
launch the application using a .bat file, and when the application
terminates, the .bat file will stop the service.

I have created a .bat file that successfully launches the application,
however I can't seem to stop the service.

The command I'm using is NET STOP service, but no matter how I reference the
service I get an error. The name of the service is XNETS.exe

Here's what I've tried:
NET STOP XNETS.exe; error can find service

I went to "Services" and copied the exact path listed in the properties for
the service.
NET STOP C:\Progra~1\Common~1\XNET\XNETS.exe; error in filename, path, etc.

I can manually stop this service using the task manager; I see it listed in
"Services" and can either stop or start it there; but I can't get the NET
STOP command to find it.

I would appreciate some suggestions, thanks.


 
Reply With Quote
 
 
 
 
mickey
Guest
Posts: n/a
 
      5th Aug 2008
I did a little research on Miscrosoft's Technet for scripting, and created a
script file that can terminate the service and launch the application.

There is one minor problem that I don't understand. The subject USB
hardware is connected through a USB Network HUB (Belkin). The software with
the Belkin Hub allows the option to automatically launch the application when
the hardware connects, and automatically disconnect the hardware when the
related application terminates. Again, because I need to terminate that
problematic service before the application is started, I'm using the script
file in to Belkin software that gets executed when the hardware connects.
The Belkin software is setup to disconnect the hardware when the application,
or in this case the script file terminates. Here's the problem, even though
I have a Do-Loop that waits for the application to terminate in the script
file, for some reason the Belkin software thinks the script file has
terminated as soon as it's started, and disconnects the hardware prematurely.
I even tried putting a "MsgBox" instruction at the very end of the script
file to verify that the loop is indeed working, but the Belkin software still
disconnects the hardware, before the application ends and the "MsgBox"
command executes.

Does anyone have an idea as to why the Belkin software thinks the script
file has ended when it hasn't, or is it possible that because it's a script
file and not an actual application there is no running flag?



"mickey" wrote:

> Problem: An application I run utilizes a service (supplied with the
> application) to connect to a special USB device. When the application
> terminates it leaves the service running. When the application is run again
> it fails to connect to it's hardware. I have found that if I manually
> terminate the service, an then run the application, the application re-starts
> the service and always connects to the hardware. I have advised the
> manufacturer of the issue, but as a temporary work-around I would like to
> launch the application using a .bat file, and when the application
> terminates, the .bat file will stop the service.
>
> I have created a .bat file that successfully launches the application,
> however I can't seem to stop the service.
>
> The command I'm using is NET STOP service, but no matter how I reference the
> service I get an error. The name of the service is XNETS.exe
>
> Here's what I've tried:
> NET STOP XNETS.exe; error can find service
>
> I went to "Services" and copied the exact path listed in the properties for
> the service.
> NET STOP C:\Progra~1\Common~1\XNET\XNETS.exe; error in filename, path, etc.
>
> I can manually stop this service using the task manager; I see it listed in
> "Services" and can either stop or start it there; but I can't get the NET
> STOP command to find it.
>
> I would appreciate some suggestions, thanks.
>
>

 
Reply With Quote
 
Klaus Jorgensen
Guest
Posts: n/a
 
      5th Aug 2008
mickey laid this down on his screen :
> I have created a .bat file that successfully launches the application,
> however I can't seem to stop the service.
>
> The command I'm using is NET STOP service, but no matter how I reference the
> service I get an error. The name of the service is XNETS.exe
>
> Here's what I've tried:
> NET STOP XNETS.exe; error can find service
>


XNETS.exe is the name of the executable - not necessarily the service
name. The service name is shown in the list of services; right-click on
a service and click properties, then the service name (and it's display
name) is shown. If the service name has blanks in it, you'll have to
use double quotation marks in the "net stop" command - e.g.:
net stop "service name"

--
/klaus


 
Reply With Quote
 
mickey
Guest
Posts: n/a
 
      5th Aug 2008
I verified that XNETS is the name of the service, which does work in the
script file.

Thanks for your suggestion.

Mick

"Klaus Jorgensen" wrote:

> mickey laid this down on his screen :
> > I have created a .bat file that successfully launches the application,
> > however I can't seem to stop the service.
> >
> > The command I'm using is NET STOP service, but no matter how I reference the
> > service I get an error. The name of the service is XNETS.exe
> >
> > Here's what I've tried:
> > NET STOP XNETS.exe; error can find service
> >

>
> XNETS.exe is the name of the executable - not necessarily the service
> name. The service name is shown in the list of services; right-click on
> a service and click properties, then the service name (and it's display
> name) is shown. If the service name has blanks in it, you'll have to
> use double quotation marks in the "net stop" command - e.g.:
> net stop "service name"
>
> --
> /klaus
>
>
>

 
Reply With Quote
 
ju.c
Guest
Posts: n/a
 
      6th Aug 2008
Try using "sc stop" instead of "net stop".


For processes:

ProcessUtility 2.03
2003 Craig Peacock
http://www.beyondlogic.org


Command Line Process Viewer/Killer/Suspender

Usage:

ProcessUtility.exe [-v] [-t] [-c]
ProcessUtility.exe [-q] [Process Name/PID] [timeout sec(optional)]
ProcessUtility.exe [-k] [-s] [-r] [Process Name/PID]
ProcessUtility.exe [-p] [Process Name/PID]
{RealTime|High|AboveNormal|Normal|BelowNormal|Low}
ProcessUtility.exe [-a] [Process Name/PID] [Mask(To Set)]

-v View Processes.
-t View Kernel and User CPU Times.
-c View Process Creation Times.
-q Send WM_CLOSE Message. Default timeout is 60 Sec
-k Kill Process. (Terminate)
-s Suspend Process.
-r Resume Suspended Process.
-p Set Process Priority.
-a Get/Set Affinity Mask of Process.

PROCUTIL -q [PID] 5


ju.c


"mickey" <(E-Mail Removed)> wrote in message
news:2ED7B32C-5847-4C11-A087-(E-Mail Removed)...
> I verified that XNETS is the name of the service, which does work in the
> script file.
>
> Thanks for your suggestion.
>
> Mick
>
> "Klaus Jorgensen" wrote:
>
>> mickey laid this down on his screen :
>> > I have created a .bat file that successfully launches the application,
>> > however I can't seem to stop the service.
>> >
>> > The command I'm using is NET STOP service, but no matter how I reference the
>> > service I get an error. The name of the service is XNETS.exe
>> >
>> > Here's what I've tried:
>> > NET STOP XNETS.exe; error can find service
>> >

>>
>> XNETS.exe is the name of the executable - not necessarily the service
>> name. The service name is shown in the list of services; right-click on
>> a service and click properties, then the service name (and it's display
>> name) is shown. If the service name has blanks in it, you'll have to
>> use double quotation marks in the "net stop" command - e.g.:
>> net stop "service name"
>>
>> --
>> /klaus
>>
>>
>>

 
Reply With Quote
 
mickey
Guest
Posts: n/a
 
      12th Aug 2008
Thanks ju.c,

Just saw your reply. I will try your suggestions. While I have a script
file that works most of the time, occasionally it fails to stop XNETS.

"ju.c" wrote:

> Try using "sc stop" instead of "net stop".
>
>
> For processes:
>
> ProcessUtility 2.03
> 2003 Craig Peacock
> http://www.beyondlogic.org
>
>
> Command Line Process Viewer/Killer/Suspender
>
> Usage:
>
> ProcessUtility.exe [-v] [-t] [-c]
> ProcessUtility.exe [-q] [Process Name/PID] [timeout sec(optional)]
> ProcessUtility.exe [-k] [-s] [-r] [Process Name/PID]
> ProcessUtility.exe [-p] [Process Name/PID]
> {RealTime|High|AboveNormal|Normal|BelowNormal|Low}
> ProcessUtility.exe [-a] [Process Name/PID] [Mask(To Set)]
>
> -v View Processes.
> -t View Kernel and User CPU Times.
> -c View Process Creation Times.
> -q Send WM_CLOSE Message. Default timeout is 60 Sec
> -k Kill Process. (Terminate)
> -s Suspend Process.
> -r Resume Suspended Process.
> -p Set Process Priority.
> -a Get/Set Affinity Mask of Process.
>
> PROCUTIL -q [PID] 5
>
>
> ju.c
>
>
> "mickey" <(E-Mail Removed)> wrote in message
> news:2ED7B32C-5847-4C11-A087-(E-Mail Removed)...
> > I verified that XNETS is the name of the service, which does work in the
> > script file.
> >
> > Thanks for your suggestion.
> >
> > Mick
> >
> > "Klaus Jorgensen" wrote:
> >
> >> mickey laid this down on his screen :
> >> > I have created a .bat file that successfully launches the application,
> >> > however I can't seem to stop the service.
> >> >
> >> > The command I'm using is NET STOP service, but no matter how I reference the
> >> > service I get an error. The name of the service is XNETS.exe
> >> >
> >> > Here's what I've tried:
> >> > NET STOP XNETS.exe; error can find service
> >> >
> >>
> >> XNETS.exe is the name of the executable - not necessarily the service
> >> name. The service name is shown in the list of services; right-click on
> >> a service and click properties, then the service name (and it's display
> >> name) is shown. If the service name has blanks in it, you'll have to
> >> use double quotation marks in the "net stop" command - e.g.:
> >> net stop "service name"
> >>
> >> --
> >> /klaus
> >>
> >>
> >>

>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
STOP:C000021a Process System Process Terminated Unexpectedly Robert J. Rando Windows XP Help 6 26th Dec 2005 12:56 AM
STOP:C000021a Process System Process Terminated Unexpectedly Robert J. Rando Windows XP Performance 6 26th Dec 2005 12:56 AM
STOP:C000021a Process System Process Terminated Unexpectedly Robert J. Rando Windows XP Drivers 6 26th Dec 2005 12:56 AM
Word's User Process shutdown Automation process =?Utf-8?B?WWVodWRh?= Microsoft Word Document Management 0 17th Aug 2005 10:05 PM
Word Automation file question Devhead Microsoft C# .NET 1 28th Jan 2005 10:03 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:45 PM.