windows - How can I start a VirtualBox VM and then run a batch file inside the VM

06
2014-04
  • rossmcm

    I have a lengthy build operation which calls several batch files in succession. Most of these batch files start 32-bit compilers, etc, but one of them involves running a legacy MS-DOS 16-bit app which for good reasons I can't avoid.

    No problem, until I moved to a Win64 system, which of course chokes on 16-bit programs.

    My workaround has been to run XP 32-bit in a VirtualBox VM, but it is manual step in what would otherwise be a completely unattended build.

    What I want to do is start the VM from a command line, then run a batch file inside the VM, and then close the VM and return control to my "master" batch file.

    Is this going to be possible?

  • Answers
  • arpz

    Thought about using DOSBox? You'd be able to invoke that from a batch file etc which would allow for completely unattended builds and would mean you could have it directly access your codebase and leave the resultant build there too, rather than within some VM's disk.

    http://www.dosbox.com/wiki/Basic_Setup_and_Installation_of_DosBox will get you started

  • crayzeedude

    You could try creating a shared folder for the VM and putting your batch file(s) in it. From what I'm thinking, it would require some degree of manual intervention.


  • Related Question

    windows - Run a completly hidden batch file
  • Moayad Mardini

    I'm looking for some way to run a batch file (.bat) without anything visible to the user (no window, no taskbar name, .etc..).

    I don't want to use some program to do that, I'm looking for something cleaner. I've found a solution that uses VBScript, but I don't really like using VBS, either.


  • Related Answers
  • Vlastimil Ovčáčík

    Solution 1:

    Save this one line of text as file invisible.vbs:

    CreateObject("Wscript.Shell").Run """" & WScript.Arguments(0) & """", 0, False

    To run any program or batch file invisibly, use it like this:

    wscript.exe "C:\Wherever\invisible.vbs" "C:\Some Other Place\MyBatchFile.bat"

    To also be able to pass-on/relay a list of arguments use only two double quotes

    CreateObject("Wscript.Shell").Run "" & WScript.Arguments(0) & "", 0, False

    Example: Invisible.vbs "Kill.vbs ME.exe"

    Solution 2:

    Use a command line tool to silently launch a process : Quiet, hidecon or hideexec.

  • joe

    use Cmdow is a Win32 commandline utility for NT4/2000/XP/2003 that allows windows to be listed, moved, resized, renamed, hidden/unhidden, disabled/enabled, minimized, maximized, restored, activated/inactivated, closed, killed and more.

    Run a batch file hidden passing it parameters:-

    cmdow /run /hid mybat arg1 "arg 2"

  • John T

    Run the script via an at job without making it interactive:

    at 11:00 script.bat
    


    Another solution, if you don't mind installing something like Python, you could simply create a script and run it with pythonw (the linked version for GUI operations). Since you aren't using any graphical APIs, the window will not show. Simply use calls to os.system() and it will mimic a batch script, as it is the same as typing the strings into the command line.

    Example:

    import os
    
    os.system("tasklist > C:\tasks.txt")
    os.system("ipconfig /all > C:\netinfo.log")
    
  • 8088

    Seems that somebody made a list of the 7-8 ways to run 'silent':

    http://forums.techguy.org/dos-other/644932-solved-howto-run-batch-file.html

  • Paul Cheselske

    To Hide batch files or command files or any files.... Use Windows XP built in Iexpress.exe utility to build a .EXE out of the batch file. When using Iexpress make sure you check the run hidden option and check mark all the boxes about not showing anything. After you create your .exe place it in whatever run command folder you choose and you will never see it come up.

  • Jack S

    If your Batch File can fit into one line and so many characters, then just use a Shortcut by right clicking inside a folder put in a random directory, and skip through the rest of the wizard, and lastly right click on the shortcut just created and click properties and under target, input what you would usually put in a bat file. And Bobs your uncle!

    Pros:

     No Command Window
     Ability to use an icon
     Same Functionality of bat file
    

    Cons:

     Limited to one line, so many characters
    
  • Brad Gilbert

    You can run it minimized easily.

    start /MIN batch.cmd
    
  • djangofan

    Using Windows7, you can use the "Scheduled Task" control panel to schedule a batch file to run in the background invisibly with specified permissions and even as the "SYSTEM" account. See screenshot below:

    enter image description here

    Furthermore, although with not as many capabilities, you can also create a invisible batch script task like this from the command line using the "AT.exe" command without the '/interactive' option.

  • BloodPhilia
    cmdow /run /hid "file.extention" arg1 "arg 2"
    
  • sgmoore

    You do not need to do any special.

    If you are running the batch files from a windows service, they should be hidden by default unless you enable the "Allow service to interact with desktop" option on the service.

  • npocmaka

    I'm experimenting with SCHTASKS. The idea is that if schedule a task as SYSTEM user the process will be started as hidden.And if you delete a scheduled task the process will be not stopped.Here's more info : http://ss64.org/viewtopic.php?id=1539

  • djangofan

    I started trying to figure this out and never really succeeded. This was as close as I got:

    @echo off
    if not defined PIL (
        set PIL=1
        start /min "" %~0
        exit /b
    )
    TITLE Hello World
    echo Hello world!
    pause>nul
    
  • Alan Panayotov

    I had the same problem, but figured it out:
    Shell("filehere" & "parametersforbatchfilehere", vbHidden)