5

How could i translate this in c#?

Set WshShell = WScript.CreateObject( "WScript.Shell" )

Thx. At what is this used? And also what is the library i have to include in c# in order to work?

Fredrik Mörk
  • 155,851
  • 29
  • 291
  • 343
Alex
  • 351
  • 2
  • 6
  • 14

4 Answers4

2

There are still some things more easily accomplished with the Shell objects for Scripting. You can get access from .NET using

var sh = (Shell32.IShellDispatch4)Activator.CreateInstance(
                                       Type.GetTypeFromProgID("Shell.Application"));

(add a reference to Shell32.dll to have the interop classes created)

Ben Voigt
  • 277,958
  • 43
  • 419
  • 720
0

You shouldn't - and maybe it isn't even possible. You should use the native classes of the .NET framework to achieve what you want. Depending on what is done with that object, there are several classes in .NET that can be used. If you show the usage of WshShell we can tell you the corresponding class in the .NET framework.

Daniel Hilgarth
  • 171,043
  • 40
  • 335
  • 443
  • i would like to activate some keys on an interface for saving a filetransfer for ezample. – Alex Apr 15 '11 at 11:31
  • eq: Call WshShell.Run( "API_CALLBACK.exe", 0, True ) ; WshShell.SendKeys("{ENTER}") – Alex Apr 15 '11 at 11:32
0

About shell

How to use in C#

Community
  • 1
  • 1
VikciaR
  • 3,324
  • 20
  • 32
0

WshShell gives you a reference to several commands and environment variables within windows. When dealing with C# you use different things to retrieve the different variables/commands. For example WshShell.Run translates to Process.Run. System.Environment.GetEnvironmentVariable can be used to get environment variables... So the actual answer depends on what you want to do.

BadGuy
  • 31
  • 4