Solved

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

Posted on 2008-06-24
8
1,960 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need help on C# Linq query on object 6 63
Device Location 4 29
Expression Evaluater 3 26
VB.NET 2008 - SQL Timeout 9 24
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

809 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