Hi Guys

I'm having a lot of bother trying to execute a vbs script from an asp file.

Basically, what i want is for the asp to call a vbs file, and then i want the vbs script to write to a file on the server, and then i want the asp to redirect the user to the file just written to, so that they are prompted to download the file.

at the minute, im stuck on trying to get the asp to execute the vbs script.

this is my asp code:

Dim wshell
set wshell = server.CreateObject("WScript.Shell")
strCommand = "cmd.exe /c cscript test.vbs"
wshell.run strCommand,1,true
set wshell = nothing 

and this is my test.vbs:

log_file = "test.csv"
set fs = createobject("Scripting.FileSystemObject")
set op = fs.OpenTextFile(log_file, 2, True)

op.Write "header1,header2,header3" & vbCrLf

set op = nothing
set fs = nothing

when i load up the asp file in ie, the page loads fine, i.e. there are no errors displayed. so the page loads, but i know the script doesnt execute because test.vbs isnt created in the web directory.

im sure teh vbs code works, as it runs successfully from the command line.

maybe i have something wrong with my permissions in IIS? is this is a possibility, can anyone tell me what i need to set?

thanks for any help you can offer! :D

<%@ Page Language = "VB" aspcompat=true Explicit="True" %>
<!-- #INCLUDE file="utils.aspx" -->

Your vbs script here

I gave up on trying to learn all that language. I just use a site builder now.

This article has been dead for over six months. Start a new discussion instead.