Jump to content

How can I pop up a message from a shell command?


Recommended Posts

Guest Robbie Hatley
Posted

I have a program that can open certain types of files (such as

yenc-encoded data files) only from within itself, one of the reasons

being that such files have no standard extension, hence the program

requires the user to specify operations to be performed by clicking

one of several buttons in the program's GUI, before opening the file.

 

Hence trying to use file associations ("MyProg.exe" "%1") won't work,

because the program has no idea of WHAT you want to do with the

file after opening it.

 

SO, I put a reminder line in the shell in the registry, like so:

 

KEY: VALUE:

HKEY_CLASSES_ROOT

.ntx (default) = "yenc_data_file"

yenc_data_file (default) = "Yenc-Encoded Data File"

shell (default) = "launch_myprog"

launch_myprog (default) = "Plz launch MyProg manually."

command (default) = "" [empty string]

 

Since the command is an empty string, clicking it pops up a std

Windows error message:

 

"This file does not have a program associated with it for

performing this action. Create an association in the

Folder Options control panel."

 

Which is invalid advice, because file associations simply cannot

work in this situation.

 

SO, how do i pop up my OWN message instead, say:

 

"This file cannot be opened through the shell. Please

launch MyProg manually, specify action to be performed,

then navigate to the file from within MyProg."

 

Preferably this would be accompanied by the "Critical Stop" event

sound (which, on my computer, is Hal9000 saying "Sorry Dave, I'm

afraid I can't do that".)

 

Basically, I'm asking if there is a service available in Win2K

which can pop up message boxes with user defined text, either

via registry shell commands, or from within scripts or programs?

(Simultaneously playing a selectable event sound would be a bonus.)

 

Or perhaps there is a way to access the MessageBox API (I think

it's in user32.dll?) more directly? I could do that from within

a C program, but I don't know how to do it from within the registry.

 

--

Cheers,

Robbie Hatley

lonewolf aatt well dott com

www dott well dott com slant user slant lonewolf slant

  • Replies 3
  • Created
  • Last Reply
Guest Pegasus \(MVP\)
Posted

Re: How can I pop up a message from a shell command?

 

 

"Robbie Hatley" <lonewolf@well.com> wrote in message

news:4Midnf_288g5uQnVnZ2dnUVZ_vednZ2d@giganews.com...

>

> I have a program that can open certain types of files (such as

> yenc-encoded data files) only from within itself, one of the reasons

> being that such files have no standard extension, hence the program

> requires the user to specify operations to be performed by clicking

> one of several buttons in the program's GUI, before opening the file.

>

> Hence trying to use file associations ("MyProg.exe" "%1") won't work,

> because the program has no idea of WHAT you want to do with the

> file after opening it.

>

> SO, I put a reminder line in the shell in the registry, like so:

>

> KEY: VALUE:

> HKEY_CLASSES_ROOT

> .ntx (default) = "yenc_data_file"

> yenc_data_file (default) = "Yenc-Encoded Data File"

> shell (default) = "launch_myprog"

> launch_myprog (default) = "Plz launch MyProg manually."

> command (default) = "" [empty string]

>

> Since the command is an empty string, clicking it pops up a std

> Windows error message:

>

> "This file does not have a program associated with it for

> performing this action. Create an association in the

> Folder Options control panel."

>

> Which is invalid advice, because file associations simply cannot

> work in this situation.

>

> SO, how do i pop up my OWN message instead, say:

>

> "This file cannot be opened through the shell. Please

> launch MyProg manually, specify action to be performed,

> then navigate to the file from within MyProg."

>

> Preferably this would be accompanied by the "Critical Stop" event

> sound (which, on my computer, is Hal9000 saying "Sorry Dave, I'm

> afraid I can't do that".)

>

> Basically, I'm asking if there is a service available in Win2K

> which can pop up message boxes with user defined text, either

> via registry shell commands, or from within scripts or programs?

> (Simultaneously playing a selectable event sound would be a bonus.)

>

> Or perhaps there is a way to access the MessageBox API (I think

> it's in user32.dll?) more directly? I could do that from within

> a C program, but I don't know how to do it from within the registry.

>

> --

> Cheers,

> Robbie Hatley

> lonewolf aatt well dott com

> www dott well dott com slant user slant lonewolf slant

 

You can set "command" to this string: wscript c:\winnt\msg.vbs

then put the following lines into c:\winnt\msg.vbs:

CR = chr(10)

Set objArgs = WScript.Arguments

if objArgs.count > 0 then parm = objArgs(0) else parm="this program"

msgbox "This file cannot be opened through the shell. " & CR & CR _

& "Please launch MyProg manually, specify action to be performed," & CR _

& "then navigate to the file from within " & parm & ".", 0, _

"File Association Notice"

Guest Robbie Hatley
Posted

Re: How can I pop up a message from a shell command?

 

 

I'd asked:

> > Basically, I'm asking if there is a service available in Win2K

> > which can pop up message boxes with user defined text, either

> > via registry shell commands, or from within scripts or programs?

> > (Simultaneously playing a selectable event sound would be a bonus.)

 

and "Pegasus (MVP)" replied:

> You can set "command" to this string: wscript c:\winnt\msg.vbs

> then put the following lines into c:\winnt\msg.vbs:

> CR = chr(10)

> Set objArgs = WScript.Arguments

> if objArgs.count > 0 then parm = objArgs(0) else parm="this program"

> msgbox "This file cannot be opened through the shell. " & CR & CR _

> & "Please launch MyProg manually, specify action to be performed," & CR _

> & "then navigate to the file from within " & parm & ".", 0, _

> "File Association Notice"

 

Excellent! Yes, that works great. Thanks for the solution!

 

I did tweak it slightly. On researching msgbox, i found that if

I change the "0" to "16", it plays the "Critical Stop" event sound,

exactly as desired. :-)

 

Thanks!

 

--

Cheers,

Robbie Hatley

lonewolf aatt well dott com

www dott well dott com slant user slant lonewolf slant

Guest Pegasus \(MVP\)
Posted

Re: How can I pop up a message from a shell command?

 

 

"Robbie Hatley" <lonewolf@well.com> wrote in message

news:GsydnYlHop7rRAXVnZ2dnUVZ_rjinZ2d@giganews.com...

>

> I'd asked:

>

>> > Basically, I'm asking if there is a service available in Win2K

>> > which can pop up message boxes with user defined text, either

>> > via registry shell commands, or from within scripts or programs?

>> > (Simultaneously playing a selectable event sound would be a bonus.)

>

> and "Pegasus (MVP)" replied:

>

>> You can set "command" to this string: wscript c:\winnt\msg.vbs

>> then put the following lines into c:\winnt\msg.vbs:

>> CR = chr(10)

>> Set objArgs = WScript.Arguments

>> if objArgs.count > 0 then parm = objArgs(0) else parm="this program"

>> msgbox "This file cannot be opened through the shell. " & CR & CR _

>> & "Please launch MyProg manually, specify action to be performed," & CR

>> _

>> & "then navigate to the file from within " & parm & ".", 0, _

>> "File Association Notice"

>

> Excellent! Yes, that works great. Thanks for the solution!

>

> I did tweak it slightly. On researching msgbox, i found that if

> I change the "0" to "16", it plays the "Critical Stop" event sound,

> exactly as desired. :-)

>

> Thanks!

>

> --

> Cheers,

> Robbie Hatley

 

Thanks for the feedback.


×
×
  • Create New...