From: Steve Ricketts on
I need to make a modification to a service written in VB6 that modifies and
then executes a .bat file. This runs fine when it's run from the command
line, but when I start it as a service, it creates the .bat file but doesn't
run it. I'm sure there's some sort of a permissions issue with the account
the service is running under but I've tried the local system account as well
as the administrator's account and there is no difference.

Can someone tell me what I need to do in order to run a .bat file from a
service?

Thanks,

Steve

From: mscir on
Steve Ricketts wrote:
> I need to make a modification to a service written in VB6 that modifies
> and then executes a .bat file. This runs fine when it's run from the
> command line, but when I start it as a service, it creates the .bat file
> but doesn't run it. I'm sure there's some sort of a permissions issue
> with the account the service is running under but I've tried the local
> system account as well as the administrator's account and there is no
> difference.
> Can someone tell me what I need to do in order to run a .bat file from a
> service?
> Thanks,
> Steve

Can you post your code?

How about modifying the .bat file to write a line to a text file each
time it performs a step, so you can see what kind of progress, if any,
is being made?

If you're using the Shell command are you watching the returned value? e.g.

Dim RetVal
RetVal = Shell("(path)\(file).bat", vbWindowState)

http://www.codetoad.com/forum/18_23202.asp

Mike
From: MikeD on


"Steve Ricketts" <velocedge(a)hotmail.com> wrote in message
news:uBAkxXcgKHA.1540(a)TK2MSFTNGP06.phx.gbl...
> I need to make a modification to a service written in VB6 that modifies
> and then executes a .bat file. This runs fine when it's run from the
> command line, but when I start it as a service, it creates the .bat file
> but doesn't run it. I'm sure there's some sort of a permissions issue
> with the account the service is running under but I've tried the local
> system account as well as the administrator's account and there is no
> difference.
>
> Can someone tell me what I need to do in order to run a .bat file from a
> service?

What does the batch file do? Are there any commands which prompt the user in
any way? If so, I can see how this may not run from a service unless the
"allow to interact with desktop" option , or whatever it's called, is
enabled.

But if the program is writing this batch file, why can't it just perform the
same tasks?

--
Mike


From: mscir on
MikeD wrote:

> "Steve Ricketts" <velocedge(a)hotmail.com> wrote
>> I need to make a modification to a service written in VB6 that
>> modifies and then executes a .bat file. This runs fine when it's run
>> from the command line, but when I start it as a service, it creates
>> the .bat file but doesn't run it. I'm sure there's some sort of a
>> permissions issue with the account the service is running under but
>> I've tried the local system account as well as the administrator's
>> account and there is no difference.
>> Can someone tell me what I need to do in order to run a .bat file from
>> a service?
>
> What does the batch file do? Are there any commands which prompt the
> user in any way? If so, I can see how this may not run from a service
> unless the "allow to interact with desktop" option , or whatever it's
> called, is enabled.
> But if the program is writing this batch file, why can't it just perform
> the same tasks?

I was wondering about that too, do you use a batch file for speed, or
could you replace it with a VB program?
From: Nobody on
"Steve Ricketts" <velocedge(a)hotmail.com> wrote in message
news:uBAkxXcgKHA.1540(a)TK2MSFTNGP06.phx.gbl...
>I need to make a modification to a service written in VB6 that modifies and
>then executes a .bat file. This runs fine when it's run from the command
>line, but when I start it as a service, it creates the .bat file but
>doesn't run it. I'm sure there's some sort of a permissions issue with the
>account the service is running under but I've tried the local system
>account as well as the administrator's account and there is no difference.
>
> Can someone tell me what I need to do in order to run a .bat file from a
> service?

Too many things could be happening, and not enough information. Try using
Shell, and surround the path by double-quotes. Example:

sBatchFile = """" & "C:\Program Files\Test\test.bat" & """""
Debug.Print sBatchFile
Shell sBatchFile & " /SomeOption", vbHide

Whether you use Shell or CreateProcess, the target process runs as the same
user as the service. If using CreateProcess, I think you need to run
"CMD.EXE /C file.bat", but instead of hard coding "CMD.EXE", use
Environ("ComSpec").



 |  Next  |  Last
Pages: 1 2 3 4 5 6
Prev: A problem using PrintForm
Next: How To Know