473,385 Members | 1,344 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

to execute server side exe file from client side

AnuSumesh
Hi

I m new to ASP 'n' this forum also.
I m writing one code to invoke remote desktop service for given IP address. For that i m using mstsc.exe file to invoke RDP.
I have a no of links to be displayed on the page and on click of link, RDP for that IP should be called.
Currently i m using one button to invoke RDP.

But i m doing some mistake. here is my code:

serverlist.txt file just contains the username and corrosponding IP addresses.
Expand|Select|Wrap|Line Numbers
  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001" %>
  2.  
  3. <%
  4.  
  5. '' To Get Server List into Array corrosponding to particular User
  6.  
  7. Dim ForReading
  8. ForReading = 1
  9.  
  10. Dim list()
  11. Dim l
  12.  
  13. Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
  14. Set objTextFile = objFSO.OpenTextFile _
  15. ("C:\ServerList.txt", ForReading)
  16.  
  17. Do Until objTextFile.AtEndOfStream
  18. strNextLine = objTextFile.Readline
  19. arrServiceList = Split(strNextLine , ",")
  20.  
  21. if arrServiceList(0)="anu" then
  22. l= Ubound(arrServiceList)
  23. Redim list(l)
  24. For i = 1 to Ubound(arrServiceList)
  25. list(i-1)=arrServiceList(i)
  26. Next 
  27. end if
  28. Loop
  29. %>
  30.  
  31. <%
  32. Dim objFS, objLogFile, fo
  33. Dim strLogFilename
  34.  
  35. strLogFilename = "testrun.log"
  36.  
  37. Set objFS = CreateObject("Scripting.FileSystemObject")
  38. Set fo=objFS.GetFolder("c:\test") 
  39. Set objLogFile=fo.CreateTextFile(strLogFilename,true) 
  40.  
  41. objLogFile.writeLine "starts now "
  42.  
  43. public function runfile()
  44.  
  45. objLogFile.writeLine "in run"
  46.  
  47. dim wshell
  48. set wshell=CreateObject("WScript.Shell")
  49.  
  50. objLogFile.writeLine "Object created"
  51.  
  52. call wshell.run ("C:\windows\system32 \mstsc.exe /v:172.20.31.102")
  53.  
  54. objLogFile.writeLine "after run"
  55.  
  56. set wshell=nothing
  57.  
  58. End function
  59. %>
  60.  
  61. <html>
  62. <HEAD>
  63. <TITLE></TITLE>
  64. </HEAD>
  65. <body>
  66. <TABLE width="100%" height="100%">
  67. <% For i = 0 to Ubound(list)-1 %>
  68. <tr>
  69. <td> 
  70. <a href="#"> <img src="images\AppIcons\TerminalServices.gif"> <% =list(i) %> </a>
  71. </td>
  72. </tr>
  73. <% Next %>
  74.  
  75. <tr>
  76. <td>
  77. <input type="button" value="click me" name="sub" onClick="<%runfile()%>" />
  78. </td>
  79. </tr>
  80.  
  81. </Table>
  82.  
  83. </body>
  84.  
  85. </html>
in this code:- its displaying the images with IP.
I have inserted one button. i want to call runfile() function to be called on click event of that button.

For testing purpose i m writing into logfile in runfile() function.

The problem is:
1. when i browse this page , at the same time it call the
runfile() function 'n' write entries into file.
2. on click of button, the function is not getting called.
3. wshell.run ("C:\windows\system32 \mstsc.exe /v:172.20.31.102") is not executing. The syntax is correct( i m sure abt the syntax)

mstsc.exe file is on server side. i want it to execute from client side 'n' it should invoke RDP for the client.

Please help me in this issue.
I m trying from last 2 days.
I need it urgently

Thanks in advance.

Anu
Nov 27 '07 #1
2 3494
urstop
12
1. Thatz not how you call a funtion that is on the sever side from the button click in ASP.
You will have to submit the page on the button click and capture the form submission and in that call the runfile method.

2. Executing a exe on the server, this EXE even if you execute it succesfully will not be visible to you, it will be created in the ASP procress and is not visible to you, so if the EXE creates any problems it might lead to a recycle of the ASP process or hanging of the process/IIS.

Let me know if you have any queries.

