jamesbebby Posted April 7, 2011 Share Posted April 7, 2011 Here my script so farx=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 More sharing options...
Tripredacus Posted April 7, 2011 Share Posted April 7, 2011 Take a look at this example:Sub AppendDim Answer Answer = MsgBox("Do you want to calculate?",1,"calculate") If Answer = 1 Then objshell.run("calc.exe"),0 Else Exit Sub End IfEnd SubSo 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 More sharing options...
jamesbebby Posted April 7, 2011 Author Share Posted April 7, 2011 Im running this straight from the .vbs off my desktop, would this make a difference??Cheers, James Link to comment Share on other sites More sharing options...
gunsmokingman Posted April 7, 2011 Share Posted April 7, 2011 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 IfMsgbox with a timer to close after 5 seconds with code only for yesDim 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 More sharing options...
jamesbebby Posted April 8, 2011 Author Share Posted April 8, 2011 (edited) 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 IfThe above is not working.Cheers, JamesEDIT- So now ive got the app opening with 'yes' because i put the .vbs in the same folder as the app [school boy error]With this codeIf MsgBox( _ "Run New Process Notifier?",4132,"New Process Notifier") = 6 Then CreateObject("Wscript.Shell").Run("NewProcessNotifier"),1,False End IfAs 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 errorIf 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!!! AhhCheers, James Edited April 8, 2011 by jamesbebby Link to comment Share on other sites More sharing options...
gunsmokingman Posted April 8, 2011 Share Posted April 8, 2011 I thnk the problem is you need a full path to app and it full nameRun("NewProcessNotifier") This might workRun("DriveLetter\FolderName\NewProcessNotifier.exe") This only ways this would work if the app in \Windows Folder Or \Windows\System32 folderRun("Notepad") Or the VBS file is in the same location as the app. Link to comment Share on other sites More sharing options...
Tripredacus Posted April 8, 2011 Share Posted April 8, 2011 This only ways this would work if the app in \Windows Folder Or \Windows\System32 folderRun("Notepad") Or the VBS file is in the same location as the app.Or you set an environment variable. Link to comment Share on other sites More sharing options...
jamesbebby Posted April 9, 2011 Author Share Posted April 9, 2011 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 IfCheers, James Link to comment Share on other sites More sharing options...
Scr1ptW1zard Posted April 9, 2011 Share Posted April 9, 2011 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 IfSpaces in the path/file names require additional quotes. Link to comment Share on other sites More sharing options...
jamesbebby Posted April 9, 2011 Author Share Posted April 9, 2011 (edited) 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 IfSpaces in the path/file names require additional quotes.You have just live up to your name 'Scr1ptW1zard'!!! [with-me anyway lol]Thanks, James Edited April 9, 2011 by jamesbebby Link to comment Share on other sites More sharing options...
gunsmokingman Posted April 9, 2011 Share Posted April 9, 2011 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 More sharing options...
Yzöwl Posted April 9, 2011 Share Posted April 9, 2011 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,FalseEnd If Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now