1

I'm trying to call an external function from Python: the function is vboxmanage.exe and I'm accessing it via subprocess call. The problem is that call cannot find the vboxmanage.exe program, even though it is listed in the path variable. I have tried every possible combination, with path, without path, with listing the full director, without listing the director, but call never finds it: vboxmanage is not recognized as an internal or external command, operable program or batch file.

Here my questions:

  1. For what reason does call disregard my path variable while in the Windows 10 commend prompt the path variable works fine? I'm using shell=True, so this shouldn't happen.
  2. Why is it not possible to specify a path of a program and have it executed like that from the command prompt (assuming it's not in path variable). This used to work under DOS a long time ago, but not in Windows 10. I.e. when I type in the command prompt "c:\Program Files....\vboxmanage.exe" it won't find the program. I have to first go into the directory and the execute it.
  3. Is there a way to manually navigate into the directory via call command and then invoke a second call command to open vboxmanage.exe?
from subprocess import call
param="c:\\Program Files\Oracle\VirtualBox\\vboxmanage controlvm MacBook keyboardputscancode "+h
print (param)
call([param], shell=True)
Rufflewind
  • 8,545
  • 2
  • 35
  • 55
Nickpick
  • 6,163
  • 16
  • 65
  • 116
  • You have two unescaped slashes in the path. Also, why do you want to use `shell=True`? Whether the Path variable gets used is independent of whether shell is used. – Rufflewind Oct 02 '15 at 01:25
  • 1
    A list isn't used with `shell=True`, but you don't need that anyway. If you use a list, then all of the command-line elements need to be separate items. This lets subprocess build a command-line string that's escaped following the most-commonly used MSVC `argv` rules. – Eryk Sun Oct 02 '15 at 01:57
  • 2
    For example: `param = [r"C:\Program Files\Oracle\VirtualBox\vboxmanage", "controlvm", "MacBook", "keyboardputscancode", h];` `subprocess.check_call(param)`. – Eryk Sun Oct 02 '15 at 02:01

1 Answers1

3

Just go to these folder: C:\Program Files\Oracle\VirtualBox and copy all the files there and then paste them in this folder: C:\Users\username\VirtualBoxVMs\Ubuntu64 which contains the .VDI files. Then open command prompt and navigate to this folder: C:\Users\Username\VirtualBoxVMs\Ubuntu64 and run your command from there and it will be recognize.

DeyaEldeen
  • 10,847
  • 10
  • 42
  • 75
Josh Moorish
  • 113
  • 9