FKLC / WhatsAppToDiscord

WhatsAppToDiscord is a Discord bot that uses WhatsApp Web as a bridge between Discord and WhatsApp.
https://fklc.github.io/WhatsAppToDiscord/
MIT License
239 stars 67 forks source link

Work as Windows Service or Scheduled Task #110

Closed HClausing closed 1 year ago

HClausing commented 1 year ago

Is your feature request related to a problem? Please describe. Not really, maybe it's a new feature.

Describe the solution you'd like I've tried to create a scheduled task on m company's server to start the WA2DC.exe on starts (without any user logged). The application starts and creates a process ID, but didn't connects the Bot on discord, neither writes anything on log.

I really don't know if it's waiting for a token. Tried with many server users: My own account, administrator, system,etc.

Maybe working as windows service could it works? I'm a donet dev and don't know anything about this project framework (I guess it's node.js) and don't figure how to create a windows service that hosts this app.

Can you help me on this?

Describe alternatives you've considered I've read some articles on the internet about services and scheduled tasks, but didn't found anything relevant.

Additional context Thanks

KungFuCookie commented 1 year ago

Have you tried running the .exe from powershell or command line to get it up and running so you can authorise the token etc?

Also, Have you tried running the process on your local machine to figure out the authentication process and make sure the bot has require permissions in discord?

I would get it all working locally before attempting to auto run on a vm. I also use scheduled tasks at work and I think you have the right idea, but would advise walking before running if you know what I mean..

HClausing commented 1 year ago

Yes, running the .exe from my user logged on server (from terminal services), it works fine (without requesting the token again), but on scheduled tasks I can't see any error on logs.txt. The process is visible on Task Manager, but the BOT won't go online on discord server.

Everything works fine if I manually run the .exe from my logged user on (OS) server. I'm trying just to automate the execution without having any user logged.

The problem with this way is the need of keeping my user logged on (OS) server to run WA2DC.exe and there's a policy on the organization to logoff inactive users after some time.

spookycookie27 commented 1 year ago

I think there is an option to click saying 'run even when user is not logged in' , have you tried this? Ill connect to my work vpn and send you some screenshots if you think it will help.

And it works fine running the exe from commaind line yeah?

this is same user (kungfu Cookie) , i have 2 github accounts

HClausing commented 1 year ago

I think there is an option to click saying 'run even when user is not logged in' , have you tried this? Ill connect to my work vpn and send you some screenshots if you think it will help.

And it works fine running the exe from commaind line yeah?

this is same user (kungfu Cookie) , i have 2 github accounts

Actually I already tried this way ("run even when user is not logged in").

Running from command line it works also.

image

image

Thanks for the help. I'll try a bit more from scheduled tasks, I think it should work.

KungFuCookie commented 1 year ago

is the command being run from the task action - to a fully qualified path?

like c://some/path/WA2DCFolder/WA2DC.exe

I agree I think it should work, your VM works manually, so should also work when kicked off via a task's action. In the windows event log, you should find a trace of the task failing I think, so my guess is the path to the exe might be wrong.

HClausing commented 1 year ago

I've created a start.bat to call WA2DC.exe, and set it on a Scheduled Task.

Now it's working. I really don't know whats the diference of running from a .bat file and directly on .exe, but the show must go on.

Many thanks for help!

By the way, you've made a very good job! Congratulations!