Bienvenido! - Willkommen! - Welcome!

Bitácora Técnica de Tux&Cía., Santa Cruz de la Sierra, BO
Bitácora Central: Tux&Cía.
Bitácora de Información Avanzada: Tux&Cía.-Información
May the source be with you!

Tuesday, August 23, 2011

VB Script that starts running a program


The Message Box works but how do you tie together by clicking "Yes" it starts running the program fsav.exe?
Option Explicit
Dim MessageBox
Dim RunScan
RunScan = "C:\Program Files\F-Secure\Anti-Virus\fsav.exe"
MessageBox = MsgBox("Run Anti-Virus Scan Now?", _
vbYesNoCancel + vbQuestion, _
If MessageBox = "Yes" Then
Run RunScan
End If 
Try this - substitute Excel for F-Secure.
Option Explicit

Sub Run(ByVal sFile)
   Dim shell
   Set shell = CreateObject("WScript.Shell")
   shell.Run Chr(34) & sFile & Chr(34), 1, false
   Set shell = Nothing
End Sub
Dim MessageBox
Dim RunScan
RunScan="C:\Program Files\Microsoft Office\Office12\EXCEL.EXE"
MessageBox=MsgBox("Run Excel Now?",vbYesNo,"Excel")
If MessageBox=6 Then
   Run RunScan
End If

No comments: