Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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"
share|improve this question
    
Why are you putting that command in batch file, instead of running it directly? –  kreemoweet Feb 16 '13 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 '13 at 0:17
add comment

3 Answers

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.

share|improve this answer
    
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 '13 at 18:32
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.