Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WshShell.Run doesn't do anything! ? ! 1

Status
Not open for further replies.

shar

Technical User
Apr 2, 2000
54
0
0
IR
Please help. Here is a very simple 4 lines vbs code:

Dim lPath
lPath = "D:\cpj.mdb"
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run strLocalPath

Why when I double click the vbs file it wouldn't start cpj.mdb in MS Access? It doesn't do anything.

I tried adding Dim WshShell, no effect.

Thanks.
 
Hello shar,

Dim lPath
lPath = "D:\cpj.mdb"
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run lPath

regards - tsuji
 
D'oh.
Thanks.

Here is another question: Is there any way to pass a string to the vbs file? In other words, can I pass the value of lpath to this script from where I am calling it?
 
Hello again,

Sure and often repeated here...(detail, you can beef it up.)
Code:
Dim lPath, oArgs, WshShell
Set oArgs=WScript.Arguments
If oArgs.count=0 Then
    WScript.Echo "You need to supply path to .mdb as argument. Operation aborted."
Else
    lPath = oArgs(0)  'you can spare lPath if you want
    Set WshShell = WScript.CreateObject("WScript.Shell")
    WshShell.Run lPath   'or submit direct oArgs(0) here
    Set WshShell = Nothing
End If
Set oArgs = Nothing
regards - tsuji
 
Thanks tsuji. I am a novice at VBSript and new to this forum. I appreciate the help. Here is a star for you.

Thanks again.
shar
 
Hello shar,

Thanks. When I say some issues are many times repeated in this forum, it does not necessarily mean the poster should always make due effort in searching---it is up to the individual, it only means helpers feel not making sufficient originality and at times feel mildly annoyed, that's all. If every thing being asked previously is not a worthy issue, we won't be here at all because there are so many sites out there with tons of systematic info. In particular, novices or seasoned are all relative. Any specific issue is worthy of specific answer free from all the unnecessary details detracting attention.

regards - tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top