Process.Start ?

G

Guest

H
If I us
Process.Start("DTSRun ...") on a computer that has SQL server installed, it can't fin
DTSRun, claiming 'file not found'. Despite this,
Shell("DTSRun...") from VB.NET works fine
It also works to run DTSRun from the command line without typing in the directory
as c:\program files\microsoft sql server\80\tools\binn is in the 'path' environmen
variable, so it can be found
What is the equivalent in C# of VB.NET's Shell, given that the reliance on Environmen
variables is desired

Thanks
 
C

Cor Ligthert

Hi Songie,

Despite that most of us probably know what you mean does it sound like a
quiz.

Is it not more easy, when you want an answer, to tell what you want to
archieve and send this question only to the C# language newsgroup.

Now the people from the C# group have to find out how it works in VB.net.

And for the VB.net people it is of no interest at all.

Just my thought,

Cor
 
N

Nicholas Paldino [.NET/C# MVP]

songie,

I would think that if DTSRun is an executable, then using the Process
class would work just as well. However, if it is a package of some kind,
then you would have to set the UseShellExecute flag on the ProcessStartInfo
class to indicate that the shell should run the executable associated with
the file (which is exactly what I think the Shell function in VB does).

You can easily get around this by adding a reference to
Microsoft.VisualBasic.dll, and then calling the static Shell function on the
Interaction class in the Microsoft.VisualBasic namespace. It's managed
code, so it will work just fine (and it is distributed with the .NET
framework).

Hope this helps.
 
H

Herfried K. Wagner [MVP]

* "=?Utf-8?B?c29uZ2llIEQ=?= said:
Process.Start("DTSRun ...") on a computer that has SQL server installed, it can't find
DTSRun, claiming 'file not found'. Despite this,
Shell("DTSRun...") from VB.NET works fine.
It also works to run DTSRun from the command line without typing in the directory,
as c:\program files\microsoft sql server\80\tools\binn is in the 'path' environment
variable, so it can be found.
What is the equivalent in C# of VB.NET's Shell, given that the reliance on Environment
variables is desired?

\\\
Dim psi As New ProcessStartInfo()
psi.FileName = "DTSRun.exe"
psi.Arguments = ...
Process.Start(psi)
///

.... should work.
 
C

Cor Ligthert

What is the equivalent in C# of VB.NET's Shell, given that the reliance
on Environment
\\\
Dim psi As New ProcessStartInfo()
psi.FileName = "DTSRun.exe"
psi.Arguments = ...
Process.Start(psi)
///

... should work.
In C#, I do not believe that.

Was a busy day I gues

:))

Cor
 
H

Herfried K. Wagner [MVP]

* "Cor Ligthert said:
In C#, I do not believe that.

Was a busy day I gues

A little bit Java "programming" for university...

This is a VB.NET group. If the OP wants a solution in C#, he should
post to the C# group only.
 
C

Cor Ligthert

This is a VB.NET group. If the OP wants a solution in C#, he should
post to the C# group only.

That was what I told in the first answer you see in this thread

however after all that Java I understand, but Weener melange is very good I
thought

:))

Cor
 
S

songie D

It's not a quiz, there was only one question.
I cross posted to the VB.NET newsgroup as I was hoping
to catch people that used both VB.NET and C# - I always
use C#, don't like VB.NET, but my colleagues have just
started a project using VB.NET.
 
S

songie D

...if DTSRun is an executable,

Yes, it is. It's installed as part of SQL server client tools
and is in the associated 'bin' directory, which is listed in the
'path' environment variable.
I would think that ... then using the Process
class would work just as well.

Unfortunately, it doesn't. Try it - create a new folder, and put
a simple batch file in it, say. Then add it to the 'path' environment
variable, then when you restart check that you can call it from
a DOS prompt when it isn't the current directory. Then try
comparing calling it from Shell in VB.NET, against using
Process.Start from C#. I'd be interested to hear what you make of it...
However, if it is a package of some kind,

Nah... it's not. It's an exe.
then you would have to set the UseShellExecute flag on the ProcessStartInfo
class to indicate that the shell should run the executable associated with
the file (which is exactly what I think the Shell function in VB does).

You can easily get around this by adding a reference to
Microsoft.VisualBasic.dll, and then calling the static Shell function on the
Interaction class in the Microsoft.VisualBasic namespace. It's managed
code, so it will work just fine (and it is distributed with the .NET
framework).

So... does that mean that C# can just delve into VB.NET and steal its
functions whenever it wants?! Great news, but a little confusing....the main
source of confusion being why doesn't C# have its own equivalent, does
VB.NET have any other functions than C# doesn't, and if so, doesn't that
make it a more powerful language?


Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

