How to pass values to a vbscript function?

T

Terry Olsen

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?
 
T

Terry Olsen

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top