How to Automatically Run a Batch File on a Self-Cleaning Virtual Machine?

Solution 1:

You've almost got it! To run the scheduled task at logon, select that option from the list of triggers in the "Create basic task" wizard:

enter image description here

I would recommend running powershell directly from the task scheduler instead of using the batch script. These are the steps to follow in the wizard:

  • Action: Start a program
  • Program: Browse to Powershell.exe, usually within C:\Windows\System32\WindowsPowerShell\v1.0\
  • Arguments: copy and paste the text below. It has to be all one line:
-ExecutionPolicy RemoteSigned -f Y:\Digitization\Powershell\The_My_Computer_Desktop_Icon\Change_Desktop_Icons.PS1

Do be aware that some scripting and automation like this can get you in trouble with your IT admins if they're cranky