.NETGURU
VB.Net Shell() function
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

Henning Kristensen (VIP)
Hello,

I am in dire need of help!

My problem is a follows:
The application MUST run from a share on a server (done by adding the
assembly strongname with Full Trust to the LocalIntranetZone of the
Machine)...

The application lists a bunch of files that I must be able to execute...
The file-types are of types *.vbs (I have to execute them by calling the
Shell function with cscript //NoLogo \\server\share\folder\script.vbs for
these to work.
Other file type is a custom (associated to run using a wsf script (can be
called by filename from anywhere on my machine), thus allowing me to double
click on these files on my machine and they run), lets call this filetype
*.ABC

My problems with the Shell function are as follows, in very much prioritized
order (I need to have the first issue solved!):
- I cannot make the shell work when any paths have spaces in it, and I need
to call it like this:
C:\Program Files\[full path]\script.wsf \\server\share\folder name\[full
path]\script.ABC
Thus I need to use shell to call the .wsf script in a folderpath that
contains spaces, the script should be called with a server-share path as
parameter, this parameter path can also contain spaces.
So far I have tried putting anywhere between 1 and 5 " around different
parts of the two paths, but nothing has worked yet.

- Shell can not find the .wsf script, when called with just scriptname.

- Shell can not execute the *.ABC file, without giving the .ABC file as a
parameter to the .wsf script, even though the .ABC filetype is associated to
run by using the wsf script.

- Shell can not execute the *.VBS files without calling cscript giving the
..vbs file as a parameter.

Any assistance with this will be deeply appreciated

Reply to this message...
 
    
saurabh
1) You can use the GetShortPathName API from kernel32 to get the short form
of the path. this short form of the path will be without spaces.

--Saurabh

"Henning Kristensen" <Click here to reveal e-mail address> wrote in
message news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Sijin Joseph
Take a look at the Process class, it is more powerful than Shell and
allows a lot of customization.

Look at the Process.Start() method and the ProcessStartInfo class.
Specifically check out the ProcessStartInfo.UseShellExecute and
ProcessStartInfo.Verb properties.

Let me know if you get stuck somewhere.

Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph

Henning Kristensen wrote:
[Original message clipped]

Reply to this message...
 
    
Henning Kristensen (VIP)
Thank you very much, that did much of the trick :o)

I now can get the .ABC files to run by just passing the path to them like:
Dim obj as new Process
obj.start("\\server\share\folder\script.ABC")

One question:
How can I now when the process has exited ?? (eg. I tried to do a while not
obj.HasExited, but that fails with "No process is associated with this
object.")

"Sijin Joseph" wrote:

[Original message clipped]

Reply to this message...
 
    
Sijin Joseph
You can use Process.WaitForExit() method to wait till the process has
termintated.

Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph

Henning Kristensen wrote:
[Original message clipped]

Reply to this message...
 
    
Henning Kristensen (VIP)
Thank you very much :o)

I actually found out about this shortly after I wrote, but your assistance
has been invaluable and deeply appreciated!

My code went from:
dim index as integer
index = Shell(path, AppWinStyle.Normal, True)

To:
Dim ShellProcess as new Process

Try
ShellProcess.StartInfo.FileName = path
ShellProcess.StartInfo.UseShellExecute = True
ShellProcess.Start()
ShellProcess.WaitForExit()
Catch....
Finally
ShellProcess.Dispose()
End Try

I works like a charm...
Now all I need to figure out is how to thread this process, in such a way
that I can make updates to my GUI while waiting for the process to exit.

Thank you for your help :o)
Kind regards
Henning
"Sijin Joseph" wrote:

[Original message clipped]

Reply to this message...
 
 
System.Diagnostics.Process
System.Diagnostics.ProcessStartInfo




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification