|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
get values from asp pass to batch file !!!Dear Sir,
i'm new to asp.net i'm looking to How to get values (Variables) pre Declared in web form & pass it to a batch file coz i've to get this values to be added to the batch file to Automate the process of creating records & Zones in our DNS server May you Help ? Ahmad Sabry wrote:
> i'm looking to How to get values (Variables) pre Declared in web form & pass If the batch file takes the values are arguments, pass them as the > it to a batch file Arguments to the Process that you start to run the Batch file. Dim p as New Process With p With p.StartInfo .FileName = "[path]\file.bat" .Arguments = A & " " & B & " " & C End With .Start() .WaitForExit() End With HTH, Phill W. Thanks Mr Phill , But as i told you i'm still new in .net
So there's something missed maybe ! so again , my batch file will be (C:\Do.bat) --------- > & i wrote in it for example : ========== @ECHO OFF mkdir c:\%A% ========== is this correct ? so in ASP.net i've a text Box & a button i imported Imports System Imports System.Diagnostics Imports System.ComponentModel & when I press the Button : ============================== Dim A As String A = TextBox1.Text Dim p As New Process With p With p.StartInfo .FileName = "C:\Do.bat" .Arguments = A End With .Start() .WaitForExit() End With ============================== I get the following Error: 'StartInfo' is not a member of 'Process'. May you tell me what i missed ? Thanks in advance A.Sabry Ahmad Sabry wrote:
> I get the following Error: Do you have another class in your project called Process?> 'StartInfo' is not a member of 'Process'. Try changing the declaration of the Process object to be: Dim p As New System.Diagnostics.Process Other than that, the code I gave works for me. :-{ Hopefully, your bat file will be doing a /lot/ more than just creating a directory - you could do that perfectly well in Visual Basic code directly ... Regards, Phill W. Do you have another class in your project called Process?
No oher Classes > Try changing the declaration of the Process object to be: It works with one Error> Dim p As New System.Diagnostics.Process [HttpException (0x80004005): Request timed out.] > i c .. but htat what my leader doesn't sees> Hopefully, your bat file will be doing a /lot/ more than just creating a > directory - you could do that perfectly well in Visual Basic code directly > ... i just want it to make a liitle thing correctly to go ahead with my complex dns commands i made it before as windows app. by using an external dos Class it worked but he needs the script to be easier for editing than compiling in future sorry mr Phill .. but i really need this to work Show quoteHide quote > Regards, > Phill W. > it works now but not 100%
i mean it opens the CMD prompt but i think the problem in the way i pass the variable (A) to the batch file my Code is: ======================================== Dim A As String A = TextBox1.Text Dim p As New System.Diagnostics.Process With p With p.StartInfo .FileName = "C:\Doit.bat" .Arguments = A End With .Start() .WaitForExit() End With ======================================== & my batch file: ======================================== @ECHO OFF mkdir c:\%A% ======================================== So ... where is the mistake ? If I remember correctly (50/50 chance here),
I think batch files accept parameters as %1%, %2%, and so on, so if you change %A% in your batch file to %1%, it should work. You can run your batch file yourself by bringing up a cmd window, navigating to the folder where your batch file it, and then running it. This would help clarify if the problem is with the batch file or the VB code. Robin S. ---------------------------- Show quoteHide quote "Ahmad Sabry" <Egyptyr***@gmail.com> wrote in message news:%23QPW%235$DHHA.4184@TK2MSFTNGP03.phx.gbl... > it works now but not 100% > i mean it opens the CMD prompt > but i think the problem in the way i pass the variable (A) > to the batch file > my Code is: > ======================================== > Dim A As String > A = TextBox1.Text > Dim p As New System.Diagnostics.Process > With p > With p.StartInfo > .FileName = "C:\Doit.bat" > .Arguments = A > End With > .Start() > .WaitForExit() > End With > ======================================== > & my batch file: > ======================================== > @ECHO OFF > mkdir c:\%A% > ======================================== > So ... where is the mistake ? > Ahmad Sabry wrote:
> i've also Access is denied in the CMD window when it runs Well that's a bit of a show-stopper.The ASP must be running under an account that's just not allowed to do whatever it is your bat file is trying to do. Find out which account it's running under and make sure that that account has the necessary permissions. Regards, Phill W.
A Modest Question
Is VB.NET Stable?? Odd databinding behavior create a keystroke logger SQL UPDATE query help please Need to create link between DataSet tables to show matching records Simple Data UPdae Question Why must I cast when I put type safe generic objects in the combo box? Exception handling, Retry, Resume Next ListView ListItems - can they be hidden? |
|||||||||||||||||||||||