Osx terminal command not found


I try to shutdown windows computers remotely with samba from within an ofApp.

I compiled and installed samba without issues, and can run the following command from the terminal or shell script without issues:

net rpc shutdown -I -U user%password

when I run this with the system() command like this

 system("net rpc shutdown -I -U user%password");

I only get the error

sh: net: command not found

I also tried using popen() without error, but also without success in various ways, eg:

popen("net rpc shutdown","-I -U user%password");

I also tried to run an otherwise functioning *.sh file via the system() command, but had no success either.

also I tried to system("osxpassword | sudo net rpc shutdown -I -U user%password");

This is witchcraft to me now, what am I doing wrong?

oh yeah, and generally terminal commands work perfectly like

system("defaults write com.apple.finder AppleShowAllFiles -boolean false");
system("killall Finder");