How to stop an ngrok tunnel? - command

I tried command killall ngrok, but I get 'killall' is not recognized as an internal or external command, operable program or batch file.
Shouldn't killall be coming with the ngrok? I can't find any reference to that issue on Internet.

taskkill /IM ngrok.exe /F
command in cmd will kill ngrok

Related

Input to psexec command

I am trying to run a batch file which is placed in a remote windows server from my local system.
For that I am using psexec command as shown: psexec \\ip address -u user\username -p password cmd /c "path to batch file". This is executing same way as it executes on remote windows server. but at some point we have to press Q on the command prompt to get to next line on the batch file.
this is how it looks:
on Remote system
But I am unable to press Q on my local psexec command prompt, this is how it looks:
on my local system
is there a way to take key inputs for psexec command?
Thanks in advance.
I tried providing -accepteula option and also pipe it with powershell and try running it.
But no luck on that.

Psexec is not running an EXE program remotely

Check everywhere for a reason but nothing I found matches my specific problem. I have a program in C:\somefoldername\anothersubdirectory\andanother\ of the remote pc that I try to run using PSEXEC but it does not take. PSEXEC just does not want to run anything for me. Now if I run a ping or tasklist via psexec, it works, though obviously this is in PATH.
So I am putting in:
PSEXEC \\pcname C:\somefoldername\anothersubdirectory\andanother\program.exe
and nothing happens.
I even wrote a batch script that I tried running in two different ways.
Script is just:
#ECHO OFF
C:\somefoldername\anothersubdirectory\andanother\program.exe
EXIT
and I had it copied to the remote pc's main directory (maybe I need to put it in a folder) and then I tried running C:\batch.bat using:
PSEXEC \\pcname C:\batch.bat
I also tries running:
PSEXEC \\pcname -c \\servername\batch.bat
so it copies it over to PATH.
Neither worked.
Does any program I try to run via PSEXEC have to be in the remote pc's path?
I do have to admit that I have not done running an EXE remotely, but I have written lengthier scripts using psexec that use batch file on a server without any hiccups.
What is weird to is that the program I run has parameters and I task that runs through it, so I first taskkill it remotely, then I PSEXEC the SAME EXACT EXE as:
psexec \\pcname C:\...\program.exe -a -few -parameters ODBC
and that works. When I try to open just program.exe on its own, nope doesn't take.
I also did try psexecing iexplore.exe and that didn't work either.
So gotta use the -i option. In addition to that, gotta use -p + -u or -s to load system hardware dependent gui. This is why large portions of the gui was missing, or I assume why.
Can you please try this format
psexec \\machineName -u username -p password /accepteula -h cmd /c
C://somefoldername//anothersubdirectory//andanother//program.exe >>log.txt
More Clearly
Download the PSEXEC tool zip file in your user machine and unzip it.
Open command prompt and go to the psexec path.
In my machine it is: D:\PsTools
Run following command line
Syntax:
D:\PsTools> psexec \\ip_address -u username -p Password cmd /c executablename arguments >> test.log

Stop the mosquitto (MQTT) broker from listening to a port using the command line

When I ran the Mosquitto (MQTT) broker for the first time there was no issue. But however from he second time when i ran it using default config I could not run the code successfully because of the following error:
1379497253: mosquitto version 1.2 (build date 2013-09-17 17:59:39+0530) starting
1379497253: Using default config.
1379497253: Opening ipv6 listen socket on port 1883.
1379497253: Error: Address already in use
I would like to know how to stop the broker from command line. It'll be nice if someone can help.
mosquitto starts to be a service.
sudo vi /etc/mosquitto/mosquitto.conf #more detail in `man mosquitto.conf`
sudo vi /etc/mosquitto/conf.d/custom.conf #add or change listening port as your need
sudo service mosquitto restart
If you don't know the PID, than you can use "pkill" instead of "kill" in linux.
Command: "pkill mosquitto"
You don't say which OS you are using, but assuming it's Linux and you have mosquitto running in the background, you just use the kill command.
Use ps to find the pid of the currently running mosquitto instance then kill the pid.
You can use your own batch script file like mosquit.sh in bash.
This is my script to stop it on CentOS.
#!/bin/sh
sudo kill $(ps aux |awk '/mosquitto/ {print $2}')
Assuming it's the linux service, a kill command will only stop using that particular socket, and will open up on another socket upon killing the PID. On redhat, to kill the service would be systemctl stop mosquitto
For Windows, open a Console as Administrator and use
taskkill /im <programname.exe> /f
Where /im = select by program (image) name, and /f = force -
C:\Users\bburns
> taskkill /im mosquitto.exe
ERROR: The process "mosquitto.exe" with PID 5344 could not be terminated.
Reason: This process can only be terminated forcefully (with /F option).
C:\Users\bburns
> taskkill /im mosquitto.exe /f
SUCCESS: The process "mosquitto.exe" with PID 5344 has been terminated.

psexec cannot kill cmd.exe & psexec.exe after execute

i had used a batch cmd (xxx.bat) to execute a psexec function as follows:
C:\psexec.exe \192.168.xxx.xx -u server1\admin -p password C:\xxx.bat
the above batch file can run successfully to remote execute file.
but i found that there are many cmd.exe and psexec.exe process in task manager, that the batch file cannot kill process after execute.
do you know how to kill cmd.exe and psexec.exe process after execute ?
thanks
Joe
I'm sure there's a better way, but personally, I do this using pskill, e.g.:
pskill.exe \\\\192.168.x.x -u user -p pass -t <imagename>
You can find the name of the executable that you want to kill using the pslist command, also in the pstools toolset.

Does psexec support input redirection?

I am trying to control a remote Python script via psexec, which reads commands from stdin, but I need to redirect psexec's input since psexec itself will be launched from another program. However, I have no luck making psexec accept redirected input. Is it supposed to work at all?
An example of what I'm trying to do, where input is a file containing input to the remote script:
psexec \\mymachine python c:\script.py < input
Here's one way I was able to kinda accomplish what you're after:
PsExec.exe -d \\\\192.168.1.1 cmd /k "echo list volume | diskpart"
This would pass the commands "list volume" to the diskpart command. Additionally you can also try using cmd like this for you example:
PsExec.exe -d \\\\192.168.1.1 cmd /k "python c:\script.py < input"