How to run DOS/CMD/Command Prompt commands from VB.NET and want to hold its terminal output for few seconds. After that it should be close automatically.
Depending on your goal, there could be multiple solutions to this request.
This SO post details how you can run a command from cmd.exe, passing arguments.
How to run DOS/CMD/Command Prompt commands from VB.NET?
Another idea, depending on the goal, would be to save the cmd as a batch file or similar, where you could have a pause or timed wait before the cmd window closes.
Then you could call the batch file from vb.net
I don't want to dive too deep into how each of these would be done without knowing more about the goal at hand.
I have a VB application which is scheduled. It focuses on some cmd windows and performs sendkey actions. This works fine when I have the RDP session open, it's only when I disconnect (not logoff) that the issue occurs. (This task is running on a virtualised server).
When I open the RDP session again after the task has ran, the application has thrown an error regarding the login permissions. I presume this is because the user is locked and therefore can't perform the actions?
I need to find a way around this, any help is much appreciated!
Don't use SendKeys.
Instead, if you have a program running in a command prompt, make sure the VB.NET program is the one to open it (or them) with Process.Start, and set the RedirectStandardInput property of the ProcessStartInfo object you pass to True. Then pass commands into the process's StandardInput property as though writing to a file.
This will avoid any focus-change problems, any problems to do with locked screen sessions, most if not all potential problems with integrity levels, most if not all problems with timing, and probably some other stuff I'm not thinking of.
I need help with this autoit script
It's close a tcp\udp connection of a process without killing the process
I found script in a forum but it's not working
let's say I want to close any connection established from "internet download manager"
so I put in process name
$processname = "IDMan.exe"
but it still not working !!
I guess some thing wrong in the code
Second : I want to but a WHILE loop to kill the process connection whenever it started
how can I do that
Here is the script without modifications
Link to script
sorry I tried to put the script source here but I failed
What you need is an Admin Rights.
Add this to the top of your script
#RequireAdmin
You can use CloseTCPConnectionByProcessName in a while loop, just add some sleep to keep it stable.
I'm looking for a way to run a program when locking the screen in Fedora 15 (linux). Basically I want to start running a motion detection program when the screen locks, or I manually hit Ctrl+Alt+L, but I don't know what commands are being run or where to alias my own intermediate step in. I assume it's:
gnome-screensaver-command --lock
but am not sure how to go about this. Anybody know how, or a direction to start looking in?
Edit, since link was in a comment:
This is done with dbus-monitor and described here.
The dbus system advertises screen locking; monitor for ActiveChanged on org.gnome.ScreenSaver. (see http://people.gnome.org/~mccann/gnome-screensaver/docs/gnome-screensaver.html )
e.g. (word-wrapped for clarity)
signal sender=:1.68 -> dest=(null destination)
serial=53 path=/org/gnome/ScreenSaver;
interface=org.gnome.ScreenSaver; member=ActiveChanged
boolean true
Unfortunately, this will require writing more code than just a shell script, I'm afraid; although I'd be curious if you could ask dbus to call your program as a handler for that signal, somehow; otherwise, I suppose you'd just start a daemon process and listen for that signal to be broadcast…
The question is special because some keys, such as CTRL+Z, stopped working.
I tried to put the process to background by typing in the order:
find /
CTRL+Z
bg
However, I can still see the stdout. The only difference to only doing the first step is that the command CTRL+Z does not work anymore. It is rather nasty when I have unsaved jobs and my harddrive is over 100GB. So
how can I put the process to background?
[Details]
I am using the fourth version of Bash on Mac.
[Crux Reply by Nicholas Riley]
The problem is really that I do not understand the "ramifications" of running process background. I cannot understand why the commnands, such as CTRL+Z, do not work to background processes. I was still able to kill the process in another shell with the command:
ps -ej | awk '! /grep/ && /find/ {print $2}' | xargs kill -9
^Z isn't working because the frontmost job is now the shell, and shells don't usually respond to SIGTSTP. (If you do really want to suspend a non-login shell, suspend usually works.)
The problem seems to be you misunderstand the ramifications of a job being in the background. Redirecting the job's standard output is unrelated.
In fact, it's unclear what you want to do. If you just want to stop find from running, then fg it and use ^C or ^\ (which by default send SIGINT and SIGQUIT respectively).
If you want to keep find running but suppress its further output, then the easiest solution I can think of is to use bg ; disown ; exit. That will stop the shell from killing its child process (find) and exit the shell; assuming it's at the top level of the Terminal window, you'll see a bit more output and find will keep running (but you'll have no way to interact with it).
I use disown.
find / & disown
exit # close the terminal and the command still runs
You can use disown after you ^Z as well:
find /
^Z
bg
disown
exit
disown is a bash builtin, I believe. Not sure about alternatives for other shells.
For further information, see my equivalent answer on Server Fault.
You can set the operation to a different key with stty on any UNIX-like system.
$ stty susp Q
will make Q your suspend key in place of CTRL-Z.
Backgrounding a process will not disconnect the output from the terminal device, that's why you're still seeing output and the output may well contain control characters which can stuff up your TTY settings (cating binary files is a good way to do that).
If you want the job to run in the background, do it right:
find / >/tmp/out 2>&1 &
then examine the /tmp/out file when it's finished.
I usually do this kind of thing with nohup. Like this:
nohup find / > /tmp/myresults.txt &
nohup makes sure that the process doesn't stop, even if the console goes away (like, you close the window or lose your SSH or whatever). The ">" sends output to a file rather than to the console, and "&" puts the job in the background.
I'll assume you're using a common variant of Linux or UNIX and possibly the bash shell. In which case:
CTRL-Z sends the SIGTSTP signal to the foreground process. You should be able to do the same thing with the kill command by specifying kill -s SIGTSTP [pid].
I know that in Ubuntu 9.04, you can start the process with a & after it to run it in the background. For example, "sudo gedit /boot/grub/menu.lst &" will start a text editor editing the GRUB config file in the background.
kill -STOP your_pid_here
from another console window?
http://tombuntu.com/index.php/2007/11/23/how-to-pause-a-linux-process/#comment-132413