473,796 Members | 2,765 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2625
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.Diagnost ics.Process = New
System.Diagnost ics.Process()
myprocess.Start Info.FileName = "c:\SomeFile.ba t"
myprocess.Start Info.WorkingDir ectory = "C:\"
myprocess.Start Info.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***@discussi ons.microsoft.c om> wrote in message
news:90******** *************** ***********@mic rosoft.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.Diagnost ics.Process = New
System.Diagnost ics.Process()
myprocess.Start Info.FileName = "c:\SomeFile.ba t"
myprocess.Start Info.WorkingDir ectory = "C:\"
myprocess.Start Info.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***@discussi ons.microsoft.c om> wrote in message
news:90******** *************** ***********@mic rosoft.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
1885
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 file is executed."! 3'rd project is builded.
2
7255
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 batch file. Is there other ways to do this? I need help. Thanks. Code: System.Diagnostics.Process.Start("batchfile1.bat");
4
2480
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 file is executed." 3'rd project is builded.
2
2816
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 is not working with ASP.net application. Help will be useful......... Thanks n Regards, Deepak
1
14671
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 machine or on the server. Our problem is that when we execute the bat file from the vb code it does not work properly. The bat file is used to connect to a commnad line service running on the server and update a file in another system. We can...
1
3766
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 drop/add stored procedure definitions, alter table definitions & constraints, etc... and I would
0
2283
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 System.Diagnostics.Process.StandardError and System.Diagnostics.Process.StandardOutput to capture and view the output and error messages. My web.config file has the following: <identity impersonate="true" userName="administrator" password="password" />
2
37648
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 UserName,Password,Database and all those things?
1
5280
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 specifies the location of above batch file. when indepedantly executes i am able to execute the bath file through this second program. Now the problem is that i want to execute the batch file in my JSP where i have tried a lot to execute the batch file...
0
9673
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9524
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10449
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10003
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9047
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7546
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5568
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.