string Fichier=Server.MapPath(@"SearchEng\request.bat");
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
"emman_54@hotmail.com" wrote:
[color=blue]
> Hi every one,
>
> I am trying to run a batch file using my asp.net application.
>
> I am using the Process class to run the batch file. When I run my web
> application, In the task manager, i could see cmd.exe with ASPNET as a
> user. But nothing happens. It can't execute the batch file.
>
> This is the code i am using to run the batch file:
>
> private void Request()
>
> {
>
> string Fichier=Server.MapPath("")+"\\SearchEng\\request.b at";
>
> Process proc=new System.Diagnostics.Process();
>
> proc.StartInfo.WindowStyle=ProcessWindowStyle.Maxi mized;
>
>
> proc.StartInfo.WorkingDirectory=Server.MapPath("") +"\\SearchEng\\";
>
> proc.StartInfo.FileName=Fichier;
>
>
>
> try
>
> {
>
> proc.Start();
>
>
> proc.WaitForExit();
>
> proc.Close();
>
> }
>
>
> catch(Exception ex)
>
> {
>
> this.lblerror.Text=ex.Message;
>
> }
>
> }
>
>
>
> ************************************************** ******************
>
> string Fichier=Server.MapPath("")+\\SearchEng\\request.ba t;
> Response.Write(Fichier)
>
> It does return the physical path of the file starting from
> C:\myApplication\SearchEng\request.bat.
>
> But if don't run the file from the physical path (example : if fichier
> = SearchEng\request.bat) it does give me an error : The system cannot
> find the file specified.
>
> I did another test: When i manually click on the request.bat file it
> does execute and returns me the right answers.
>
> This is what i get on my dos screen when i run the bat file with my
> code.
>
> C:\myApplication\SearchEng>set
> path="C:\myApplication\SearchEng";C:\WINDOWS\syste m32;C:\WINDOWS;C:\WINDOWS\system32\WBEM;C:\Program
> Files\ATI Technologies\ATI Control Panel;C:\Program Files\Microsoft SQL
> Server\80\Tools\BINN;C:\bin C:\myApplication\SearchEng>java -jar
> "C:\myApplication\SearchEng\SearchEngine.jar" GOOGLE/EPS/ gps IPSearch
> Version 1.22 All rights reserved ¬ 2005 my company Researche in
> progress ...... Error Results are saved in the Results.xml
>
> You can see research is in progress. I think the Process end before the
> SearchEngine.jar finishes executing.
>
> But when i run it manually i don't no error, Very strange
>
> I tried this proc.WaitForExit(900000) or proc.WaitForExit() but still
> ended without success.
>
> The content of my batch file is :
> set path="C:\myApplication\SearchEng";%path%
> java -jar "C:\myApplication\SearchEng\SearchEngine.jar" GOOGLE/EPS/ gps
>
> This batch file execute : SearchEngine.jar in dos then it saves the
> results in Results.xml
>
> Then i get the results then list them in a treeview.
>
> Have a wonderfull day.
>
>[/color]