Solved

Using wscript.shell to launch an app from VBScript

Posted on 2004-03-24
5
1,632 Views
Last Modified: 2008-02-26
hi guys,

Ive added a script behind a button on an Outlook form that launches an app if the Save & Close button is clicked. The problem is, the Run command fails on the wscript.shell object. It seems to be an issue with using a spae in the run string. ie. if I put "C:\temp\app.exe" it is fine, but if I put the app in temp 2 and use "C:\temp 2\app.exe" it just opens up the temp folder as if it truncated my run statement ! Here is my code...

Dim wshShell
Set wshShell = CreateObject("WScript.Shell")
wshShell.Run "C:\temp 2\notepad.exe"
Set wshShell = Nothing

...doesnt work but...

Dim wshShell
Set wshShell = CreateObject("WScript.Shell")
wshShell.Run "C:\temp\notepad.exe"
Set wshShell = Nothing

...does

Im running on Windows 2000 and Outlook 2002.
0
Comment
Question by:adders99
  • 3
  • 2
5 Comments
 
LVL 28

Expert Comment

by:vinnyd79
ID: 10668693
try adding extra qoutes:

wshShell.Run ""C:\temp 2\notepad.exe""
0
 
LVL 28

Accepted Solution

by:
vinnyd79 earned 50 total points
ID: 10668717
try this instead:

Dim wshShell
Set wshShell = CreateObject("WScript.Shell")
wshShell.Run Chr(34) & "C:\temp 2\notepad.exe" & Chr(34)
Set wshShell = Nothing
0
 

Author Comment

by:adders99
ID: 10668792
Tried that one and got 'expected end of statement'
0
 

Author Comment

by:adders99
ID: 10668804
tried your second one and it worked a treat. Many thanks ! Any idea why it works like that ?
0
 
LVL 28

Expert Comment

by:vinnyd79
ID: 10668821
the chr(34) puts qoutes around the string,otherwise wshShell will think anything after the spaces are parameters.
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Put text in a picture ASP.NET C# 2 58
VB 6 error 5 in windows 10 but not in XP 7 57
vbModal 12 53
How to read File Date Created using VB6 8 39
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question