Saturday, March 24, 2012

Invoke an exe file on server side

I created a page with a button. The user presses this button and it is supposed to invoke an exe file that works on the server side. I tried the following code behind:

Label2.Text ="The bot began it's work. Pleas wait..."Dim startInfo As System.Diagnostics.ProcessStartInfoDim pStart As New System.Diagnostics.ProcessstartInfo = New System.Diagnostics.ProcessStartInfo("http://.../files/BotScript1.exe")pStart.StartInfo = startInfopStart.Start()pStart.WaitForExit()Label2.Text = "The bot has finished it's work"

My problem is that this doesn't work on the server side: Pressing the button asks the user if he wants to open the file. I want this file to work on the server.

If this can't be done for security reasons (I don't see why not - this file has nothing to do with the user, but is part of the server script), I would like to use the source code of this exe file and run it on the server. The problem doing it this way is that the script is in c# and my pages are in VB.NET.

Thanks
Yoni

If the .exe is on your web server, try using Server.MapPath in the ProcessStartInfo() to get the actual file location, instead of the HTTP (virtual) location.


doyleits:

If the .exe is on your web server, try using Server.MapPath in the ProcessStartInfo() to get the actual file location, instead of the HTTP (virtual) location.

I tried that, and the exe runs, but as a diff problem came up, I decided to put the source code in my code behind page. I now face a new problem:

I have created a listbox inside an update panel, but when I use the code behind to add items to the listbox (in order to notify the user whats going on) - they added items don't appear until the server is done with the code. How can I get the listbox to refresh itself every time I add/remove/edit items from it?

Thanks,
Yoni


Put the ListBox inside UpdatePanel. Also set the UpdateMode property toConditional

When items will be added/deleted call UpdatePanel1.Update()

http://www.asp.net/ajax/documentation/live/mref/M_System_Web_UI_UpdatePanel_Update.aspx


chetan.sarode:

Put the ListBox inside UpdatePanel. Also set the UpdateMode property toConditional

When items will be added/deleted call UpdatePanel1.Update()

http://www.asp.net/ajax/documentation/live/mref/M_System_Web_UI_UpdatePanel_Update.aspx

I did as you said: I added a UpdateMode="Conditional" property to the Update Panel and used the Update() function after every change I did to the list - but still nothing. Any ideas?

Thanks
Yoni


Hi Yoni,

I recommend copying those source code into a class library. And reference the assembly in your web application. It's better than changing security settings.

After the class library has been compiled into an assembly, it can be used regardless of what language it's written in.


Sorry, I didn't notice that you've solved the running exe issue.

yonidebest:

I tried that, and the exe runs, but as a diff problem came up, I decided to put the source code in my code behind page. I now face a new problem:

I have created a listbox inside an update panel, but when I use the code behind to add items to the listbox (in order to notify the user whats going on) - they added items don't appear until the server is done with the code. How can I get the listbox to refresh itself every time I add/remove/edit items from it?

Thanks,
Yoni

I think you can add a timer on the page to refresh the page at a specific interval.

No comments:

Post a Comment