Jump to content

.vbs MsgBox help


Recommended Posts

Here my script so far

x=MsgBox("Run New Process Notifier",vbYesNo+vbDefaultButton2, "New Process Notifier")

Its a simple msgbox with yes or no, How do i add commands to the answer?

I would like no to just exit and yes to start/open a app.

Please advise.

Cheers, James

Link to comment
Share on other sites


Take a look at this example:

Sub Append
Dim Answer
Answer = MsgBox("Do you want to calculate?",1,"calculate")
If Answer = 1 Then
objshell.run("calc.exe"),0
Else
Exit Sub
End If
End Sub

So you need to determine what all the return values are and put them in the else if you want something "else" to happen if you click Cancel.

Link to comment
Share on other sites

Or another way of doing it, with code only for yes


If MsgBox( _
"Would You Like To Open Notepad?",4132,"Yes No Notepad") = 6 Then
CreateObject("Wscript.Shell").Run("Notepad"),1,False
End If

Msgbox with a timer to close after 5 seconds with code only for yes


Dim Act :Set Act = CreateObject("Wscript.Shell")
If Act.Popup( _
"Would You Like To Open Notepad?" & vbCrLf & _
"If Nothing Is Selected In Five" & vbCrLf & _
"Seconds This Dialog Will Close", 5,"Yes No Self Close", 4132) = 6 Then
Act.Run("Notepad"),1,False
End If

Link to comment
Share on other sites

Yea thats working great!!!

I stead of opening 'Notepad' how can i change it???

If MsgBox( _
"Run New Process Notifier?",4132,"New Process Notifier") = 6 Then
CreateObject("Wscript.Shell").Run("C:\Program Files\New Process Notifier\NewProcessNotifier.exe"),1,False
End If

The above is not working.

Cheers, James

EDIT- So now ive got the app opening with 'yes' because i put the .vbs in the same folder as the app [school boy error]

Msgbox.jpg

With this code

If MsgBox( _
"Run New Process Notifier?",4132,"New Process Notifier") = 6 Then
CreateObject("Wscript.Shell").Run("NewProcessNotifier"),1,False
End If

As you can see from the picture ive got a 'startup.reg' file thats adds the .vbs file to windows startup [this is done with winrar sfx], the only thing is when windows startsup the box comes up which is great but the .vbs finds an error

MsgboxError.jpg

If i go and run the .vbs file everything works great, Just cant get my head round why when it start from startup it fails its the same file that opens!!! Ahh

Cheers, James

Edited by jamesbebby
Link to comment
Share on other sites

I thnk the problem is you need a full path to app and it full name

Run("NewProcessNotifier")

This might work

Run("DriveLetter\FolderName\NewProcessNotifier.exe")

This only ways this would work if the app in \Windows Folder Or \Windows\System32 folder

Run("Notepad")

Or the VBS file is in the same location as the app.

Link to comment
Share on other sites

This is not working.....

If MsgBox( _
"Run New Process Notifier?",4132,"New Process Notifier") = 6 Then
CreateObject("Wscript.Shell").Run("C:\Program Files\New Process Notifier\NewProcessNotifier.exe"),1,False
End If

Cheers, James

Link to comment
Share on other sites

Try this:

If MsgBox( _
"Run New Process Notifier?",4132,"New Process Notifier") = 6 Then
CreateObject("Wscript.Shell").Run("""C:\Program Files\New Process Notifier\NewProcessNotifier.exe"""),1,False
End If

Spaces in the path/file names require additional quotes.

Link to comment
Share on other sites

Try this:

If MsgBox( _
"Run New Process Notifier?",4132,"New Process Notifier") = 6 Then
CreateObject("Wscript.Shell").Run("""C:\Program Files\New Process Notifier\NewProcessNotifier.exe"""),1,False
End If

Spaces in the path/file names require additional quotes.

You have just live up to your name 'Scr1ptW1zard'!!! [with-me anyway lol]

Thanks, James

Edited by jamesbebby
Link to comment
Share on other sites

Another way, Chr(34) = "


If MsgBox( _ "Run New Process Notifier?",4132,"New Process Notifier") = 6 Then
CreateObject("Wscript.Shell").Run(Chr(34) & "C:\Program Files\New Process Notifier\NewProcessNotifier.exe" & Chr(34)),1,False
End If

Link to comment
Share on other sites

As a result of the formatting error on the above post, I thought I'd post it again, this time concatenating the line which required it.

If MsgBox("Run New Process Notifier?",4132,"New Process Notifier") = 6 Then
CreateObject("Wscript.Shell").Run(Chr(34) & "C:\Program Files\" & _
"New Process Notifier\NewProcessNotifier.exe" & Chr(34)),1,False
End If

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...