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

joedelapazAsked:
Who is Participating?
 
joedelapazAuthor Commented:
After a lot more investigation, these were the documents that helped me solve the problem.

This is the key web page that helped me.

http://www.west-wind.com/WebLog/posts/2153.aspx

These pages helped complete the picture and after a little bit of tinkering I finally got it sorted.

http://aspnet.4guysfromrolla.com/articles/031204-1.aspx
http://msdn.microsoft.com/en-us/library/ms998358.aspx
0
 
HainKurtSr. System AnalystCommented:
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
0
 
joedelapazAuthor Commented:
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
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
HainKurtSr. System AnalystCommented:
try this

System.Diagnostics.Process.Start("cscript c:\Inetpub\wwwroot\DisableDot1x.vbs");
0
 
HainKurtSr. System AnalystCommented:
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...
0
 
HainKurtSr. System AnalystCommented:
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)?
0
 
joedelapazAuthor Commented:
Please award 250 points to HainKurt for his assistance on this issue.

Thanks,
Joe
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.