VMware {code} Community
casolorz
Enthusiast
Enthusiast
Jump to solution

FileNotFound on startProgramInGuest

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.

0 Kudos
1 Solution

Accepted Solutions
togtog
Hot Shot
Hot Shot
Jump to solution

Hi casolorz!

Just a quick guess: did you also try "net.exe" to specify the full program name.

Thomas G.

View solution in original post

0 Kudos
7 Replies
togtog
Hot Shot
Hot Shot
Jump to solution

Hi casolorz!

Just a quick guess: did you also try "net.exe" to specify the full program name.

Thomas G.
0 Kudos
casolorz
Enthusiast
Enthusiast
Jump to solution

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.

0 Kudos
togtog
Hot Shot
Hot Shot
Jump to solution

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.

Thomas G.
0 Kudos
casolorz
Enthusiast
Enthusiast
Jump to solution

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.

0 Kudos
wangjianghuan
Contributor
Contributor
Jump to solution

hi , casolorz

How to use the startProgramInGuest method ?

how to get the startProgramInGuest method‘s parameter GuestProcessManagerManagedObjectReference) ?

Can show your code ?

0 Kudos
casolorz
Enthusiast
Enthusiast
Jump to solution

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.

0 Kudos
wangjianghuan
Contributor
Contributor
Jump to solution

Thank you very much,Can you tell me your email? Much grant instruction!

0 Kudos