Link to home
Start Free TrialLog in
Avatar of joedelapaz
joedelapaz

asked on

How to run server side vbscript file from website

Hello,

In relation to my previous question, about running a batch file from an asp.net page.
I now need to run a vbscript file instead of a batch file.
I thought it would have just been a simple task of substituting the batch file name with the vbscript file name.
However, I can run the batch file successfully but not the vbscript file.

I have tried running the vbscript file from within the batch file but this does not work either.

I have tried several other methods as can be seen in this code snippet below.
I've remmed out some of the other options I had tried.

If someone can post up a working code sample, I would be absolutely grateful.

Thanks in advance,
Joe
Partial Class TrainingRoom
    Inherits System.Web.UI.Page

    Protected Sub btnDisableDot1x_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDisableDot1x.Click
        ''''''''''''''''''''''''''
        ' Define new process
        Dim procDisableDot1x As System.Diagnostics.Process

        ' Start the filename you have specified as this new process
        procDisableDot1x = System.Diagnostics.Process.Start("c:\Inetpub\wwwroot\ScheduleDisableDot1x.cmd")
        'procDisableDot1x = System.Diagnostics.Process.Start("c:\Inetpub\wwwroot\DisableDot1x.vbs")

        ' Wait for the batch file to finish
        procDisableDot1x.WaitForExit(1000)
        ''''''''''''''''''''''''''
        ' Define(New process)
        'Dim procOutput As String
        'Dim procDisableDot1x As New System.Diagnostics.Process

        
        'procDisableDot1x.StartInfo.FileName = "c:\windows\system32\cscript.exe"
        'procDisableDot1x.StartInfo.RedirectStandardOutput = False
        'procDisableDot1x.StartInfo.Arguments = "c:\Inetpub\wwwroot\DisableDot1x.vbs"
        'procDisableDot1x.Start()
        'procDisableDot1x.WaitForExit()

        'procOutput = procDisableDot1x.StandardOutput.ReadToEnd
        'Response.Write(procOutput)
        ''''''''''''''''''''''''''
        

    End Sub


End Class

Open in new window

Avatar of HainKurt
HainKurt
Flag of Canada image

here it is:

http://technet.microsoft.com/en-us/library/ee156587.aspx

You can run script files from the command line in one of two ways:

Type the name of the script, including its file name extension, at the command prompt:

HardwareAudit.vbs

Type the name of one of the script hosts followed by the name of the script:

cscript HardwareAudit.vbs
wscript HardwareAudit.vbs
Avatar of joedelapaz
joedelapaz

ASKER

Hi Hain,

I tried that already, as per

procDisableDot1x.StartInfo.FileName = "c:\windows\system32\cscript.exe"
procDisableDot1x.StartInfo.RedirectStandardOutput = False
procDisableDot1x.StartInfo.Arguments = "c:\Inetpub\wwwroot\DisableDot1x.vbs"

I've also tried different variations of this programmatically in the script.

Any other suggestions?

Regards,
Joe
try this

System.Diagnostics.Process.Start("cscript c:\Inetpub\wwwroot\DisableDot1x.vbs");
look @ here  : http://stackoverflow.com/questions/200422/how-to-call-the-vbscript-file-in-c-application
there are some samples

maybe you should use a new System.Diagnostics.Process instead of using an existing one...
what happens when you enter DisableDot1x.vbs and hit run on command line?
is vbs registered? did you install host scripting? does IIS user have access to that file/folder? did you check event manager for any warnings/errors? is that code giving you error? if not, did you check task manager whether it is running or not (since it will be invisible)?
ASKER CERTIFIED SOLUTION
Avatar of joedelapaz
joedelapaz

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Please award 250 points to HainKurt for his assistance on this issue.

Thanks,
Joe