Solved

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

Posted on 2008-06-24
8
1,872 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 18

Expert Comment

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

Accepted Solution

by:
DarrenMcCall earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks again!  You're awesome.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

771 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

10 Experts available now in Live!

Get 1:1 Help Now