You are here:

VB Script/using the wshshell object in vbscript

Advertisement


Question
We have an ASP page where we want to run a vb script to execute an external command and then return to ASP...

I did some research and found the wshShell object  - and it has a .run method that will do the trick.

Problem is, I have the following source code using VBScript that uses this functionality and I do not know what "references" I need in a project in order to use this object. Can you help?

The code to open a copy of the currently running script is as follows...

set WshShell = Wscript.CreateObject("Wscript.Shell")
WshShell.run "%windir%\notepad " & Wscript.ScriptFullname

Questions... What references do I need in order to access the methods of the Wscript and WshShell objects?


Thanks,

Brad


Answer
Im not specialist with ASP (WSH only) but you can try like this

JScript:

<% var objMyObject = Server.CreateObject("Scripting.FilesystemObject"); %>

VBScript:

<% Set objMyObject = Server.CreateObject("Scripting.FilesystemObject") %>

Of course in the raw scripts <% %> will not present.

I was glad to answer

VB Script

All Answers


Answers by Expert:


Ask Experts

Volunteer


Igor

Expertise

WSH 5.6, ADO, CDO, WMI, IE as Object.

Experience

WSH 5.6, ADO, CDO, WMI, IE as Object.

©2012 About.com, a part of The New York Times Company. All rights reserved.