## Command Line - Batch - Scheduled Task

Forum for DBF Commander discussing.

### Command Line - Batch - Scheduled Task

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 offcd "\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
TLWP

Posts: 8
Joined: Thu Feb 02, 2017 5:51 pm

### Re: Command Line - Batch - Scheduled Task

Please try to run two BAT files one by one:
Code: Select all
@echo offcd "\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 offcd "\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.
Best regards,
Oleg Zhechkov

Posts: 116
Joined: Wed Apr 21, 2010 7:27 pm

### Re: Command Line - Batch - Scheduled Task

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.
TLWP

Posts: 8
Joined: Thu Feb 02, 2017 5:51 pm

### Re: Command Line - Batch - Scheduled Task

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"
Best regards,
Oleg Zhechkov

Posts: 116
Joined: Wed Apr 21, 2010 7:27 pm

### Re: Command Line - Batch - Scheduled Task

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.
TLWP

Posts: 8
Joined: Thu Feb 02, 2017 5:51 pm

### Re: Command Line - Batch - Scheduled Task

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.
Best regards,
Oleg Zhechkov

Posts: 116
Joined: Wed Apr 21, 2010 7:27 pm

### Re: Command Line - Batch - Scheduled Task

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"
TLWP

Posts: 8
Joined: Thu Feb 02, 2017 5:51 pm

### Re: Command Line - Batch - Scheduled Task

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.
Best regards,
Oleg Zhechkov

Posts: 116
Joined: Wed Apr 21, 2010 7:27 pm

### Re: Command Line - Batch - Scheduled Task

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

C:\ShippingLabelUpdate\DBFCommander.exe -e C:\ShippingLabelUpdate\openinv.dbf C:\ShippingLabelUpdate\shplblx2.xls
TLWP

Posts: 8
Joined: Thu Feb 02, 2017 5:51 pm

### Re: Command Line - Batch - Scheduled Task

Please attach an example of such DBF file. I'll try to export it to XLS and CSV on my side.
Best regards,
Oleg Zhechkov