无法让Windows任务调度程序运行计划的控制台应用程序

时间:2022-06-16 04:34:50

I have a console app that uses two batch files to decompress a zip file, take the xls which was decompressed convert it to CSV and BCP the data into a SQL table. I'd like to schedule this console app to run once a day. I set up windows task scheduler to run said app. I try to "test run" the task and don't get an error. I have the app writing to a txt file when exceptions are caught and i get an error along the lines of "the xls file you are trying to use is being used by another process".

我有一个控制台应用程序,它使用两个批处理文件来解压缩zip文件,将解压缩的xls转换为CSV并将数据BCP转换为SQL表。我想安排这个控制台应用程序每天运行一次。我设置了Windows任务调度程序来运行所述应用程序。我尝试“测试运行”任务,并没有得到错误。当有异常被捕获时,我有应用程序写入txt文件,我得到一个错误,就像“你试图使用的xls文件被另一个进程使用”。

NOTE: I know there are more efficiant ways of accomplishing the importation of xls to SQL, but it is for a client who is too cheap to buy a FULL version of SQL SERVER.

注意:我知道有更有效的方法来完成xls到SQL的导入,但是对于一个太便宜而无法购买完整版SQL SERVER的客户端。

3 个解决方案

#1


Something hasn't released it's hold on the XML file. You need to figure out what other program is using that resource and ensure that it's connections are closed. It could be that in your test run you don't close your connection, and then later on when the task is run, there's another process (the earlier instance of your app) that hasn't released the resource.

有些东西没有发布它对XML文件的保留。您需要弄清楚其他程序正在使用该资源并确保其连接已关闭。可能是在测试运行中您没有关闭连接,然后在运行任务时,还有另一个尚未释放资源的进程(应用程序的早期实例)。

#2


sounds like you are triying to use the xml file before it's fully decompressed. Also check the possibility that rie819 mentioned before.

听起来你正在试图在完全解压缩之前使用xml文件。还要检查rie819之前提到过的可能性。

We could help you better if you post your scripts.

如果您发布脚本,我们可以帮助您更好。

#3


I found a way to produce the results I needed. I took the two batch files out of the console app. I now have a task scheduled to run one batch, the console app, and the last batch. Both answers I recieved were correct, it wasn't releasing the XML because of the console windows opening in the middle of execution. Since they have been removed I no longer have errors. Thanks for the help. -Z

我找到了一种方法来产生我需要的结果。我从控制台应用程序中取出了两个批处理文件。我现在有一个任务计划运行一个批处理,控制台应用程序和最后一批。我收到的两个答案都是正确的,因为控制台窗口在执行过程中打开,所以它没有发布XML。由于它们已被删除,我不再有错误。谢谢您的帮助。 -Z

#1


Something hasn't released it's hold on the XML file. You need to figure out what other program is using that resource and ensure that it's connections are closed. It could be that in your test run you don't close your connection, and then later on when the task is run, there's another process (the earlier instance of your app) that hasn't released the resource.

有些东西没有发布它对XML文件的保留。您需要弄清楚其他程序正在使用该资源并确保其连接已关闭。可能是在测试运行中您没有关闭连接,然后在运行任务时,还有另一个尚未释放资源的进程(应用程序的早期实例)。

#2


sounds like you are triying to use the xml file before it's fully decompressed. Also check the possibility that rie819 mentioned before.

听起来你正在试图在完全解压缩之前使用xml文件。还要检查rie819之前提到过的可能性。

We could help you better if you post your scripts.

如果您发布脚本,我们可以帮助您更好。

#3


I found a way to produce the results I needed. I took the two batch files out of the console app. I now have a task scheduled to run one batch, the console app, and the last batch. Both answers I recieved were correct, it wasn't releasing the XML because of the console windows opening in the middle of execution. Since they have been removed I no longer have errors. Thanks for the help. -Z

我找到了一种方法来产生我需要的结果。我从控制台应用程序中取出了两个批处理文件。我现在有一个任务计划运行一个批处理,控制台应用程序和最后一批。我收到的两个答案都是正确的,因为控制台窗口在执行过程中打开,所以它没有发布XML。由于它们已被删除,我不再有错误。谢谢您的帮助。 -Z