Unable to capture CMD output from VMWare utility

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
mirrormirror
Posts: 129
Joined: 08 Feb 2016 20:25

Unable to capture CMD output from VMWare utility

#1 Post by mirrormirror » 08 Feb 2016 20:53

Hello all - I'm brand new to the forum. I've read through several posts and am impressed with the many ingenious solutions to various problems. I have a problem that I hope someone can help figure out...

I use a VMWare utility to mount/unmount virtual disks (.vmdk) via script. In order to see/repro the issue you would need to download the utility from here:
https://my.vmware.com/web/vmware/detail ... on_history
I'm using windows so you'll need to choose the "Windows" download.
Also, it may ask you to create a user/login in order to download but the utility is free.
EDIT: I uploaded the mount utility in case anyone else wants to download without creating a vmware account. The file is here: https://storage-eu.gmx.com/qx/gmx_com_eu/?locale=en&guestToken=cWkMdW8TTDGQWaO_9WaUZg&loginName=365@gmx.com
it is a .7z password-protected file - the password is: dostips

After installing, here is the command that I run and the output: "No volumes mounted."

Code: Select all

C:\Program Files (x86)\VMware\VMware Virtual Disk Development Kit\bin>vmware-mount.exe /L
No volumes mounted.

Yet "temp.txt" is always empty (as seen in the above screen output).

It looks like it is using stdout - see the following tests/results:

Code: Select all

C:\Program Files (x86)\VMware\VMware Virtual Disk Development Kit\bin>vmware-mount.exe /L 1>temp.txt

C:\Program Files (x86)\VMware\VMware Virtual Disk Development Kit\bin>vmware-mount.exe /L 2>temp.txt
No volumes mounted.

C:\Program Files (x86)\VMware\VMware Virtual Disk Development Kit\bin>type temp.txt

C:\Program Files (x86)\VMware\VMware Virtual Disk Development Kit\bin>

I've tried:
piping with for loops
Using alternate "Tee" utilities
launchng another cmd.exe process to get the output

and other things but for some reason I just can't seem to capture the output. Anyone have any ideas?
Last edited by mirrormirror on 11 Feb 2016 16:28, edited 1 time in total.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Unable to capture CMD output from VMWare utility

#2 Post by foxidrive » 09 Feb 2016 03:52

Does this give you anything in the file?

Code: Select all

vmware-mount.exe /L >file.txt 2>&1

Squashman
Expert
Posts: 4472
Joined: 23 Dec 2011 13:59

Re: Unable to capture CMD output from VMWare utility

#3 Post by Squashman » 09 Feb 2016 07:59

mirrormirror wrote:It looks like it is using stdout - see the following tests/results:

Code: Select all

C:\Program Files (x86)\VMware\VMware Virtual Disk Development Kit\bin>vmware-mount.exe /L 1>temp.txt

C:\Program Files (x86)\VMware\VMware Virtual Disk Development Kit\bin>vmware-mount.exe /L 2>temp.txt
No volumes mounted.

C:\Program Files (x86)\VMware\VMware Virtual Disk Development Kit\bin>type temp.txt

C:\Program Files (x86)\VMware\VMware Virtual Disk Development Kit\bin>



I am a bit confused by the description of your problem because of the code examples you provided. The first time you run the mount program you are not getting any verbose output to the console. So that tells me there is output in temp.txt. But then you run it again but redirect standard error to temp.txt. This time you get verbose output but at the same time you have overwritten temp.txt so when you use the TYPE command to display temp.txt it is empty. If your point was to try and prove that it was empty regardless of what you do, then your code example to prove that point is extremely flawed. You are opening a file handle to overwrite that file regardless of their being any Standard Output or Standard Error. So it will always get overwritten.

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: Unable to capture CMD output from VMWare utility

#4 Post by Ed Dyreen » 09 Feb 2016 08:23

Correct me if I am wrong but I don't think you can mount a vmdk inside a running vmx. I assume you want to change the configuration ( add a vmdk ), start the vm, do something, power off, mount a different vmdk, power on again and do something else, right ?

But this can be done without any tool so maybe I am missing something.

