Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


VBS and VB simple question

Posted on 2003-02-24
Medium Priority
Last Modified: 2010-04-07
Hi, I'm new here and i am currently learning
Visual Basic.
I was messing around writing a program in VBS with notepad
and i couldent use the shell command.
i allways get an error saying
type missmatch: "Shell"
i typed this into notepad and saved it as .vbs

Shell "C:\notepad.exe"

I got nothing, just an error.
But i can do it in a VB editor.
I have no idea why its doing that.
Thanks for your help!!
Question by:OverdrivE
  • 2
LVL 43

Accepted Solution

TimCottee earned 300 total points
ID: 8007054
This is because not all functions available within VB are available with VBScript.

VBScript is designed for client side web browser scripting (though of course it can do many other things as well). As a result there are a number of limitations. For example there are no native file handling commands in vbscript, you cannot use API functions either. However many of the things that can be achieved in VB can be achieved in VBScript using alternative methods. For example the Shell command that you refer to can be achieved using this code:

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


Author Comment

ID: 8007071
Thank you very much!!!
:D :D
LVL 43

Expert Comment

ID: 8008972
You need to accept a comment as answer now to close out this thread.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

580 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