I am trying to execute the "net" command in a windows guest from java using the startProgramInGuest method.
I've tried using "%SystemRoot%\System32\net" as the path.
I've tried retrieving the environment variables using readEnvironmentVariableInGuest and then using it in the path which leads to "c:\WINDOWS\System32\net"
I've tried hardcoding the path.
I've tried setting the environment variables including path and then just executing "net".
No matter what I try, I always get a FileNotFound error. Is there something I'm not understading about the error or how to set the path?
Thank you.
Hi casolorz!
Just a quick guess: did you also try "net.exe" to specify the full program name.
Hi casolorz!
Just a quick guess: did you also try "net.exe" to specify the full program name.
Wow I feel like an idiot. That seems to have worked, at least I'm not getting the exception. I had gotten around it by running cmd.exe /c but this is much better.
Hi Carlos,
Wow I feel like an idiot.
:-DDDDDDDDDDDD - believe me you really don't have to, with all the stuff involved when working with the vSphere APIs I actually face such moments too. And hey "cmd.exe /c" is much more innovative - so believe me everything is just fine 😉
Happy coding, and thanks for awarding points.
Yeah I know what you mean, on top of that I'm working on a vmware host in which I have very limited rights so half the time I don't know if the errors are related to limited rights or if I'm making the wrong calls.
hi , casolorz
How to use the startProgramInGuest method ?
how to get the startProgramInGuest method‘s parameter GuestProcessManager(ManagedObjectReference) ?
Can show your code ?
I am using a java wrapper from here http://vijava.sourceforge.net/
Assuming you have a vm object and a service object:
GuestProcessManager procMan = service.getGuestOperationsManager().getProcessManager(vm);
NamePasswordAuthentication auth = new NamePasswordAuthentication();
auth.setUsername(vmtUsername());
auth.setPassword(vmPassword());
GuestProgramSpec spec = new GuestProgramSpec();
spec.setProgramPath("programname.exe");
spec.setArguments("program arguments");
long pid = procMan.startProgramInGuest(auth, spec);
You can also use the process manager to check if the process is still running.
Thank you very much,Can you tell me your email? Much grant instruction!