...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