Solved

What is the C# equivalent of the VB.NET Shell command?

Posted on 2008-06-24
8
1,925 Views
Last Modified: 2012-05-05
Here's the code I need an equivalent for:

            Shell("C:\Program Files\WinZip\wzzip -sPa$$pHr@$E47 -ycAES256 " & Left(fil.Path, fil.Path.Length - 4) & ".zip " & fil.Path, AppWinStyle.NormalFocus, True, 60000)

0
Comment
Question by:FrancineTaylor
8 Comments
 
LVL 3

Expert Comment

by:DarrenMcCall
ID: 21858461
What does the "true" and "60000" do?
using System.Diagnostics;
 

Process shell = new Process();

shell.StartInfo.WindowStyle = ProcessWindowStyle.Normal;

shell.StartInfo.FileName = "C:\Program Files\WinZip\wzzip.exe";

shell.StartInfo.Arguments = "-sPa$$pHr@$E47 -ycAES256 " & Left(fil.Path, fil.Path.Length - 4) & ".zip " & fil.Path;

Open in new window

0
 
LVL 29

Expert Comment

by:David H.H.Lee
ID: 21858464
Hi FrancineTaylor,
You can try this:
Interaction.Shell("C:\\Program Files\\WinZip\\wzzip -sPa$$pHr@$E47 -ycAES256 " + Strings.Left(fil.Path, fil.Path.Length - 4) + ".zip " + fil.Path, AppWinStyle.NormalFocus, true, 60000);

Here is the convertor from C# to vb.net. You can try it for other conversion as well.
0
 
LVL 3

Expert Comment

by:DarrenMcCall
ID: 21858467
Sorry, I forgot to use escape characters
shell.StartInfo.FileName = "C:\\Program Files\\WinZip\\wzzip.exe";

Open in new window

0
 
LVL 3

Expert Comment

by:DarrenMcCall
ID: 21858598
correction to the last line
shell.StartInfo.Arguments = "-sPa$$pHr@$E47 -ycAES256 " + shell.StartInfo.FileName.Substring(0, shell.StartInfo.FileName.Length - 4) + ".zip " + shell.StartInfo.FileName;

Open in new window

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 18

Expert Comment

by:jcoehoorn
ID: 21858721
Use the System.Diagnostics.Process() class:
Process.Start()
0
 
LVL 3

Accepted Solution

by:
DarrenMcCall earned 500 total points
ID: 21858846
jcoehoorn: yes! I keep leaving code off!
shell.Start();

shell.WaitForExit; //If you want to wait

Open in new window

0
 
LVL 1

Author Comment

by:FrancineTaylor
ID: 21858885
Aha!  Thank you, Darren, I was just composing another question...you just answered it!

You guys are great, thanks!
0
 
LVL 1

Author Closing Comment

by:FrancineTaylor
ID: 31470274
Thanks again!  You're awesome.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now