How to pass values to a vbscript function?

Discussion in 'ASP .Net' started by Terry Olsen, Sep 29, 2005.

  1. Terry Olsen

    Terry Olsen Guest

    I pulled the following client-side script from an ASP page.

    <script language="vbscript">
    function doNetOp()
    Dim WshShell, oExec, HostIP
    Set WshShell = CreateObject("WScript.Shell")
    Set oExec = WshShell.Exec("C:\Program Files\Netop Remote
    Control\GUEST\ngstw32.exe /h:MTLOGUWK0009 /c:TCP/IP")
    end function
    </script>

    I would like to implement it in my ASP.NET WebForm. The script as is has
    no arguements and the PC name is predefined. On the ASP page, the user
    could click on a hyperlink:

    <a href="vbscript:donetop()">netop</a>

    and the Netop program will launch and connect to the specified pc.

    I would like to modify the script to pass a pc name as an arguement like
    so:

    <script language="vbscript">
    function doNetOp(hostname)
    dim WshShell, oExec
    Set WshShell = CreateObject("WScript.Shell")
    Set oExec = WshShell.Exec("C:\Program Files\Netop Remote
    Control\GUEST\ngstw32.exe /h:" + hostname + " /c:TCP/IP")
    end function
    </script>

    I have a datagrid with a listing of all the pc's on the network. I want
    to be able to have the user click on a pc name and pass the pc name to
    the vbscript function to launch Netop and connect to the pc.

    How could I go about doing this?

    *** Sent via Developersdex http://www.developersdex.com ***
    Terry Olsen, Sep 29, 2005
    #1
    1. Advertising

  2. Terry Olsen

    Terry Olsen Guest

    I actually got it working using a link button in my datagrid. This is
    server-side, so a postback occurs. But I'd still like to figure out how
    to do it on the client-side. See my original post at the top of the
    thread for that, but here's the code I got working...

    Private Sub DataGrid1_NetopCommand(ByVal source As Object, ByVal e As
    System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
    DataGrid1.ItemCommand
    Response.Write("<script language=""vbscript"">" & vbCrLf & _
    " Dim oShell" & vbCrLf & _
    " Set oShell =
    CreateObject(""WScript.Shell"")" & vbCrLf & _
    "
    oShell.run(""C:\Progra~1\Danwar~1\NetopR~1\GUEST\ngstw32.exe /h:" & _
    e.Item.Cells(9).Text & " /c:TCP/IP"")" & vbCrLf &
    _
    " Set oShell = Nothing" & vbCrLf & _
    "</script>" & vbCrLf & vbCrLf)
    End Sub

    *** Sent via Developersdex http://www.developersdex.com ***
    Terry Olsen, Sep 29, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. deanfamily
    Replies:
    4
    Views:
    399
    puzzlecracker
    Oct 24, 2005
  2. Joe
    Replies:
    2
    Views:
    393
    Martin Honnen
    Apr 25, 2009
  3. W. Jack
    Replies:
    5
    Views:
    238
    Roland Hall
    May 13, 2004
  4. Roland Hall

    VBScript function returning multiple values

    Roland Hall, Jan 30, 2005, in forum: ASP General
    Replies:
    17
    Views:
    492
    Roland Hall
    Feb 5, 2005
  5. Replies:
    3
    Views:
    233
Loading...

Share This Page