Solved

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

Posted on 2008-06-24
8
2,218 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

635 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