run bat file as a service in Windows 2003/XP

  • Thread starter Thread starter Dan
  • Start date Start date
D

Dan

Guest
Hi,

Is it possible to run a bat file as a service? I created a service with the
SRVANY and INSTSRV tools. I then created a bat file to check for the
existence of a file in a certain folder and if it existed then delete that
file. I then specified the path to the bat file in the new service's binpath.
However when the service runs it doesn't delete the file. I can see the
command prompt open up and close.

When I directly run the bat file it deletes the file. But when the service
runs it doesn't delete the file. I researched but couldn't find any specific
answer.

Thanks in advance
Dan
 
Re: run bat file as a service in Windows 2003/XP

Are you try to run it in an endless loop?

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

"Dan" wrote:
> Hi,
>
> Is it possible to run a bat file as a service? I created a service with
> the
> SRVANY and INSTSRV tools. I then created a bat file to check for the
> existence of a file in a certain folder and if it existed then delete that
> file. I then specified the path to the bat file in the new service's
> binpath.
> However when the service runs it doesn't delete the file. I can see the
> command prompt open up and close.
>
> When I directly run the bat file it deletes the file. But when the service
> runs it doesn't delete the file. I researched but couldn't find any
> specific
> answer.
>
> Thanks in advance
> Dan
 
Re: run bat file as a service in Windows 2003/XP

I think the batch file doesn't work This post discussed the similar issue.

Run Application as a service"MSNewsGroup" <Cal> wrote in message news:%23y$JyPV1HHA.4980@TK2MSFTNGP03.phx.gbl... Is there a procedure to set an application to run as a service under ...
www.chicagotech.net/netforums/viewtopic.php?t=1192


Bob Lin, MS-MVP, MCSE & CNE
Networking, Internet, Routing, VPN Troubleshooting on http://www.ChicagoTech.net
How to Setup Windows, Network, VPN & Remote Access on http://www.HowToNetworking.com
"Dan" <Dan@discussions.microsoft.com> wrote in message news:17576135-D132-44CB-84AB-C1898E872B7F@microsoft.com...
Hi,

Is it possible to run a bat file as a service? I created a service with the
SRVANY and INSTSRV tools. I then created a bat file to check for the
existence of a file in a certain folder and if it existed then delete that
file. I then specified the path to the bat file in the new service's binpath.
However when the service runs it doesn't delete the file. I can see the
command prompt open up and close.

When I directly run the bat file it deletes the file. But when the service
runs it doesn't delete the file. I researched but couldn't find any specific
answer.

Thanks in advance
Dan
 
Re: run bat file as a service in Windows 2003/XP

...Thanks for responding..Yes I'm testing a scenario whereby the service would
continually monitor the folder and whenever a file appears it would delete
it..

I'm not sure if this is the right way of doing it. The other option I have
is to schedule a task for the bat file and make it run at regular intervals.
Performance wise I'm not sure which is better.

- Dan

"Dave Patrick" wrote:

> Are you try to run it in an endless loop?
>
> --
>
> Regards,
>
> Dave Patrick ....Please no email replies - reply in newsgroup.
> Microsoft Certified Professional
> Microsoft MVP [Windows]
> http://www.microsoft.com/protect
>
> "Dan" wrote:
> > Hi,
> >
> > Is it possible to run a bat file as a service? I created a service with
> > the
> > SRVANY and INSTSRV tools. I then created a bat file to check for the
> > existence of a file in a certain folder and if it existed then delete that
> > file. I then specified the path to the bat file in the new service's
> > binpath.
> > However when the service runs it doesn't delete the file. I can see the
> > command prompt open up and close.
> >
> > When I directly run the bat file it deletes the file. But when the service
> > runs it doesn't delete the file. I researched but couldn't find any
> > specific
> > answer.
> >
> > Thanks in advance
> > Dan

>
>
 
Re: run bat file as a service in Windows 2003/XP

I don't think that will work or yield desirable effects. Here are some more
elegant methods.

http://www.codeproject.com/csharp/filewatcherwinservicecsha.asp

http://samples.gotdotnet.com/quickstart/aspplus/default.aspx?url=/quickstart/howto/doc/watcher.aspx

http://www.databasejournal.com/features/mssql/article.php/3319261


--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

"Dan" wrote:
> ..Thanks for responding..Yes I'm testing a scenario whereby the service
> would
> continually monitor the folder and whenever a file appears it would delete
> it..
>
> I'm not sure if this is the right way of doing it. The other option I have
> is to schedule a task for the bat file and make it run at regular
> intervals.
> Performance wise I'm not sure which is better.
>
> - Dan
 
Back
Top