Regards,
UrStop
Nov 28 '07 #2
hi

thanks for reply.
i understand i m doing wrong.
now i have changed my code as follows:
Expand|Select|Wrap|Line Numbers
  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001" %>
  2. <html>
  3.  
  4. <HEAD>
  5. <TITLE></TITLE>
  6. </HEAD>
  7. <body>
  8.  
  9. <%
  10. '' To Get Server List into Array corrosponding to particular User
  11. Dim ForReading
  12. ForReading = 1
  13.  
  14. Dim list()
  15. Dim l
  16.  
  17. Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
  18. Set objTextFile = objFSO.OpenTextFile _
  19.     ("C:\ServerList.txt", ForReading)
  20.  
  21. Do Until objTextFile.AtEndOfStream
  22.     strNextLine = objTextFile.Readline
  23.     arrServiceList = Split(strNextLine , ",")
  24.  
  25.     if arrServiceList(0)="Anu" then
  26.         l= Ubound(arrServiceList)
  27.         Redim list(l)
  28.         For i = 1 to Ubound(arrServiceList)
  29.        list(i-1)=arrServiceList(i)
  30.         Next 
  31.     end if
  32. Loop
  33. %>
  34.  
  35. <form name="serverslist">
  36. <TABLE width="100%" height="100%">
  37. <% For i = 0 to Ubound(list)-1 %>
  38. <tr><td> 
  39. <a href="runfile.vbs" <% =list(i)%>> <img src="images\AppIcons\TerminalServices.gif"> </a>
  40. <a href="runfile.vbs" <% =list(i)%>> <% =list(i) %> </a>
  41. </td></tr>
  42. <% Next %>
  43.  
  44. </Table>
  45. </form></body></html>
and the runfile.vbs file is :
Expand|Select|Wrap|Line Numbers
  1. On Error Resume Next
  2. dim IP
  3. IP=WScript.Arguments.Item(0)
  4.     WScript.Echo "IP is "&IP
  5.     dim wshell
  6.     set wshell=CreateObject("WScript.Shell")
  7.     wshell.Run "some exe "& IP
  8.     set wshell=nothing
  9.  
Now the problem is in syntax of <a href="runfile.vbs" <% =list(i)%>>.
vbs file starts executing on click of lick but i want to pass the parameters also.

1. Please suggest me what should be the correct format of URL to be passed in <href= >.
2. when vbs starts executing, it asks the user to open/Save. But i want it to run automatically without user interaction. is it possible? if yes then how?

thanks a lot in advance.

Anu
Nov 28 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Kathryn | last post by:
Hiya I have a problem with using some client side and server side scripting together in an ASP. I'm using VBScript. What I'm trying to achieve is this - - Page loads up and some server side...
4
by: Fred | last post by:
I have read and tried every combination for hours. I'm sorry, but I don't get it. How do I have a form with textboxes and buttons and allow click events to execute a server function then display...
4
by: Ian Kelly | last post by:
Hi All, I have an .net form that is split into two frames. The left frame has a tree that displays a list of all the customers. The right frame displays the appropriate clients information. ...
4
by: Mark Miller | last post by:
I've been trying to execute a javascript function just before submit on a form that contains an <input type="file"> input field and it isn't working. The reason I want to do this is the end users...
0
by: nano2k | last post by:
Hi I develop a client/server application using webservices. So, I have a client app and a webservice that responds to client app requests - nothin' new. In certain circumstances (namely, when...
31
by: Manfred Kooistra | last post by:
If I have a document like this: <html> <head> <script language=javascript> window.location.href='file.php'; </script> </head> <body> body content
3
by: Mel | last post by:
My server makes a url call that returns a whole bunch of javascripts. I will then have to execute them on the server. I stripped out everything between <bodyand </bodyand I can see the scripts. ...
17
by: =?Utf-8?B?SmltIFJvZGdlcnM=?= | last post by:
I am trying to replace a huge chunck of code that currently I incorporate with an #Include directive. The program rarely has to flow through that code, so I thought it would be better if I used...
0
by: cherryblossom | last post by:
hii, Im developing an client server application in C#. In that i have to use Mobile Agent technology. On the Server side there is a class...which i want send to the client...by System.IO...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.