I have a simple VBScript, which executes a batch file in the background. It starts correctly and it's working, but I can't stop it.
I already checked all of these answers, but I have no cscript.exe and no wscript.exe running
Any ideas?
You could try adding an "exit" statement at the end of your batch as long as you don't need to visually see the results (you could just write them to a text file). Just saying, in case you're experiencing this problem in the future.
Related
This question already has answers here:
Prevent VBscript app from showing Console Window
(1 answer)
How can I run a command silently in VBScript? [duplicate]
(1 answer)
Closed 3 years ago.
I need to run this old telnet scripting client silently in the background. You run it from cmd providing arguments for:
1- a file containing the commands to send
2- a file where to print any output
3- whether to run it minimized to taskbar or not
(note: if it is run without arguments, it displays a help window)
So this is what I type in cmd, and it works like a charm:
TST10.exe /r:mycommands.txt /o:myoutputfile.txt /m
What I can't achieve however, is running it completely hidden in the background. Now, since this program requires arguments, I tried to first achieve this only on the help window that gets spawned (ie: running it without arguments).
I tried with VBScripts using carefully all the answers here. It always starts normally (not hidden). These VBScripts all succeed to hide other programs though.
I also tried with this program that starts processes hidden, oddly enough it only succeeds in hiding the the telnet client from the taskbar. Also, even if it would completely hide it, I still have no idea on how to pass the mentioned arguments.
edit:
How is this even CLOSE to "Prevent VBscript app from showing Console Window" or "How can I run a command silently in VBScript?"? This question VERY clearly asks how to run a normal .exe program in a hidden manner which is not even slightly related to running a VBscript without showing the console or running a command silently in VBScript. + I even stated that the only way to achieve this USING VBScipt (not hiding a VBScript itself) doesn't work. Are the accounts marking this as duplicate bots that simply detect "VBScript" and "hide program" and assume that I want to hide an executing VBScript? Or can they simply not understand English?
Try this... create a run.js or something (make sure you give it a .js extension). Place this line inside the .js:
WScript.CreateObject("WScript.Shell").Run("notepad.exe", 0);
Run it. You should see notepad.exe running in your task manager, but it's window should be hidden. Now try the same with your app instead.
When I am running batch file through LabVIEW by using System Exec.vi, two cmd windows are appearing. The second one executes command of the batch file and closes after that, while the first one doesn't close. I have tried to use this solution, but it doesn't work. Is there any way to close that first cmd ?
P.S. If I run batch file not through LabVIEW, but just by double clicking on it, two cmd windows close after execution
It's hard to tell, but I think you've misunderstood the directions given at that link. The batch file should contain the executable and its options, but you just pass the batch file to the System Exec VI. I'm guessing what's happening here is the batch file is getting called twice, and some process that the first call depends on is getting hijacked by the second call, so that when the process ends, the second call gets notified and stops itself, but the first call is left hanging. Or something like that.
I am using nant, but this can apply to any thing, I just want to know if there is a way to set windows cmd or console2 or some kind of shell to give me a popup or make a noise when it is "finished" (i.e. when it is waiting and the screen says >C:\User\Random_FILE_PATH>_)
I'm using windows 7.
Valentine
sorry, to clarify, I am not running a script that I created, this is just when running anything in the console. I would like it to be that anytime my console is waiting for me it creates a pop up or a noise. This would ideally be some kind of setting
You may open a message box in the end of your batch file, using WSH with a simple VBScript or JScript. See Show a popup/message box from a Windows batch file for an example.
c:\> my_command & mshta.exe vbscript:Execute("msgbox ""finished"",0,""finished"":close")
this here uses conditional execution - when my_command is finished the mshta.exe will be executed with arguments in the brackets.As the parameter passing here is not so easy the string given to msgbox will not be displayed.
you can add a beep to your prompt:
set prompt=%prompt%^G
Don't type ^G. To get it, keep your alt-key pressed while entering 0 0 7 on your numeric keyboard.
When i click on a .rb file to run it a CMD window pops up for a brief second and then closes again. This is probably a really nooby question thats easily fixed but i've looked everywhere for help. But like i said it pops up for a brief second and i THINK while its up its executing the code but when the codes done it closes so i don't know if i'm making mistakes in code or other important things like that.
Run the program through the command prompt (CMD), that way you can see the result, otherwise the window closes when the program exits.
Alternatively, you can prevent the program from exiting by putting some sort of blocking instruction at the end of the script, such that the program waits for user input before exiting.
Press Windows_Key+R and then type CMD. Browse to the location of the file and then type ruby your_ruby_file.rb. The program is running, but Windows automatically closes the window upon completion of the command.
To get Windows to run your *.rb files through Ruby when you click on them in the UI, you have to associate the .rb extension with the ruby.exe executable. Such an association is called a "Windows File Association." Here's a Microsoft Knowledge Base article that'll tell you how to create such a thing.
http://support.microsoft.com/kb/307859
There is a VB6 application. It can be run with command line parameters to create some report in a text file.
The problem is that when started from a batch file, application returns control immediately, so the following commands start executing. I need these following commands to wait until the VB6 app finishes its work.
How to achieve that?
The Start command has a wait switch which does exactly what you want.
c:\start /w notepad
You could rewrite the VB6 program as a console application.