App As System Service calling terminal commands

Greetings,

I’m trying to have a Console XOJO app as a service for windows to do some management to some pcs.

Now ,while I managed to start the app and register it as a service no matter what I put in the shell.Execute does not work , I keep on getting

woami ‘???’ is not recognised as an internal or external command

Is there a specific way to call those on windows ? so far on Mac you call shell , put the command and works straight , apparently Windows is different.

I need to be able to

  • Get Logged in Users
  • Restart / ShutDown PC
  • Logout / Lock User

Ideally would be to be able to use net command as well.

The idea is to have an IT management service that could do some automations on the desktops in the office from a central location via tcpip.

From what I see the service runs as SYSTEM so I guess that is one of the issues but I have pcs that could have multiple users so I cannot create a user service .

There are any libraries that could help on this case ? no plugins please .

whoami is probably misspelled.

If you use MBS Xojo Plugins, check ExitWindowsMBS function for shutdown/restart/logout.

I see two possible explanations: the extension of the file is missing, or the file is not in the current directory or in a directory listed in PATH.

but there is no extension to the CMD command whoami
CMD will be in path

Wonder if the OP is trying on Windows 7? whoami is not a native command on that OS

Not sure about Win 8.1 but definitely on Win 10

hi guys , the typo is in the forum post but not in the code, regarding OS, Windows 10 only, and on terminal it does work whoami as well query as well net wmic but not on the xojo service app, I guess is something related to the fact that is a console app set as a service app. I don’t see other explanation.

As for the path I did tried with the path and without the path and same result unfortunately.

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.