auto run a bat script in windows 7 at login

Cnorwood7641 picture Cnorwood7641 · Apr 18, 2013 · Viewed 107.7k times · Source

I have recently acquired a windows 7 laptop from my late grandmother. I have been using it for work and other things. I decided to create a VM using VirtualBox And now I want to create a user on the (Windows 7 Host) machine so that when I log into that user it autoruns a .bat script to start the VM. To make it clear I only want to run it only if the user "VM" logs in and not my normal user and it would be super awesome if it would autostart in full screen. I have a shortcut on my desktop that executes the command:

"C:\Program Files\Oracle\VirtualBox\VirtualBox.exe" --comment "VM" --startvm "12dada4d-    9cfd-4aa7-8353-20b4e455b3fa"

but how do I make an autorun.bat when I log into the User "VM"?

Answer

Nate Hekman picture Nate Hekman · Apr 18, 2013

To run the batch file when the VM user logs in:

Drag the shortcut--the one that's currently on your desktop--(or the batch file itself) to Start - All Programs - Startup. Now when you login as that user, it will launch the batch file.

Another way to do the same thing is to save the shortcut or the batch file in %AppData%\Microsoft\Windows\Start Menu\Programs\Startup\.

As far as getting it to run full screen, it depends a bit what you mean. You can have it launch maximized by editing your batch file like this:

start "" /max "C:\Program Files\Oracle\VirtualBox\VirtualBox.exe" --comment "VM" --startvm "12dada4d-9cfd-4aa7-8353-20b4e455b3fa"

But if VirtualBox has a truly full-screen mode (where it hides even the taskbar), you'll have to look for a command-line parameter on VirtualBox.exe. I'm not familiar with that product.