songie D said:
Hi
If I use
Process.Start("DTSRun ...") on a computer that has SQL server installed, it can't find
DTSRun, claiming 'file not found'. Despite this,
Shell("DTSRun...") from VB.NET works fine.
It also works to run DTSRun from the command line without typing in the directory,
as c:\program files\microsoft sql server\80\tools\binn is in the 'path' environment
variable, so it can be found.
What is the equivalent in C# of VB.NET's Shell, given that the reliance
on
Environment
variables is desired?

Thanks
 
J

Jon Skeet [C# MVP]

songie D said:
So... does that mean that C# can just delve into VB.NET and steal its
functions whenever it wants?! Great news, but a little confusing....the main
source of confusion being why doesn't C# have its own equivalent, does
VB.NET have any other functions than C# doesn't, and if so, doesn't that
make it a more powerful language?

C# as a *language* doesn't have any functions. However, it can use the
same types that VB.NET uses to emulate old VB behaviour. Unfortunately,
the Microsoft.VisualBasic assembly isn't documented, and to my mind
isn't really intended to be used other than by the VB.NET compiler.
 
C

Cor Ligthert

Hi Jon,

Something for this page maybe?

http://www.pobox.com/~skeet/csharp/faq/#vb.or.csharp
C# as a *language* doesn't have any functions. However, it can use the
same types that VB.NET uses to emulate old VB behaviour. Unfortunately,
the Microsoft.VisualBasic assembly isn't documented, and to my mind
isn't really intended to be used other than by the VB.NET compiler.

:) only to prickle

However what do you mean by the Microsoft.VisualBasic assembly isn't
documented, how should I see that comparing that with C#?

Cor
 
J

Jon Skeet [C# MVP]

Cor Ligthert said:
Something for this page maybe?

http://www.pobox.com/~skeet/csharp/faq/#vb.or.csharp
Possibly...


:) only to prickle

However what do you mean by the Microsoft.VisualBasic assembly isn't
documented, how should I see that comparing that with C#?

There is no documentation for the Microsoft.VisualBasic assembly, as
far as I've seen. There's documentation for VB.NET's built-in
functions, but that doesn't document how they convert to IL calls.

C# doesn't have documentation for built-in functions because it doesn't
*have* any built-in functions. The nearest it has are the language
constructs of lock, using and foreach, all of which are clearly
documented in terms of their more wordy equivalents.
 
J

Jay B. Harlow [MVP - Outlook]

Jon,
With all due respect: Huh??? ;-)
There is no documentation for the Microsoft.VisualBasic assembly, as
far as I've seen. There's documentation for VB.NET's built-in
functions, but that doesn't document how they convert to IL calls.

Start here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vastmAppActivate.asp

As you say the functions are documented, included at the bottom of this
documentation is the Namespace, Module (remember a module is nothing more
then a class with static methods only) and Assembly of where the function
is.

Unless of course you are referring to Keywords, such as CInt, then although
they are listed as Functions, they are not actual functions... (they do
however call undocumented helper functions in the above assembly).

Hope this helps
Jay
 
J

Jon Skeet [C# MVP]

Jay B. Harlow said:
With all due respect: Huh??? ;-)


Start here:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/
html/vastmAppActivate.asp

As you say the functions are documented, included at the bottom of this
documentation is the Namespace, Module (remember a module is nothing more
then a class with static methods only) and Assembly of where the function
is.

Ah, that's good to see. Shame it only comes up if you've got a filter
that includes Visual Basic though - why would that be the case if the
assembly were designed to be used from other languages? (That's almost
certainly why I haven't seen it before. I tend to have a Visual C#
filter on.)

It's certainly *not* part of the main framework like (say)
System.IO.Stream is - hence why even within MSDN it's not under the
".NET Framework/Reference/Class Library" topic.

So while I accept that it's documented (and am pleased by that) I still
don't think it's something C# programmers should be referencing without
a very good reason.
 
J

Jay B. Harlow [MVP - Outlook]

Jon,
So while I accept that it's documented (and am pleased by that) I still
don't think it's something C# programmers should be referencing without
a very good reason.
Totally agree!!
It's certainly *not* part of the main framework like (say)
System.IO.Stream is - hence why even within MSDN it's not under the
".NET Framework/Reference/Class Library" topic.
It is however shipped with the framework! I think Ed has the right idea, if
you are porting/upgrading something use it at first, then refactor it out,
unless there is a very good reason...

Jay
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top