473,396 Members | 1,907 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,396 software developers and data experts.

running command line progs in a controlled manner

hi,

i am swamped by all the documentation and i can't find something relatively
simple.

a company has an intranet and they want a browser based application to
control data import/export. i need an apsx page to run dts packages on a
separate server.

after asking here and further investigation i am going to try this using
dtsrun.exe

which brings me to my question...

i can create a system.diagnostics.process object and run the program - but
how would i capture errors from this running.

the code i found is for VB and not ASP.NET and is at he end of this message.
when i tried to run it get Catch e As Win32Exception code produces Catch e
As Win32Exception.

where is a good place for ASP.NET examples?

thanks - kev


[Visual Basic]
Imports System
Imports System.Diagnostics
Imports System.ComponentModel
Namespace MyProcessSample
_
'/ <summary>
'/ Shell for the sample.
'/ </summary>
Public Class MyProcess
' These are the Win32 error code for file not found or access denied.
Private ERROR_FILE_NOT_FOUND As Integer = 2
Private ERROR_ACCESS_DENIED As Integer = 5
'/ <summary>
'/ Prints a file with a .doc extension.
'/ </summary>
Public Sub PrintDoc()
Dim myProcess As New Process()

Try
' Get the path that stores user documents.
Dim myDocumentsPath As String =
Environment.GetFolderPath(Environment.SpecialFolde r.Personal)

myProcess.StartInfo.FileName = myDocumentsPath + "\MyFile.doc"
myProcess.StartInfo.Verb = "Print"
myProcess.StartInfo.CreateNoWindow = True
myProcess.Start()
Catch e As Win32Exception
If e.NativeErrorCode = ERROR_FILE_NOT_FOUND Then
Console.WriteLine((e.Message + ". Check the path."))

Else
If e.NativeErrorCode = ERROR_ACCESS_DENIED Then
' Note that if your word processor might generate
exceptions
' such as this, which are handled first.
Console.WriteLine((e.Message + ". You do not have
permission to print this file."))
End If
End If
End Try
End Sub 'PrintDoc
Public Shared Sub Main()
Dim myProcess As New MyProcess()
myProcess.PrintDoc()
End Sub 'Main
End Class 'MyProcess
End Namespace 'MyProcessSample
Nov 18 '05 #1
1 1191
it depends on the program you run how you detect error. when you run a
program, you have access to its stdout, and stderr streams, and its
exitcode. some programs will return a special exitcode if they failed, some
don't. some will write errors to stderr, some stdout. dtsrun.exe is better
behaved than most.

-- bruce (sqlwork.com)

"kevin bailey" <kb*****@freewayprojects.com> wrote in message
news:co*******************@news.demon.co.uk...
| hi,
|
| i am swamped by all the documentation and i can't find something
relatively
| simple.
|
| a company has an intranet and they want a browser based application to
| control data import/export. i need an apsx page to run dts packages on a
| separate server.
|
| after asking here and further investigation i am going to try this using
| dtsrun.exe
|
| which brings me to my question...
|
| i can create a system.diagnostics.process object and run the program - but
| how would i capture errors from this running.
|
| the code i found is for VB and not ASP.NET and is at he end of this
message.
| when i tried to run it get Catch e As Win32Exception code produces Catch e
| As Win32Exception.
|
| where is a good place for ASP.NET examples?
|
| thanks - kev
|
|
|
|
| [Visual Basic]
| Imports System
| Imports System.Diagnostics
| Imports System.ComponentModel
|
|
| Namespace MyProcessSample
| _
| '/ <summary>
| '/ Shell for the sample.
| '/ </summary>
| Public Class MyProcess
| ' These are the Win32 error code for file not found or access
denied.
| Private ERROR_FILE_NOT_FOUND As Integer = 2
| Private ERROR_ACCESS_DENIED As Integer = 5
|
|
| '/ <summary>
| '/ Prints a file with a .doc extension.
| '/ </summary>
| Public Sub PrintDoc()
| Dim myProcess As New Process()
|
| Try
| ' Get the path that stores user documents.
| Dim myDocumentsPath As String =
| Environment.GetFolderPath(Environment.SpecialFolde r.Personal)
|
| myProcess.StartInfo.FileName = myDocumentsPath + "\MyFile.doc"
| myProcess.StartInfo.Verb = "Print"
| myProcess.StartInfo.CreateNoWindow = True
| myProcess.Start()
| Catch e As Win32Exception
| If e.NativeErrorCode = ERROR_FILE_NOT_FOUND Then
| Console.WriteLine((e.Message + ". Check the path."))
|
| Else
| If e.NativeErrorCode = ERROR_ACCESS_DENIED Then
| ' Note that if your word processor might generate
| exceptions
| ' such as this, which are handled first.
| Console.WriteLine((e.Message + ". You do not have
| permission to print this file."))
| End If
| End If
| End Try
| End Sub 'PrintDoc
|
|
| Public Shared Sub Main()
| Dim myProcess As New MyProcess()
| myProcess.PrintDoc()
| End Sub 'Main
| End Class 'MyProcess
| End Namespace 'MyProcessSample
Nov 18 '05 #2

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

Similar topics

23
by: Spiffy | last post by:
hello, i'm fairly new to python programming and programming in general, but i have written a python prog that creates a MIDI file (.mid) and I want to be able to play it from another prog which is...
0
by: Nilsson Mats | last post by:
Hi! I have an intresting problem for our programming community on Solaris. I want to develop an environment where: 1) The developers shouldn't need to bother about which Perl version to use....
6
by: Christopher Bohn | last post by:
(repost under MSDN account) When building a solution that consists of one managed C++ project with a project reference to a C# project in the same solution, there is a bug when trying to build...
8
by: Paul Cochrane | last post by:
Hi all, I've got an application that I'm writing that autogenerates python code which I then execute with exec(). I know that this is not the best way to run things, and I'm not 100% sure as to...
6
by: Gabest | last post by:
I'm asking this because I'd like to include a few (but often used) inline assembly code via marcos to make the whole thing a bit more readable, and more resistant to typos (by keeping the repeating...
0
by: WATYF | last post by:
This is my problem... I have some code that starts a Process and returns it to a variable... (prcBat) At any time while that process is running... I want to be able to Kill it by pressing a...
3
by: Double Echo | last post by:
Hi all, I'm using PHP 4.4.2, and use PHP on both the command-line and the web. I am running PHP on SuSE 10 Linux , in a VMware 5.5 workstation, using Apache 2.0.55 , on my Dell laptop. ...
24
by: Mark | last post by:
Hi, I'm new to python and looking for a better idiom to use for the manner I have been organising my python scripts. I've googled all over the place about this but found absolutely nothing. I'm...
6
by: tvaughan77 | last post by:
Hi, I have some code that I want to use to run a command line utility and I want to be able to run it from an aspx page running under IIS. The command line utility is a local utility running on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
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,...
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
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...
0
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,...

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.