Why not change the configuration inside vmware, compare the changed vmx with the previous vmx, note down what changes are made to the vmx file and script the vmx file and then use:
vmware.exe -x "myVM.vmx" ?

I would simply add an entry to the vmx:
idex:x.filename = "myVMDK.vmdk"

I would use the gui and see what changes vmware makes and compare.

einstein1969
Expert
Posts: 944
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Unable to capture CMD output from VMWare utility

#5 Post by einstein1969 » 09 Feb 2016 12:14

@ed
I think that the utility is for Mount a vmware disk on the HOST system operating (for access).

mirrormirror
Posts: 129
Joined: 08 Feb 2016 20:25

Re: Unable to capture CMD output from VMWare utility

#6 Post by mirrormirror » 09 Feb 2016 15:53

Sorry for the confusing results - I've updated them below and also tried the command from foxdrive:

Code: Select all

C:\Program Files (x86)\VMware\VMware Virtual Disk Development Kit\bin>vmware-mount.exe /L 1>temp.txt

C:\Program Files (x86)\VMware\VMware Virtual Disk Development Kit\bin>type temp.txt

C:\Program Files (x86)\VMware\VMware Virtual Disk Development Kit\bin>vmware-mount.exe /L 2>temp.txt
No volumes mounted.

C:\Program Files (x86)\VMware\VMware Virtual Disk Development Kit\bin>type temp.txt

C:\Program Files (x86)\VMware\VMware Virtual Disk Development Kit\bin>vmware-mount.exe /L >file.txt 2>&1

C:\Program Files (x86)\VMware\VMware Virtual Disk Development Kit\bin>type temp.txt

C:\Program Files (x86)\VMware\VMware Virtual Disk Development Kit\bin>

Correct me if I am wrong but I don't think you can mount a vmdk inside a running vmx. I assume you want to change the configuration ( add a vmdk ), start the vm, do something, power off, mount a different vmdk, power on again and do something else, right ?

I am not using it for this purpose - einstein1969 is correct that this mounts the drive on my host machine. I can then copy/update files, etc. directly on the VM drive without ever firing up the VM itself. I have a bare-bones config VM with a non-persistent drive and a startup script that installs / configures things on startup every time. This allows me to change the config or the startup script outside of the vm as needed.

EDIT: adding a couple more examples of things I've tried:

Code: Select all

C:\Program Files (x86)\VMware\VMware Virtual Disk Development Kit\bin>vmware-mount.exe /L
No volumes mounted.

C:\Program Files (x86)\VMware\VMware Virtual Disk Development Kit\bin>vmware-mount.exe /L |FIND /I "No"

C:\Program Files (x86)\VMware\VMware Virtual Disk Development Kit\bin>vmware-mount.exe /L |MORE


C:\Program Files (x86)\VMware\VMware Virtual Disk Development Kit\bin>


Any more ideas or things to try to capture this output? Just post them here and I can try them and report back.

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: Unable to capture CMD output from VMWare utility

#7 Post by Ed Dyreen » 09 Feb 2016 19:30

try this

Code: Select all

2>temp.txt >&2 ( vmware-mount.exe /L )

type temp.txt

mirrormirror
Posts: 129
Joined: 08 Feb 2016 20:25

Re: Unable to capture CMD output from VMWare utility

#8 Post by mirrormirror » 09 Feb 2016 20:28

Results below - no difference.

Code: Select all

C:\Program Files (x86)\VMware\VMware Virtual Disk Development Kit\bin>2>temp.txt >&2 ( vmware-mount.exe /L )

C:\Program Files (x86)\VMware\VMware Virtual Disk Development Kit\bin>type temp.txt

C:\Program Files (x86)\VMware\VMware Virtual Disk Development Kit\bin>

Squashman
Expert
Posts: 4472
Joined: 23 Dec 2011 13:59

Re: Unable to capture CMD output from VMWare utility

#9 Post by Squashman » 09 Feb 2016 21:25

