0

I am trying to start a virtual machine via a batch file. The .bat file runs fine when I run it from the Windows command line. But when I run it from scheduled tasks, it exits with error code 1.

I am running the command line under the same user which the scheduled task is scheduled to run under. I have checked the permissions on the Scheduled Task, and it appears that I have all access which I need to the task. The "Run As" dialog has the proper password for the user which it is using.

The batch file is very simple:

"C:\Program Files\Oracle\VirtualBox\VBoxHeadless.exe" -startvm "Debian"
2
  • Why are you putting that command in batch file, instead of running it directly?
    – kreemoweet
    Feb 16, 2013 at 17:47
  • @kreemoweet: I intend to add more commands later, and don't want to have to set up the scheduled task yet.
    – loneboat
    Feb 17, 2013 at 0:17

4 Answers 4

0

One thing to make sure is that your scheduled task instance of your user has access to all of your network shares. If your computer is part of a domain that setups network drives at login or you have any folder redirection it could cause problems.

It's important to remember that the scheduled task user runs in a limited instance of your account. No startup scripts are run and no local user cache is created. If your currently logged on user has a file locked, the scheduled task user will be unable to use it.

I know this is a long shot, but without a log of what the virtualbox executable is doing, we can't really do much to help. Most well written programs dump the "full text" error to a log file so you know what actually happened.

1
  • Thanks for the suggestions - especially the one regarding locked files. That is a good suggestion, and I will investigate that when I'm back at my workstation later today. Regarding network shares, this is all happening locally - no network involved. I appreciate your reply. I was unaware that scheduled tasks were run in a limited environment - I'll also investigate that. Thanks again for your time!
    – loneboat
    Feb 15, 2013 at 18:32
0

I got stuck with the same trouble about 2 months ago, but on Win 7 - however, the solution might work for XP as well. I had a VB script instead of CMD or BAT file that also could not be executed when I placed it to D:\TestData. As it turned out, Task Scheduler is very careful about allowed locations for such files.

Long story short, I ended up with the following: I created Scripts folder as C:\Users\username\AppData\Local\Scripts - and it worked like charm)

For XP try to create it in e.g. %USERPROFILE% folder (this is C:\Documents and Settings\username by default).

Hope that was helpful.

0

On "Security options" group, there is an option about how to run the task. You can find this option at the first tab of "Properties" page.

  • Run only when user is logged on - It makes the task visible on your desktop.
  • Run whether user is logged on or not - It makes the task invisible as there is no way to display UI when no user is logged on.

Would you please try the former option? I actually use that for a very similar situation of yours. By doing this, at least you will have chances to see what is happening there, which must be more informative than "error code 1".

Not to mention, a user should be logged on there all the time to ensure the task runs but this can be workarounded by login automation and system lock.

0

Problem : - Startup physical machine and automatic launch of VMs by sheduled task - login later on with my mainaccount (days or weeks later...no matter) - start "cmd", typing "vboxmanage list runningvms" does not showup any vms

My solution : 1- first open the component service DCOM

COMPONENTSERVICE

2- edit the highlighted component as followed :

Edit the accountsettings for launch

upon 2- enter the credentials for your account which shall see the Vms on the commandline

3- start task editor (in my case Windows 10) and follow the steps shown up. (i enabled the local administrator account and used it for the task. the DCOM component is launched by the settings defined in step 2)

Task sheduler "simple task step 1"

4- setup the starting parameters

enter image description here

Restart machine to bring the DCOM configuration changes on.

It should now visible with your entered logon account in the DCOM panel to show up the "vboxmanage list runningvms".

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .