RESOLVED: SHELL command - having trouble using parameters
Hello,
I want to convert a line of code that's been using within a batchfile, to vb6:
Code:
C:
cd "\Program Files (x86)\VMware\VMware Workstation"
call vmrun stop "C:\__VMWARE MACHINES\Machine1\Machine1.vmx" hard
This works! It runs vmrun.exe, using the parameter 'stop', then the path of the file... (which successfully stops a virtual machine)
In vb6 I've tried the following:
Shell "C:\Program Files (x86)\VMware\VMware Workstation\vmplayer.exe", vbNormalFocus
...this works. I tried running vmplayer.exe just to make sure I'm heading the right way.
Then tried the following:
Shell "C:\Program Files (x86)\VMware\VMware Workstation\vmrun stop C:\__VMWARE MACHINES\Machine1\Machine1.vmx", vbNormalFocus
...This didn't work. I've tried many alterations, adding quotation marks here and there (to encapsulate the .vmx part), trying double-quotes, even 8dot3 paths.
So easy from a batch file... but still clueless on how to do it straight from vb6..
Any help greatly appreciated!
Re: SHELL command - having trouble using parameters
The first one I would try would be
Code:
Shell """C:\Program Files (x86)\VMware\VMware Workstation\vmrun"" stop ""C:\__VMWARE MACHINES\Machine1\Machine1.vmx""", vbNormalFocus
Re: SHELL command - having trouble using parameters
That was a good call. It worked. Thank you very much.
... taking notes
Re: RESOLVED: SHELL command - having trouble using parameters
Quotation marks around the executable's path in the Shell call doesn't appear to be necessary. The following works just as well:
Code:
Shell "C:\Program Files (x86)\VMware\VMware Workstation\vmrun.exe stop ""C:\__VMWARE MACHINES\Machine1\Machine1.vmx"" hard", vbNormalFocus
Note the inclusion of the parameter "hard" at the end of the command line (which you seem to have missed in your OP). Also, it would be best to specify the fully-qualified path of the executable so as to prevent situations where a file having a similar name but different extension (such as .COM) exists in the same directory.