April 7, 201115 yr 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
April 7, 201115 yr 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.
April 7, 201115 yr Author Im running this straight from the .vbs off my desktop, would this make a difference??Cheers, James
April 7, 201115 yr 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
April 8, 201115 yr Author 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, 201115 yr by jamesbebby
April 8, 201115 yr 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.
April 8, 201115 yr 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.
April 9, 201115 yr Author 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
April 9, 201115 yr 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.
April 9, 201115 yr Author 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, 201115 yr by jamesbebby
April 9, 201115 yr 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
April 9, 201115 yr 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
Create an account or sign in to comment