views:

7236

answers:

8

I'm kind of going through DOS again and it's been ages, so I need a lot of help.

My question is; how can I make a batch file open a popup screen? Like: alt text

Sorry for the poor English, I'm Dutch/Italian >.<

+1  A: 

You can't, not unless you have a small program that displays a messagebox and run that.

You could open a console window that displays a prompt though, but getting a GUI message box is not possible, AFAIK.

Marcus Lindblom
a prompt might do it...do you have more on that?
billyy
echo "xx", pause, or set /p var=prompt are cmd.exe options
Marcus Lindblom
+7  A: 

I would make a very simple VBScript file and call it using CScript to parse the command line parameters.

Something like the following saved in MessageBox.vbs:

Set objArgs = WScript.Arguments
messageText = objArgs(0)
MsgBox messageText

Which you would call like:

cscript MessageBox.vbs "This will be shown in a popup."

MsgBox reference if you are interested in going this route.

boflynn
would this work in fullscreen mode too?
devio
thanks that would do it, ill create a file write this data to it, and than use it, than delete it. should work fine :)
billyy
+1  A: 

:

echo my popup message
pause

;)

devio
that does just echo the text...
billyy
+7  A: 

First of all, DOS has nothing to do with it, you probably want a Windows command line solution (again: no DOS, pure Windows, just not a Window, but a Console).

You can either use the VBScript method provided by boflynn or you can mis-use net send or msg:

net send localhost Some message to display

for old versions of Windows. This does depend on the Messenger service to run, though.

msg "%username%" Some message to display

for newer versions (XP and onward, apparently).

Joey
You can use env variables to get the local user - %USERNAME%. msg.exe is on my XP Home machine, but I've heard anecdotal accounts that it isn't on every version of Vista. I believe the service behind NET SEND is disabled these days.
McDowell
Right, thanks, forgot the envvar (seldom use anything beyond %UserProfile% and my own defined ones in batches :)). Funny, though, you're right about the Messenger service. It doesn't even exist on my XP VM, but net send still exists. msg.exe works there, though.
Joey
i tought it was clear that i used boflynn's solution since i chose it...
billyy
I thought a viable option was missing from the answers and provided it. Nothing wrong here. Neither do you need to feel forced to do something nor am I somehow saying that boflynn's wrong. I was just adding another option which should be perfectly fine for questions that do not have a single definitive answer. Furthermore, you're probably not the only one with this question and others may not want to use VBScript for whichever reasons. This is a community site, not solely yours :-)
Joey
I for myself just used this to spawn an "I love you" message on my girlfriend's PC from a remote shell.
Camilo Martin
+9  A: 

This will pop-up another Command Prompt window:

START CMD /C "ECHO My Popup Message && PAUSE"
Dave Webb
awesome ty!i might use this in a few other scripts :)
billyy
A: 

I don't remember for sure but I'm pretty sure I've seen a 'msg' command in a batch file before.

A: 

Try :

Msg * "insert your message here" 

If you are using Windows XP's command.com, this will open a message box.

Opening a new cmd window isn't quite what you were asking for, I gather. You could also use VBScript, and use this with your .bat file. You would open it from the bat file with this command:

cd C:\"location of vbscript"

What this does is change the directory command.com will search for files from, then on the next line:

"insert name of your vbscript here".vbs

Then you create a new Notepad document, type in

<script type="text/vbscript">
    MsgBox "your text here"
</script>

You would then save this as a .vbs file (by putting ".vbs" at the end of the filename), save as "All Files" in the drop down box below the file name (so it doesn't save as .txt), then click Save ^_^

(Apologies if I got that wrong, my VBScript is a little rusty xD)

If you have any queries with this, just ask at [email protected]. (Note it may take a while for a response, I check my e-mail once a day.)

A: 

I use a utility named msgbox.exe from here: http://www.paulsadowski.com/WSH/cmdprogs.htm

zhongshu