August 06, 2020, 02:45:46 pm

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Windows Service in IWB

Started by Andy, September 11, 2016, 04:58:39 am

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy

September 11, 2016, 04:58:39 am Last Edit: September 11, 2016, 05:29:51 am by Andy
After getting very close, and with Jalih's help, I've managed to create, run, and delete a program built as a windows service.

So here goes....

Step 1.
I created a folder on my C drive called "Services" i.e. C:\Services (if you want to try this then I suggest you create a folder with the same name as above on your C drive - otherwise you will have to amend the paths in the three programs and the .rc file accordingly).

Step 2.
Compile (but do not run yet) createservice.iwb and deleteservice.iwb as single files (not projects).

Step 3.
Open the "myserviceprog" project and build it.

Step 4.
Run createservice.exe as an Administrator to create and run myserviceprog as a service.

Step 5.
Open task manager and click on "Processes" (at least in win 10) under "Background Processes", you should see "IWB Service Program" listed.

Step 6.
Now click on the "Services" tab, scroll down and you should see an entry that says.. "IWBrules" with a Description "IWBDisplayName".

The service should be running.

Step 7.
Right click on it, and select "Stop".

Step 8.
Run deleteservice.exe as an Administrator to delete the service.
If all goes well, the service is no more.

The service program "myserviceprog.exe" produces a log file which you can find in the folder C:\Services\log.txt

Note - myserviceprog.exe is built as a project so that we can add in a display name and icon under "Background Processes" using a resource file (myserviceprog.rc).

If you've followed the steps above correctly, you should be able to create, run, and delete this example service.

I've zipped up the files needed - see attached.

Let me know what you think please....

Andy,
:)


Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Andy

Just in case anyone missed this, attached is how to enumerate windows services.

Special thanks to Jalih for helping me out with windows services.

Compile and run as Admin!

Thanks,
Andy.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.