Hello. I'm creating a GUI for Discord Bots and I want to know why is my program crashing when the instance of Node.JS is running. What I mean by this is that when you press the button on the form to execute the server/bot, the app hangs up.
I'm using the "Process()" way to open an app/exe, and there's a property that it's called ".CreateNoWindow". So yeah. When you put this property to "False", a console window from where the server is running is shown up. And when I closed it, I managed to see the message that I programmed to show up when the bot logs in to the Discord API, which was a great message to me. But the bot wasn't online on my private server, so I decided to mess around with the configuration of the "ProcessStartInfo". But no success.
Anyways, I'll let you in the "What have you tried?" a download to the ZIP that contains my Visual Studio 2019 Solution and the files needed to start the bot so somebody on this platform can help me with this.
The contents on the folder "nodejs" should go in the "nodejs" folder located at %ProgramFiles%\nodejs\
the file "token.tkn" is really a renamed .txt file that I coded to create and modify.
Please DON'T touch the "SECRET TOKEN (CLICK ME)" button. If you do, please do Alt + F4 and nothing should happen. I just want to make the program respond when the bot is on.
What I have tried:
Solution+Bot stuff[
^] <--- I'll still let it there.
Public Class Form1
Private Sub Label4_Click(sender As Object, e As EventArgs) Handles Label4.Click
Form2.Show()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
statusLabel.Text = "OK"
statusLabel.ForeColor = Color.Lime
Dim bot = New Process With {
.StartInfo = New ProcessStartInfo With {
.FileName = "node.exe",
.Arguments = "bot\main.js",
.UseShellExecute = False,
.RedirectStandardOutput = True,
.CreateNoWindow = True
}
}
bot.Start()
While Not bot.StandardOutput.EndOfStream
Dim botOutput As String = bot.StandardOutput.ReadLine()
TextBox1.Text = botOutput
End While
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
MsgBox("Make sure that you have Node.js installed in the default route. If not, please re-install.")
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
MsgBox("Made by joveaaron in 2021. Due to the importance of the Tokens, I'm just gonna give the source code to people with good reputation. In order to stop the token stealing. This is a completely free program. If you paid for this, contact me inmediately at joveaaron.yt@gmail.com.")
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
statusLabel.Text = "Stopped"
statusLabel.ForeColor = Color.Red
Dim stopbot = New Process With {
.StartInfo = New ProcessStartInfo With {
.FileName = "taskkill.exe",
.Arguments = "/IM node.exe"}}
End Sub
End Class