Hi!
I believe the issue is the arguments you provide to IGuestSession_processCreate on line 6440:
https://github.com/SmithersTheOracle/Vi ... psm1#L6440
You provide a single argument (ProcessCreateFlag.Hidden) however to read StdOut or StdErr from the process you must also provide the ProcessCreateFlag.WaitForStdOut and/or ProcessCreateFlag.WaitForStdErr.
Take a look at the relevant section from the SDK documentation:
6.85 ProcessCreateFlag
Guest process execution flags.
WaitForProcessStartOnly Only use the specified timeout value to wait for starting the guest
process - the guest process itself then uses an infinite timeout.
IgnoreOrphanedProcesses Do not report an error when executed processes are still alive
when VBoxService or the guest OS is shutting down.
Hidden Do not show the started process according to the guest OS guidelines.
Profile Utilize the user’s profile data when exeuting a process. Only available for Windows
guests at the moment.
WaitForStdOut The guest process waits until all data from stdout is read out.
WaitForStdErr The guest process waits until all data from stderr is read out.
Bitwise operations seem difficult in PowerShell, so I'm not certain how to combine the flags with the method you use
Code: Select all
$Global:processcreateflag.ToInt('Hidden')
but it should work with the correct value.
Also looking at your definition of ProcessCreateFlag the values aren't correct in regards to the COM api (I do not know if they differ for the Web API, but I would assume not)
Code: Select all
Switch ($FromStr) {
'None' {$ToInt = 0} # No flag set
'WaitForProcessStartOnly' {$ToInt = 1} # Only use the specified timeout value to wait for starting the guest process - the guest process itself then uses an infinite timeout.
'IgnoreOrphanedProcesses' {$ToInt = 2} # Do not report an error when executed processes are still alive when VBoxService or the guest OS is shutting down.
'Hidden' {$ToInt = 3} # Do not show the started process according to the guest OS guidelines.
'Profile' {$ToInt = 4} # Utilize the user’s profile data when exeuting a process. Only available for Windows guests at the moment.
'WaitForStdOut' {$ToInt = 5} # The guest process waits until all data from stdout is read out.
'WaitForStdErr' {$ToInt = 6} # The guest process waits until all data from stderr is read out.
'ExpandArguments' {$ToInt = 7} # Expands environment variables in process arguments. ***Note: This is not yet implemented and is currently silently ignored. We will document the protocolVersion number for this feature once it appears, so don’t use it till then.
'UnquotedArguments' {$ToInt = 8} # Work around for Windows and OS/2 applications not following normal argument quoting and escaping rules. The arguments are passed to the application without any extra quoting, just a single space between each. ***Note: Present since VirtualBox 4.3.28 and 5.0 beta 3.
Default {$ToInt = 0} # Default to 0.
}
where the COM definition is as follows (bitwise flags)
Code: Select all
public enum ProcessCreateFlag
{
ProcessCreateFlag_None = 0,
ProcessCreateFlag_WaitForProcessStartOnly = 1,
ProcessCreateFlag_IgnoreOrphanedProcesses = 2,
ProcessCreateFlag_Hidden = 4,
ProcessCreateFlag_Profile = 8,
ProcessCreateFlag_WaitForStdOut = 16,
ProcessCreateFlag_WaitForStdErr = 32,
ProcessCreateFlag_ExpandArguments = 64,
ProcessCreateFlag_UnquotedArguments = 128
}
Combining the flags, if you want the process to be hidden and to redirect both StdOut and StdErr, the correct value should be (4 + 16 + 32) == 52