473,387 Members | 1,517 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

execute batch file

Hi,
How can I execute a batch file form asp.net app. I have a form which a user
uploads a text file. after the file is uploaded I want a batch file to then
execute and do some work.

Thanks

Nov 19 '05 #1
3 2602
It depends on whether the upload triggers or something else. There are a
couple of ways I can think of to handle this:

1. Use a Process object to process the file when the upload is finished.
2. Create a service that uses a FileWatcher to watch for files to be
processed that processes when a new file appears. This is not driven by the
ASP.NET page.
3. Create a process that runs every once in awhile to see if there are
unprocessed files. Use a scheduler to run it. This is similar to #2, but does
not require learning how to use the FileWatcher.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
"Chris" wrote:
Hi,
How can I execute a batch file form asp.net app. I have a form which a user
uploads a text file. after the file is uploaded I want a batch file to then
execute and do some work.

Thanks

Nov 19 '05 #2
This code should do the trick:

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

If you run into security problems you might try using impersonation to run
ASP.NET under a user account that has more permissions than the standard
ASPNET user account.

Here's more info on impersonation:
http://msdn.microsoft.com/library/de...ersonation.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"Chris" <Ch***@discussions.microsoft.com> wrote in message
news:90**********************************@microsof t.com...
Hi,
How can I execute a batch file form asp.net app. I have a form which a
user
uploads a text file. after the file is uploaded I want a batch file to
then
execute and do some work.

Thanks

Nov 19 '05 #3
beautiful!

"Steve C. Orr [MVP, MCSD]" wrote:
This code should do the trick:

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

If you run into security problems you might try using impersonation to run
ASP.NET under a user account that has more permissions than the standard
ASPNET user account.

Here's more info on impersonation:
http://msdn.microsoft.com/library/de...ersonation.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"Chris" <Ch***@discussions.microsoft.com> wrote in message
news:90**********************************@microsof t.com...
Hi,
How can I execute a batch file form asp.net app. I have a form which a
user
uploads a text file. after the file is uploaded I want a batch file to
then
execute and do some work.

Thanks


Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: carrot | last post by:
With .Net Studio, I have a solution includes some projects. I want to execute a batch file during build solution time. For example, 1'st project is builded. 2'nd project is builded. " a batch...
2
by: den 2005 | last post by:
Hi Everybody, Is anybody knows how to Hide Execution of batch file at background? I mean without displaying the DOS Prompt window while batch file is being executed. I used code below to execute...
4
by: carrot | last post by:
With .Net Studio, I have a solution includes some projects. I want to execute a batch file during build solution time. For example, 1'st project is builded. 2'nd project is builded. " a batch...
2
by: DB | last post by:
Hi All, I have to execute dos command containing batch file using asp.net application. Code for batch file execution is working properly when I tried it with console application but same code...
1
by: Eric Wood | last post by:
We have an application that is accessed using shared drives, client executes program from server. We have already coded the program to create and save the a bat file either locally on the users...
1
by: Crash | last post by:
Hi, ..NET v1.x SP1 VS 2003 SQL Server 2000 SP3 Server 2000, XP, Server 2003 I would like to programmatically execute {possibly many} SQL Server batch scripts. Aka I have many scripts that...
0
by: Elroyskimms | last post by:
I need to execute a batch file via ASP.Net. In my VB.Net code, I'm using System.Diagnostics.Process to call the batch file and its appropriate command line arguments. I'm using...
2
by: raghutumma | last post by:
Hi, How can we execute SQL Scripts using Batch file??? i think Batch file should contain Username,Password,Database and Scripts... Using that file scripts should run... How can i give...
1
by: byjufromgamut | last post by:
I created a batch file, when executes gives a preview window(using swings & JFrame). I created another java fie in which used a Process object and Runtime.getRuntime().exec(path) , where path...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.