在 Windows 上自動啟動批處理文件 (Autostart a batch file on Windows)


問題描述

在 Windows 上自動啟動批處理文件 (Autostart a batch file on Windows)

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.

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

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

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

Thanks,

Miki

‑‑‑‑‑

參考解法

方法 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

方法 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).

(by mikJose BasilioJoey)

參考文件

  1. Autostart a batch file on Windows (CC BY‑SA 3.0/4.0)

#windows-server-2003 #scripting #batch-file






相關問題

Metode Dll tidak dipanggil di windows server 2008 (Dll methods are not invoked on windows server 2008)

刪除窗口別名 (Removing windows aliases)

從 IIS 6 升級到 8.5:增加並發請求 (Upgrading from IIS 6 to 8.5: increased concurrent requests)

IOException 寫入事件日誌 (IOException writing to event log)

底層連接已關閉:接收時發生意外錯誤 (The underlying connection was closed: An unexpected error occurred on a receive)

Win2003終端服務器的小程序加載問題 (Applet loading problem with Win2003 Terminal Server)

確保在 Windows Server 2003 64 位上安裝了 ASP.NET 3.5 Framework (Ensure that ASP.NET 3.5 Framework is installed on Windows Server 2003 64-bit)

為沒有證書模板的 PKCS#10 CSR 頒發證書。0x80094801 MS W2K3企業CA (Issue certificate for a PKCS#10 CSR without Cert template. 0x80094801 MS W2K3 enterprise CA)

操作系統升級後無法從 ANT 訪問環境變量 (Can't access env vars from ANT after OS upgrade)

在 Windows 上自動啟動批處理文件 (Autostart a batch file on Windows)

為什麼從 PHP 腳本調用 (ImageMagick) convert.exe 會導致頁面無響應? (Why is calling (ImageMagick) convert.exe from PHP script resulting in an unresponsive page?)

即使在修補程序之後 SHA256 也無法正常工作 (SHA256 not working even after hotfixes)







留言討論