在Windows上自动启动批处理文件

时间:2022-03-18 02:22:38

I want to create a script that will run whenever a server is turned on to do basic things like create a directory and copy a binary from an FTP server to it. I need it to run before a user logs in, as soon as the server is turned on. This will be deployed on my EC2 windows servers.

我想创建一个脚本,只要打开服务器来执行基本操作,例如创建目录并将二进制文件从FTP服务器复制到它,它就会运行。一旦打开服务器,我就需要在用户登录之前运行它。这将部署在我的EC2 Windows服务器上。

Checking around (http://www.bleepingcomputer.com/tutorials/tutorial44.html) I saw that only services can run before a user logs in.

检查周围(http://www.bleepingcomputer.com/tutorials/tutorial44.html)我发现在用户登录之前只能运行服务。

I saw that I can make my batch into a com (bat2exe) and set it as a service but that doesn't work with internal commands like ECHO, md, etc. I can also fake a service to be "cmd /k batch.cmd".

我看到我可以将我的批处理组成一个com(bat2exe)并将其设置为服务,但这不适用于内部命令,如ECHO,md等。我还可以伪造服务为“cmd / k批处理。 CMD”。

Both seem cumbersome. Is there an elegant way to do this?

两者看起来都很麻烦。有一种优雅的方式来做到这一点?

Thanks,

Miki

2 个解决方案

#1


You can use the Windows Task Scheduler and set it for when the system is booted. Here's more info on that Task Scheduler

您可以使用Windows任务计划程序并在系统引导时将其设置为。以下是该任务计划程序的更多信息

#2


You can use the Task Scheduler. Scheduled tasks can run at startup, even before a user logs on (they run in a specified user's context, however).

您可以使用任务计划程序。计划任务可以在启动时运行,甚至可以在用户登录之前运行(但是,它们在指定用户的上下文中运行)。

#1


You can use the Windows Task Scheduler and set it for when the system is booted. Here's more info on that Task Scheduler

您可以使用Windows任务计划程序并在系统引导时将其设置为。以下是该任务计划程序的更多信息

#2


You can use the Task Scheduler. Scheduled tasks can run at startup, even before a user logs on (they run in a specified user's context, however).

您可以使用任务计划程序。计划任务可以在启动时运行,甚至可以在用户登录之前运行(但是,它们在指定用户的上下文中运行)。