Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to run a batch file from ASP.Net and also want to pass parameter to a batch file

0 views
Skip to first unread message

Ajit

unread,
Apr 30, 2003, 8:10:52 PM4/30/03
to
Hi,

I want to run a batch file from with in ASP.NET (aspx.vb file)
and also i want to pass a parameter to the batch file.

Do anyone know how to do this ?

Steve C. Orr, MCSD

unread,
Apr 30, 2003, 8:32:57 PM4/30/03
to
This code should do the trick

Dim myprocess As System.Diagnostics.Process = New
System.Diagnostics.Process()
myprocess.StartInfo.FileName = "c:\mybat.bat"
myprocess.StartInfo.WorkingDirectory = "C:\"
myprocess.StartInfo.Arguments= " file.txt -s -m"
myprocess.Start()

--
I hope this helps,
Steve C. Orr, MCSD
http://Steve.Orr.net

"Ajit" <adeo...@thedebtmediator.com> wrote in message
news:%230KeGZ3...@TK2MSFTNGP11.phx.gbl...

Ajit

unread,
Apr 30, 2003, 9:45:15 PM4/30/03
to
Hi Steve,

thanx for your suggession the good thing is it don't give any error but
neither it runs the batch file.

My batch file is Test.bat as below
=======================
@echo off
xcopy %1 "\\ServerName\Users\All\"

And ASP.Net code is
===============
'Run a Batch file
Dim proc As System.Diagnostics.Process = New
System.Diagnostics.Process()
proc.StartInfo.FileName = "C:\test.bat"
proc.StartInfo.WorkingDirectory = "C:\"
proc.StartInfo.Arguments = strFileName
proc.Start()
'proc.WaitForExit()

but in the target folder (\\servername\users\all\) i don't have the copy of
strfilename which is always dynamically generated.

thanx once again

Ajit.


"Steve C. Orr, MCSD" <St...@Orr.net> wrote in message
news:u72O3k3D...@TK2MSFTNGP10.phx.gbl...

Steve C. Orr, MCSD

unread,
Apr 30, 2003, 10:00:59 PM4/30/03
to
Oh, you are trying to run the batch file off of a file share. You didn't
mention that before.
That complicates things.
You need to make sure that your ASPNET account has permission to that file
share, or you need to modify the machine.config to run ASP.NET under a
different account, or you can use impersonation to temporarily get the
necessary permissions for that file share.

--
I hope this helps,
Steve C. Orr, MCSD
http://Steve.Orr.net


"Ajit" <adeo...@thedebtmediator.com> wrote in message

news:%2395O2N4...@TK2MSFTNGP11.phx.gbl...

0 new messages