Running batch file through a service

1

1

I'm trying to schedule a batch file to run through a third party application, however the output file doesn't get created in the directory. If I run the .BAT file from the command line, it works and the file gets created. Also using the Windows Schedule will also succeed.

Basically, the 3rd party software will schedule the .BAT file and it shows success within the 3rd party user interface. The difference between running from the command prompt and the software, is that the software will use its Windows service to launch the batch.

The 3rd party software will show success since it was able to successfully call the .BAT file to run, however it has no control of the other EXE's that's being called within the script.

I'm able to run a simple .BAT file in the 3rd party software, for example a copy command.

The .BAT I'm having problems with calls a compiled EXE which launches Excel to create a file to a location.

The .bat file calls something.exe, which then calls Excel.exe:

C:\something.exe -o D:\filename.xlsm C:\filename.xlsm refresh_pivot

Do you think it's a permissions issue? I used Process Monitor to verify any Access Denied errors but everything seems to be working according to the trace. It worked on a non-64-bit OS, I'm currently using Win2008 64-bit.

wallz

Posted 2010-12-09T00:49:42.613

Reputation: 11

i'm going with a command syntax issue, but i'm not sure – RobotHumans – 2010-12-09T00:52:52.120

Try not writing the output file to the root of C:, but a subdirectory instead. – LawrenceC – 2014-04-16T14:33:23.637

Answers

0

What user credentials is the Scheduled Task running under? Has Excel been run and configured under that user account? My gut says that's where things are falling down -- Office hasn't been through its first run on the account running the batch file.

afrazier

Posted 2010-12-09T00:49:42.613

Reputation: 21 316

0

Afrazier is probably on the right track. You can test this by using the runas command from the command prompt and test running the batch file with the same account that the service uses. This would be a much better test than simply running the batch file from the command prompt under your user account or administrator.

The command would look something like this: C:\> runas /user:DOMAIN\service_acct "scheduled.bat"

I would also try substituting the actual something.exe command for the batch file and see if that has any different output, ie- C:\> runas /user:DOMAIN\service_acct "something.exe -o D:\filename.xlsm C:\filename.xlsm refresh_pivot"

That might give you a better understanding of what is going on. If an access denied error happens then it's definitely a permissions thing. You can try just typing runas at the prompt to see other options as well.

Diffuser

Posted 2010-12-09T00:49:42.613

Reputation: 118