• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2621
  • Last Modified:

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

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
FrancineTaylor
Asked:
FrancineTaylor
1 Solution
 
DarrenMcCallCommented:
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
 
David H.H.LeeCommented:
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
 
DarrenMcCallCommented:
Sorry, I forgot to use escape characters
shell.StartInfo.FileName = "C:\\Program Files\\WinZip\\wzzip.exe";

Open in new window

0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
DarrenMcCallCommented:
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
 
Joel CoehoornDirector of Information TechnologyCommented:
Use the System.Diagnostics.Process() class:
Process.Start()
0
 
DarrenMcCallCommented:
jcoehoorn: yes! I keep leaving code off!
shell.Start();
shell.WaitForExit; //If you want to wait

Open in new window

0
 
FrancineTaylorAuthor Commented:
Aha!  Thank you, Darren, I was just composing another question...you just answered it!

You guys are great, thanks!
0
 
FrancineTaylorAuthor Commented:
Thanks again!  You're awesome.
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now