Page 1 of 2

Command Line - Batch - Scheduled Task

PostPosted: Thu Feb 02, 2017 10:00 pm
by TLWP
I am trying to set up a scheduled task to run a batch file which calls DBFCommander 4.1.2 Pro to do a few things. It's running on a virtual Windows Server 2008 R2 machine.

Here is the batch file. I am doing a query to table because I only need two columns in the tables to a new DBF. Then I am trying to export those temporary DBF's to Excel. DBF's are FoxPro I believe.

Code: Select all
@echo off
cd "\Program Files (x86)\DBFCommander"
dbfcommander.exe -q "SELECT inv,name FROM 'c:\path\to\file.dbf'  WHERE (thedate>=DATE()-15) INTO TABLE c:\path\to\open.dbf'"
dbfcommander.exe -q "select inv,name from 'c:\path\to\file2.dbf'' INTO TABLE "c:\path\to\inv.dbf'"
dbfcommander.exe" -e "c:\path\to\open.dbf" "c:\path\to\Export\open.xls"
dbfcommander.exe" -e "c:\path\to\inv.dbf" "c:\path\to\Export\inv.xls"
exit



I started out with this on a Windows 7 machine and everything worked fine. Once I moved it to Server it worked manually. When I ran it as a scheduled task it fails completely and does not create the DBF's or XLS's.

Now when I run it manually on the server it will create the DBF's but gives me this error for creating the XLS:
Code: Select all
Error: Access violation at address 0061C610 in module 'DBFCommander.exe'. Read of address 000003A0

Re: Command Line - Batch - Scheduled Task

PostPosted: Fri Feb 03, 2017 10:48 am
by Admin
Please try to run two BAT files one by one:
Code: Select all
@echo off
cd "\Program Files (x86)\DBFCommander"
dbfcommander.exe -q "SELECT inv,name FROM 'c:\path\to\file.dbf'  WHERE (thedate>=DATE()-15) INTO TABLE c:\path\to\open.dbf'"
dbfcommander.exe -q "select inv,name from 'c:\path\to\file2.dbf'' INTO TABLE "c:\path\to\inv.dbf'"
exit

Check if the DBFs were created, then run:
Code: Select all
@echo off
cd "\Program Files (x86)\DBFCommander"
dbfcommander.exe" -e "c:\path\to\open.dbf" "c:\path\to\Export\open.xls"
dbfcommander.exe" -e "c:\path\to\inv.dbf" "c:\path\to\Export\inv.xls"
exit


Please also check system user restrictions and rights.

Re: Command Line - Batch - Scheduled Task

PostPosted: Fri Feb 03, 2017 5:07 pm
by TLWP
The DBF''s are not being created and do not give any errors. Permissions should not be an issue as it's being run as administrator and has full control over the directory.

Re: Command Line - Batch - Scheduled Task

PostPosted: Fri Feb 03, 2017 10:02 pm
by Admin
OK, I see now. There are some syntax mistakes. Please try the following:

Code: Select all
"C:\Program Files (x86)\DBFCommander\dbfcommander.exe" -q "SELECT inv,name FROM 'c:\path\to\file.dbf'  WHERE (thedate>=DATE()-15) INTO TABLE 'c:\path\to\open.dbf'"
"C:\Program Files (x86)\DBFCommander\dbfcommander.exe" -q "select inv,name from 'c:\path\to\file2.dbf' INTO TABLE 'c:\path\to\inv.dbf'"
"C:\Program Files (x86)\DBFCommander\dbfcommander.exe" -e "c:\path\to\open.dbf" "c:\path\to\Export\open.xls"
"C:\Program Files (x86)\DBFCommander\dbfcommander.exe" -e "c:\path\to\inv.dbf" "c:\path\to\Export\inv.xls"

Re: Command Line - Batch - Scheduled Task

PostPosted: Tue Apr 18, 2017 4:38 pm
by TLWP
It still gives an error on Server 2008. It looks like the export function to a spreadsheet doesn't do something right on the Server OS. I've been running this on Windows 7 just fine. Sorry for the delay.

Re: Command Line - Batch - Scheduled Task

PostPosted: Thu Apr 20, 2017 12:23 pm
by Admin
I was able to test DBF Commander Pro on MS Windows Server R2 Datacenter. Both export to a DBF file and export to an XLS file via BAT file works fine, just like on a regular OS. Looks like there are still syntax mistakes in command-line. I've updated the commands in my previous message, please try again.

Re: Command Line - Batch - Scheduled Task

PostPosted: Fri May 26, 2017 12:23 am
by TLWP
They work fine in a batch file, it is when you run it as a scheduled tasks.

I have one now in Windows 10 that is working. I have a second one that does not. It will create the DBF's but will not export the file. If i run the BAT file manually it runs.

Here is what I have in the batch file to export the DBF to XLSX. Run it manually it works. Run the BAT from a scheduled task and nothing gets created. I can see "EXECEL.EXE" run in the task manager but no file is created.

Code: Select all
dbfcommander.exe -e "C:\FreightCost\Data\FreightCostFinal.dbf" "C:\FreightCost\FreightCost.xlsx"

Re: Command Line - Batch - Scheduled Task

PostPosted: Fri May 26, 2017 3:30 pm
by Admin
Please try to export to an XLS file instead of XLSX:
Code: Select all
dbfcommander.exe -e "C:\FreightCost\Data\FreightCostFinal.dbf" "C:\FreightCost\FreightCost.xls"

Export to XLS doesn't need MS Excel to be installed. However, you'll be able to open the result XLS file with any version of Excel.

Re: Command Line - Batch - Scheduled Task

PostPosted: Tue May 30, 2017 3:58 pm
by TLWP
I tried that also. The very first one I created that has been working for months all of a sudden stopped exporting to XLS after running the "FreightCost" one I created. It will run everything else, create the DBF but will not export.

It will export to CSV though. Here is the error it is giving. I've tried to reboot the PC to see if that fixes it and it does not.

C:\ShippingLabelUpdate\DBFCommander.exe -e C:\ShippingLabelUpdate\openord.dbf C:\ShippingLabelUpdate\shplblxl.xls
Error: Access violation at address 0061C610 in module 'DBFCommander.exe'. Read of address 000003A0

C:\ShippingLabelUpdate\DBFCommander.exe -e C:\ShippingLabelUpdate\openinv.dbf C:\ShippingLabelUpdate\shplblx2.xls
Error: Access violation at address 0061C610 in module 'DBFCommander.exe'. Read of address 000003A0

Re: Command Line - Batch - Scheduled Task

PostPosted: Tue May 30, 2017 9:38 pm
by Admin
Please attach an example of such DBF file. I'll try to export it to XLS and CSV on my side.