Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to translate CreateObject("Wscript.shell") into C# [duplicate]

Tags:

c#

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?

like image 593
Alex Avatar asked Nov 05 '22 23:11

Alex


1 Answers

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)

like image 50
Ben Voigt Avatar answered Nov 14 '22 17:11

Ben Voigt