DOS batch file - Display popup message with two choices - windows

Using a DOS batch file I'd like to display a popup window in XP and Windows 7 where I display a message and give the user the choice to press one of two buttons - one would stop the DOS batch file, while the other button would allow it to continue.
Any hint on what dos batch command/pgm I may use?

The following WSH/VBscript snippet prompts the user to click yes/no, after which you can base logic on the response:
'enter this text into ask.vbs
dim input
input = MsgBox ("Do you want to continue?", 4)
'wscript.echo input
If input = 7 Then
'answer was no
End If
If input = 6 Then
'answer was yes
End If
Then in your batch file, call wscript ask.vbs.
However, I recommend staying in pure console for this task if you can, as choice and set can handle this nicely as Anders suggests. pause works very well too, and that's usually what I use for a binary choice like yours because it's the simplest approach.

To display an actual window you would have to call something external, a .exe or a Windows Scripting Host script.
If you want to stay in pure batch, echo the choices and use SET /P to wait for input from the user. (To support DOS and Win9x you would have to use choice and not set on those systems)

Related

how to show a dialog windows during applescript works

I wrote an applescript to convert a to b,
I want to show a dialog when script is working,
script first ask for a file and a folder from user, after this I want to show a dialog until my last dialog which say work is done.
I couldn’t find any help here or other sites regarding this way of implementing dialogs, thanks for you help.
to be clear, there is no way of having an input for steps, because it's doing a convert on one file only, but the file could be large & take some time, I'm looking for something that can input for example line of codes & progress depend on which line it's working right now or something else which start with the first line & close just before the end dialog

How to mask input with VBScript?

does anyone have an idea how to mask the InputBox in VBScript without using html (work security issues)? I'm using windows 10. Thank you very much, any help is greatly appreciated.
In VBScript you essentially have 2 options for masked input:
Using the console and a ScriptPW.Password object:
Set oInput = CreateObject("ScriptPW.Password")
WScript.StdOut.Write "Enter password: "
pw = oInput.GetPassword
Using a custom HTML dialog.
[Source]
Masking input in the builtin InputBox dialog is not possible.
ES_PASSWORD Displays an asterisk (*) for each character typed into the
edit control. This style is valid only for single-line edit controls.
Windows XP: If the edit control is from user32.dll, the default
password character is an asterisk. However, if the edit control is
from comctl32.dll version 6, the default character is a black circle.
To change the characters that is displayed, or set or clear this
style, use the EM_SETPASSWORDCHAR message.
So set the style for the contained edit box to password.
There is some C source code here
MSDN - How to Create a Single Line Edit Control
Run batch script as admin during Maven build (gives a good example of a wrapped VBScript that can be used for this purpose).

Print File(NotePad) Without the name of the file appearing in the printing document

Dim ProcessProperties As New ProcessStartInfo()
ProcessProperties.FileName = "notepad.exe"
ProcessProperties.Arguments = "/p c:/doc.txt" 'command line arguments ''
''ProcessProperties.WindowStyle = ProcessWindowStyle.Maximized
Dim myProcess As Process = Process.Start(ProcessProperties)
when printing using the code above i have "doc.txt" printed. I don't want the file name to appear when printing is over
It is not possible to pass an argument through command line to notepad to hide the header, the only parameter accepted for the /P argument is the file name. (See link)
The only way to hide the header from printing is by opening notepad and going to File->Page Setup, and changing the header command. (See link)
If it is really needed to print using a process, you can try searching for third party editing tools which support printing arguments.
Another way is to implement functionality for printing the text file, see this Stackoverflow article (Link)
You will have to configure the header and footer options of Notepad in order to prevent or override the file name appearing on the print page. This can be done by simulating user input to bring up the Page Setup dialog and clear the header and footer.
There are a number of ways to send user input (mouse and/or keyboard). For starters you could look at these two:
Windows Input Simulator
Application and Global Mouse and Keyboard Hooks .Net Libary in C#

Type a pre defined text when a shortcut key is pressed in Windows 7

I work on mainframes and don't have much knowledge about windows other than playing warcraft :-) hence pardon me if I ask something nooby/silly.
I have a requirement to enter a particular long-text in the current position of a cursor whenever a shortcut key is pressed.
I am thinking of creating a bat file and assigning a windows keyboard shortcut to the bat file and whenever I have requirement to enter the long text, I press the windows shortcut key
and the long text gets typed in the current position of the cursor.
The current position of the cursor can be in any application, like Excel, Word or notepad or Windows dialog prompts.
Could you please let me know if this is possible and point me where I could get some information about this "technique".
Thanks & Regards,
Vasanth.S
To make a single key combo do what you are asking, you may need another program. You can make a link to a batch file, hook up a shortcut and then use the clip command to copy text from a file onto the clipboard. That would require the shortcut and then a Ctrl+V to paste. The batch file would look like this:
clip < c:\SomeDir\sometext.txt
You might like to look at using a clipboard manager - which saves a history of clipboard entries, can search for an entry, and paste it at the cursor.
Ditto and CLCL are both useful and free - which one you use depends on your windows version.
They are hotkey driven for ease of use, but mouse can be used.

How to stop gnuplot window poping-up when using it from command line in windows?

I am using perl to open a pipe to pgnuplot.exe to output plot commands. For example,
open ($PLOT, "|pgnuplot") or die "error: gnuplot not found!";
print $PLOT <<EOPLOT;
set term postscript eps enhanced "Arial" 20
set output "somefile.eps"
## do some plotting here ##
EOPLOT
close $PLOT;
I notice that a window for gnuplot always pops up and grabs the focus of my mouse and keyboard momentarily. This makes it difficult to use the computer while the plot script is running.
Is there any way to stop pgnuplot from opening a window?
Yes, when starting a program in Windows (CreateProcess API) it is possible to request that the main window be hidden or minimized without focus (among other options). But I don't know whether perl provides a easy way to do that.
You might consider using batch operation instead (put your plot commands in a file, then pass the filename to gnuplot).
You can prevent showing child console windows via Win32 module:
use Win32;
Win32::SetChildShowWindow(0);

Resources