How to run a bat file inside EC2 instance using a service account

0

Just to check, how do we run a .bat file inside an AWS EC2 instance (Windows Server) using a service account on a daily schedule?

질문됨 한 달 전240회 조회
1개 답변
1
수락된 답변

To run a .bat file inside an EC2 Windows instance using a service account, you can use AWS Systems Manager Run Command. With Run Command, you can remotely execute commands on your EC2 instances without having to log in to each instance.

https://docs.aws.amazon.com/systems-manager/latest/userguide/run-command.html

Or you can also do it manually by Remote Desktop with elevated privileges: Connect to the EC2 instance using RDP with an account that has administrative privileges. Once connected, navigate to the directory containing the .bat file and run it as usual.

FEW approaches for automatic execution:

User Data Script: When launching a new EC2 instance, you can leverage the User Data field. Paste the contents of your .bat file there, and it will be executed automatically during the first boot. However, this won't involve a service account.

Scheduled Tasks with Service Account: Configure a scheduled task to run the .bat file at the desired time. You can set the task to run under the specific service account using its credentials.

profile pictureAWS
akad
답변함 한 달 전
profile pictureAWS
전문가
검토됨 한 달 전
  • Thank you akad. I tried to configure a scheduled task to run the .bat time using a service account.

    I was just wondering why would saving the scheduled task work after entering the credentials for a service account, but not after entering the credentials for a user account? Is it because the service account credentials are not stored in the AWS EC2 instance, while user account credentials will be stored in the EC2 instance for running the scheduled task?

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