I just find this hard to believe. I know you cannot redirect CON but we can see that STDOUT is getting redirected somewhere because it is not being displayed on the screen. My other thought process was that you do not have permissions to write to a text file in the Program Files directory. You should not be able to write to a file in that directory unless you are running cmd.exe with elevated privileges.

mirrormirror
Posts: 129
Joined: 08 Feb 2016 20:25

Re: Unable to capture CMD output from VMWare utility

#10 Post by mirrormirror » 09 Feb 2016 23:31

I just find this hard to believe. I know you cannot redirect CON but we can see that STDOUT is getting redirected somewhere because it is not being displayed on the screen. My other thought process was that you do not have permissions to write to a text file in the Program Files directory. You should not be able to write to a file in that directory unless you are running cmd.exe with elevated privileges.

Thanks for the thoughts - I found it hard to believe also. Capturing command output is something I do on a regular basis - whether into a file, or variable or whatever and I this one utility acts different than others. I am positive it is not the permissions issue you mention because this is run from different folders with the same results - I'm also using an admin cmd prompt. As I mentioned, the screen output does go away when you redirect "1>" but is visible when you use "2>" so I assumed it used stdout ???

Could there be some strange unicode output or something that standard cmd utilities cannot handle?

einstein1969
Expert
Posts: 944
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Unable to capture CMD output from VMWare utility

#11 Post by einstein1969 » 10 Feb 2016 05:31

Hi,

are you probed to download a different version (like vsphere virtual disk development kit 5.5.5 or 6.0 or ....) ?

If the output is on CON: I think that it is possible (in 32bit machine) use debug.exe to capture the output.

You can use a semi automatic capture with VB sendkey also an other method.

But I'm not expert in this last methods.

Einstien1969

Squashman
Expert
Posts: 4472
Joined: 23 Dec 2011 13:59

Re: Unable to capture CMD output from VMWare utility

#12 Post by Squashman » 10 Feb 2016 07:45

I would like to see if a FOR /F command can capture it.

Code: Select all

FOR /F "delims=" %G IN ('vmware-mount.exe /L') DO echo %G

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Unable to capture CMD output from VMWare utility

#13 Post by foxidrive » 10 Feb 2016 08:39

mirrormirror wrote:and also tried the command from foxdrive:

Code: Select all

C:\Program Files (x86)\VMware\VMware Virtual Disk Development Kit\bin>vmware-mount.exe /L >file.txt 2>&1

C:\Program Files (x86)\VMware\VMware Virtual Disk Development Kit\bin>type temp.txt



There is one small flaw with your test.

You typed the wrong file. :D

einstein1969
Expert
Posts: 944
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Unable to capture CMD output from VMWare utility

#14 Post by einstein1969 » 10 Feb 2016 09:11

Squashman wrote:I would like to see if a FOR /F command can capture it.

Code: Select all

FOR /F "delims=" %G IN ('vmware-mount.exe /L') DO echo %G


nothing...

Code: Select all

C:\Program Files\VMware\VMware Virtual Disk Development Kit\bin>FOR /F "delims=" %G IN ('vmware-mount.exe /L') DO echo %G

C:\Program Files\VMware\VMware Virtual Disk Development Kit\bin>

einstein1969
Expert
Posts: 944
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: Unable to capture CMD output from VMWare utility

#15 Post by einstein1969 » 10 Feb 2016 09:19

foxidrive wrote:
mirrormirror wrote:and also tried the command from foxdrive:

Code: Select all

C:\Program Files (x86)\VMware\VMware Virtual Disk Development Kit\bin>vmware-mount.exe /L >file.txt 2>&1

C:\Program Files (x86)\VMware\VMware Virtual Disk Development Kit\bin>type temp.txt



There is one small flaw with your test.

You typed the wrong file. :D


C:\Program Files\VMware\VMware Virtual Disk Development Kit\bin>
C:\Program Files\VMware\VMware Virtual Disk Development Kit\bin>vmware-mount.exe /L >file.txt 2>&1

C:\Program Files\VMware\VMware Virtual Disk Development Kit\bin>type file.txt

C:\Program Files\VMware\VMware Virtual Disk Development Kit\bin>


nothing...

Post Reply