Link to home
Start Free TrialLog in
Avatar of vpnsol123
vpnsol123

asked on

Batch File Issues

Client has an automated process to send statement files generated out of their practice management program a company. The process is scripted to sweep the directories that they save these exported statements into and it sends them a company through .exe by means of Windows scheduled task. All works fine on my Server 2003 OS.

Here is where I am seeing an issue.

I have the exact same setup on the 2008 R2 x64 server as I do on the 2003 x86 Standard but they act differently.

Here is the basic version:

On the 2008 server – The script is below:

for %%a in ("C:\Path\*.txt") do abc.exe -u username -p password -d "Client Statement File" -f "%%a" >> abc.log

move "C:\Path\*.txt" "C:\Path\Processed"

Notice there are two parts. The first sends it to the company and the second just moves the file out of the original directory so it won’t get picked up again next time.

1. When we use a Server 2008 Scheduled Task and point it at the batch file with the commands above – it moves the file (step2) and NOTHING is written to the abc.log and if I check the company, it is never received .

2. If I run the batch script by either double clicking on it or through a command prompt – it will move the file and write to the abc.log that it was sent.

We have checked that all the abc.exe and abc.log have full permissions and obviously the scripting is written correctly because it works when run manually.

We have created a new scheduled task on the Server 2008 with Server 2003 compatibility – same result.

Also booted the server – same result.

We have even tried setting up a remote scheduled task firing off of a 2003 server in the same domain – (utilizing psexec - which we have done before when scheduled tasks wouldn't work with Server 2008 but would work when manually run) - same result.

I tried changing the abc.exe compatibility to XP but still nothing.

Confused
Avatar of Steve Knight
Steve Knight
Flag of United Kingdom of Great Britain and Northern Ireland image

Ok, first thoughts... Where is abc.exe ?  Is it accessible, i.e. in the path, or in the same dir as the script.  Is the script ran with working directory correct?

Try adding this to scheduled script:

@Echo off
( echo Run at %date% %time% as %userdomain% \ %username% on %computername%
 echo Current dir is %cd%
  dir abc.exe
  abc.exe /?  ) > "c:\path\test.log"

Assuming the exe abc.exe has a /? param which will give some output for instance.

Then see what it reports back for your scheduled job vs manual.
Hi vpnsol123,

Have you tried checking the properties of the scheduled task, to make sure that under security options it's set to run as a user rather than the system?

Start > All Programs > Accessories > System Tools > Task Scheduler

Select Task Scheduler Library
Right click on your task,
choose properties,
Under Security Options, Ensure it's using a user account, if not, click on Change User or Group button.


Hope this helps!

:o)

Bartender_1
Avatar of vpnsol123
vpnsol123

ASKER

Hi all -

I have the same question as above into the company who gave us the .exe - as it may have something to do with that exe and 2008 for all I know but I came here to make sure I wasn't missing anything from an IT standpoint that I could try.

abc.exe and the abc.log are in a direcory on C and that directory is shared with full control and full access as far as local security as well

The exe doesn't respond to a /? probably because its proprietary, I assume - should I still try to insert your scripting then?

The scheduled task is running under domain admin user account with the Run as highest privileges checked

Thx all
Was just suggesting then you could confirm what environment it is running under by looking at the log file it makes.

Steve
Does the abc.log file appear at all btw?

You could also do some other checks:

@Echo off
(
echo Run at %date% %time% as %userdomain% \ %username% on %computername%
echo Current dir is %cd%
dir abc.exe
for %%a in ("C:\Path\*.txt") do echo abc.exe -u username -p password -d "Client Statement File" -f "%%a"
for %%a in ("C:\Path\*.txt") do echo abc.exe -u username -p password -d "Client Statement File" -f "%%~a"
) > c:\path\logfile.txt

And see whether that loops through the files OK or not... do they have one set of " " around the filenames at the ends of the lines?  

Perhaps you could post a part of the log - change the pc / user names if needed.
the log file is present at all times and gets updated when the batch file is successful so basically as its not successful - it never gets written to so I have nothing to post and the user name and password in the file are fine as the whole process works if you double click the .bat.

It just baffles me that it does exactly what is should when we double click the batch file rather than pointing the 2008 scheduled task at the batch file it just does the second step - the move portion - but never the first part of the batch file

Update -

I ended up using a 2003 server in that same domain – set up the scheduled tasks there – brought over the abc.exe’s, abc.logs and batch files from all the different processes we have – changed the batch files to reference a network path rather than local and tested and they work. This is a band aid but for now – the automation is back in play so the severity is decreased.

Really weird.
So did the log of debugging information appear when you ran with the code above?

Steve
ASKER CERTIFIED SOLUTION
Avatar of Paul Tomasi
Paul Tomasi
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you.
So did you get this working that way then?  We asked for arious debugging logs but got no answer so there wasn't anything else to suggest without it frankly.