PC Review


Reply
Thread Tools Rating: Thread Rating: 8 votes, 3.50 average.

get values from asp pass to batch file !!!

 
 
Ahmad Sabry
Guest
Posts: n/a
 
      22nd Nov 2006
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 ?


 
Reply With Quote
 
 
 
 
Phill W.
Guest
Posts: n/a
 
      23rd Nov 2006
Ahmad Sabry wrote:

> i'm looking to How to get values (Variables) pre Declared in web form & pass
> it to a batch file


If the batch file takes the values are arguments, pass them as the
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.
 
Reply With Quote
 
 
 
 
Ahmad Sabry
Guest
Posts: n/a
 
      24th Nov 2006
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


 
Reply With Quote
 
Phill W.
Guest
Posts: n/a
 
      24th Nov 2006
Ahmad Sabry wrote:

> I get the following Error:
> 'StartInfo' is not a member of 'Process'.


Do you have another class in your project called 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.
 
Reply With Quote
 
Ahmad Sabry
Guest
Posts: n/a
 
      24th Nov 2006
Do you have another class in your project called Process?
No oher Classes

> Try changing the declaration of the Process object to be:
> Dim p As New System.Diagnostics.Process

It works with one Error

[HttpException (0x80004005): Request timed out.]
>
> 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 c .. but htat what my leader doesn't sees
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
> Regards,
> Phill W.
>



 
Reply With Quote
 
Ahmad Sabry
Guest
Posts: n/a
 
      24th Nov 2006
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 ?


 
Reply With Quote
 
RobinS
Guest
Posts: n/a
 
      24th Nov 2006
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.
----------------------------
"Ahmad Sabry" <(E-Mail Removed)> wrote in message
news:%23QPW%235$(E-Mail Removed)...
> 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 ?
>



 
Reply With Quote
 
Ahmad Sabry
Guest
Posts: n/a
 
      24th Nov 2006
i've also Access is denied in the CMD window when it runs


 
Reply With Quote
 
Phill W.
Guest
Posts: n/a
 
      27th Nov 2006
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.
 
Reply With Quote
 
New Member
Join Date: Jun 2011
Posts: 1
 
      21st Jun 2011
I wonder if you are getting access denied because you're declaring a letter in your batch file, its ignoring it and you are then trying to create a directory called c:\ which is obviously not allowed.

declare your variable in .net as normal then within your batch file you need to set it. so if you

Dim p AsNew System.Diagnostics.Process
Dim a AsString
a = TextBox1.Text

With p
With p.StartInfo
.FileName =
"C:\Doit.bat"
.Arguments = a
EndWith
.Start()
.WaitForExit()
EndWith

then within your batch file

set a=%1
mkdir c:\%1%



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
I got Values From ASP Passed To Batch File .. Many Thanks:-) Ahmad Sabry Microsoft VB .NET 1 27th Nov 2006 04:51 AM
get values from asp pass to batch file !!! Ahmad Sabry Microsoft ASP .NET 0 22nd Nov 2006 07:27 PM
Calling Batch within a Batch file Bobby Stiklus Microsoft Windows 2000 Developer 1 27th Apr 2004 06:40 PM
Calling Batch within a Batch File ChuckR Microsoft Windows 2000 Developer 0 22nd Apr 2004 02:33 AM
how to get pass the pass word Susan Microsoft Word New Users 1 31st Aug 2003 08:39 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:37 AM.