• Welcome to PlanetSquires Forums.
 

Windows shell commands

Started by Petrus Vorster, September 14, 2022, 05:55:12 AM

Previous topic - Next topic

Petrus Vorster

Hi All

We have very ancient windows XP pc's with Verifone pin-pads (Card Swipes).
Any power failure (and down here that is up to five times a day) causes the pin-pad configuration file to corrupt sometimes.

It is simple to fix manually, but i want to make a simple EXE that could just do that. THe file change is simple but there are two services you need to stop first, and re-start after the file correction.

Its a simple command like STOP Service JBOSS and another one, and that shell is simple, but how do you ensure the services stops BEFORE you run the next STOP for the other service?
I need to verify that both those services stopped before i can edit the pinpad file.

In a CMD window it does give you a notice, but how would you be able to verify that from your own tool?

After the edit I need to start those two services again.
Simple, but tedious. It would be much simpler if i had a FIXPINPAD.exe that does it for me.

Any suggestions would be great.


Regards, Peter
-Regards
Peter

Pierre Bellisle

Use Services APIs,
You query the service, if it is running you call  ControlService / SERVICE_CONTROL_STOP.
You then loop: SLEEP ~10 and QueryServiceStatusEx until it return SERVICE_STOPPED. (Service may take few seconds to stop.)
You restart the service with StartService()
If run on newer than XP you will need to run as Admin.

See MS...
OpenService : CreateService
ControlService(SERVICE_CONTROL_STOP)
StartService()
QueryServiceStatusEx(SERVICE_STOPPED, SERVICE_START_PENDING, SERVICE_STOP_PENDING, SERVICE_RUNNING, SERVICE_CONTINUE_PENDING, SERVICE_PAUSE_PENDING, SERVICE_PAUSED)

I guess you can easily find some FreeBASIC demo on the web.

Petrus Vorster

Thanks Pierre!

That is what i was looking for!

Regards, Peter
-Regards
Peter