Codementor Events

How and why I built A Windows Service (Virtual office assistant)

Published Jul 06, 2018
How and why I built A Windows Service (Virtual office assistant)

About me

I am a Developer at a Firm, I have a BS degree in Computer Science. (Enough about me, lets proceed to topic) When learning .Net Development in the last days of my academic career, I came to know about the "Windows service." Loving thing about the Windows Service is "They are behind the Scene (Background Process), but do a lot of handy Stuff".

The problem I wanted to solve

Motivation arise when I was thinking of how to have a virtual assistant at my office 😃 who can do small things, copy paste some dlls, schedule some jobs, start some servers etc... as I am too good at forgetting things at the last moment 😦

What is A Windows Service (Virtual Office assistant)?

Then I built the Windows Service, which can really perform duties as a virtual assistant. The most important thing I needed was "A growing virtual assistant" who can develop himself from time to time.

Tech stack

Choosing a tech stack was not that much difficult for me at that time, because I just needed it for the office, where all of the systems have windows OS. Therefore, I chose to develop using C#.Net.

The process of building A Windows Service (Virtual Office assistant)

First thing was to think about the sending commands remotely. Initially, I thought to have my own protocol for communication but then realized I did not want to re-invent the wheel; And I was looking for a protocol with a wider scope. Finally decided, a windows service that can process any batch command and can perform all duties of being a virtual assistant.

Challenges I faced

In its initial requirements, it has no challenges. The idea was to keep the Commands.txt file, which is synced online from a drive. Windows service will read the commands, execute the commands, and write commands output to the file Output.txt.

The challenge was how to make windows service self improving. By self improving, I mean that, service downloads its own code changes, builds itself and deploy itself with new changes...(Wooooohhhhh... How???)

Here batch scripting helped me, windows service runs a batch script after a fixed interval which downloads, builds, and starts the service with new Code Changes.

Key learnings

I learned that if you are a developer, there can never be a problem without a solution. The difficulty is to find an optimized one with a less effort...
I could have built a large software for this problem, but achieved my goal using 150 lines of code only 😃

Tips and advice

Don't Re-invent the Wheel.
Keep things as simple as you can.

Final thoughts and next steps

Thoughts are not final yet but thinking to have some event driven mechanism to run commands and to update the service. Right now there are timers after which service reads the commands like polling (So thinking to make event driven rather than polling).

Discover and read more posts from Sajjid Atta
get started
post commentsBe the first to share your opinion
Show more replies