Old 4th May 2016, 16:08   #1
butsay
Junior Member
 
Join Date: May 2016
Posts: 19
NSIS and VBoxManage.exe

Hello everybody.
NSIS 2.51
When I run: ExecWait '"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" startvm my_vm'
it works.
When I run: ExecWait '"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" list vms'
It doesn't work.
If I run both strings in MS Windows command line , both of them work just fine.
What is the difference?
Thank you.
butsay is offline   Reply With Quote
Old 4th May 2016, 19:36   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,926
And doesn't work means what exactly? If this command writes to stdout and you want that output you need to use nsExec or one of the other "DOS" exec plugins...

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 5th May 2016, 11:31   #3
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
!include x64.nsh
${DisableX64FSRedirection}

Or use the ExecDos plug-in with the /disablefsr switch.

Stu
Afrow UK is offline   Reply With Quote
Old 5th May 2016, 17:10   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,926
Quote:
Originally Posted by Afrow UK View Post
!include x64.nsh
${DisableX64FSRedirection}

Or use the ExecDos plug-in with the /disablefsr switch.
How could WOW64 redirection be the issue if the first command worked correctly

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 6th May 2016, 12:37   #5
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Perhaps he is running the 2nd command from a page callback and has only disabled redirection in a Section. VirtualBox is a 64-bit install on 64-bit Windows so it's good to cover all bases and the user may not have disabled redirection at all (and is testing on a 32-bit OS)

Stu
Afrow UK is offline   Reply With Quote
Old 6th May 2016, 15:45   #6
butsay
Junior Member
 
Join Date: May 2016
Posts: 19
Thank you for your respond.
In my first example :ExecWait '"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" startvm my_vm' it sends the command to VM and I can see in the terminal windows how the command was executed.
In my second example :ExecWait '"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" list vms'
it does nothing. It just opens the terminal window and waits for a few second and exits. It doesn't list VMS.
butsay is offline   Reply With Quote
Old 6th May 2016, 15:47   #7
butsay
Junior Member
 
Join Date: May 2016
Posts: 19
Quote:
Originally Posted by Afrow UK View Post
!include x64.nsh
${DisableX64FSRedirection}

Or use the ExecDos plug-in with the /disablefsr switch.

Stu
It didn't help to solve the problem.
butsay is offline   Reply With Quote
Old 6th May 2016, 15:56   #8
butsay
Junior Member
 
Join Date: May 2016
Posts: 19
When I need to run : list vms, I have to use the following :
ExecWait 'cmd.exe /k "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" list vms'
I had to add cmd.exe, because it didn't work without it.
But if I run:
ExecWait 'cmd.exe /k "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" list runningvms'
It still doesn't return anything.
butsay is offline   Reply With Quote
Old 6th May 2016, 16:05   #9
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Do you get any output using nsExec?

Stu
Afrow UK is offline   Reply With Quote
Old 6th May 2016, 16:26   #10
butsay
Junior Member
 
Join Date: May 2016
Posts: 19
There is no output using nsExec.
butsay is offline   Reply With Quote
Old 6th May 2016, 18:08   #11
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,926
PHP Code:
Section
nsExec
::ExecToLog '"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" list vms'
Pop $0
SectionEnd 
works for me on 64-bit Windows 8.

Hardcoding ProgramFiles like this is of course not something you should do!

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 6th May 2016, 19:09   #12
butsay
Junior Member
 
Join Date: May 2016
Posts: 19
It works if I run it directly in MS Windows cmd:
C:\Program Files\Oracle\VirtualBox>VboxManage list runningvms
"rnd" {cf185132-d834-4f3e897c6aa3811b9972}
But it still doesn't work with NSIS:
ExecWait 'cmd.exe /k "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" list runningvms'
butsay is offline   Reply With Quote
Old 6th May 2016, 19:11   #13
butsay
Junior Member
 
Join Date: May 2016
Posts: 19
Quote:
Originally Posted by Anders View Post
PHP Code:
Section
nsExec
::ExecToLog '"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" list vms'
Pop $0
SectionEnd 
works for me on 64-bit Windows 8.

Hardcoding ProgramFiles like this is of course not something you should do!
Please try to do the same but for: list runningvms
butsay is offline   Reply With Quote
Old 6th May 2016, 19:21   #14
butsay
Junior Member
 
Join Date: May 2016
Posts: 19
Quote:
Originally Posted by butsay View Post
Please try to do the same but for: list runningvms
It works for : list vms
but it doesn't work for: list runningvms
butsay is offline   Reply With Quote
Old 6th May 2016, 19:30   #15
butsay
Junior Member
 
Join Date: May 2016
Posts: 19
When I run the command:
nsExec::ExecToLog 'cmd.exe /k "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" guestcontrol rnd --username root --password ******* run .........
I've got this output:
VBoxManage.exe: error: Machine "rnd" is not running (currently powered off)!
D:\VirtualBox>
Completed

So the problem is that the state of the virtual machine is not detected.
And this is why I can't get anything from the command : list runningvms
My questions is what should I do to detect properly the state of the virtual machine in NSIS?
It works just fine in the MS command line window.

Last edited by butsay; 6th May 2016 at 20:48.
butsay is offline   Reply With Quote
Old 6th May 2016, 20:58   #16
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,926
Does your installer request UAC elevation? I think I read something about VBox not listing VMs for other users and possibly other logon sessions.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 10th May 2016, 16:31   #17
butsay
Junior Member
 
Join Date: May 2016
Posts: 19
No, my installer doesn't request UAC elevation.
Unfortunately NSIS doesn't work properly with VboxManage.exe
I was able to run all my commands with Vboxmanage using bat file but not the ExecWait, ExecDos e.t.c.
butsay is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump