创建一个批处理文件并计划它. [英] Creating a batch file and scheduling it.

查看:123
本文介绍了创建一个批处理文件并计划它.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用C#、. NET创建了Windows应用程序.

当我双击\ bin \ Debug文件夹中创建的应用程序文件时,该应用程序将正确执行.现在,我需要通过创建批处理文件并将其安排为每10分钟执行一次来实现相同目的.
我在同一文件夹(\ bin \ Debug)中用以下两行创建了一个.bat文件(使用记事本):

@echo关闭
开始D:\ Projects \ BatchFileApp \ BatchFileApp \ bin \ Debug \ BatchFileApp

另外,我已经在计划任务"中计划了这个.bat文件.

问题在于,每当计划任务运行时,它只是打开.bat文件(在记事本中)但不执行应用程序.

请指导.感谢您早日做出回应.

谢谢.

I have created a windows application using C#,.NET.

When I double click on the application file created in the \bin\Debug folder, the application gets executed properly. Now I need to achieve the same by creating a batch file and schedule it for executing it every 10 mins.
I have created a .bat file (using notepad)in the same folder (\bin\Debug ) with the following two lines:

@echo off
start D:\Projects\BatchFileApp\BatchFileApp\bin\Debug\BatchFileApp

Also, I have scheduled this .bat file in the Scheduled Tasks.

The problem is whenever the scheduled task runs, it simply opens the .bat file(in a notepad) but does not execute the application.

Pls guide. An early response is appreciated.

Thanks.

推荐答案

我在用户打开隐藏公共文件扩展名"的Windows设置之前就已经看到了这一点.
保存文件后,它实际上称为"thefile.bat.txt",因此在记事本中打开.

您需要检查文件是否另存为".bat"而不是".bat.txt"
I have seen this before where the user has the windows setting for ''Hide Common File extensions'' switched on.

When the file is save it actually is called ''thefile.bat.txt'' and as a result is being opened in notepad.

You need to check that the file is saved as ''.bat'' and not ''.bat.txt''


您可以为其创建Windows服务,在此处创建一个小型服务,它将为您处理所有功能.或者,您可以创建一个小型可执行文件,并通过Windows Service可以执行该文件,也可以使用System.Diagnostics.Start.Process(您要执行的文件路径")执行该操作,也可以使用相同的文件执行相同的批处理文件命令并执行之前,只需检查带有扩展名的完整文件名.
You can Create a Windows Service for the Same, where you can create a small service that would handle all the functionality for you. or You may Create a Small Executable file and through Windows Service you can execute that file or along with using System.Diagnostics.Start.Process("Your File Path To be Executed"), also you can execute the same batch file using the same command and before executing just check the Full File Name with the extension.


这篇关于创建一个批处理文件并计划它.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