Add PowerShell in VB with Ws.shell

AbigailJ 101 Reputation points
2022-01-17T02:57:10.17+00:00

Howdy!

I'm attempting to run a PowerShell script within a VBScript, but when I launch the.exe, an error message that I don't understand is presented in the console.
Finally, at line 5, I put "Dim," when it should be "Set." However, Set is no longer supported (I'm not sure what effect this has). BC30807 is the identification number for this error.
At the moment, I'm attempting to run a.ps1 file, but the goal is to incorporate the powershell script straight into the VBScript.

Thanks in advance!
Unhandled exception. System.MissingMemberException: Public member 'run' on type 'IWshShell3' not found.
at Microsoft.VisualBasic.CompilerServices.Symbols.Container.GetMembers(String& memberName, Boolean reportErrors)
at Microsoft.VisualBasic.CompilerServices.NewLateBinding.CallMethod(Container baseReference, String methodName, Object[] >arguments, String[] argumentNames, Type[] typeArguments, Boolean[] copyBack, BindingFlags invocationFlags, Boolean reportErrors, >ResolutionFailure& failure)
at Microsoft.VisualBasic.CompilerServices.NewLateBinding.ObjectLateCall(Object instance, Type type, String memberName, Object[] >arguments, String[] argumentNames, Type[] typeArguments, Boolean[] copyBack, Boolean ignoreReturn)
at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateCall(Object Instance, Type Type, String MemberName, Object[] >Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack, Boolean IgnoreReturn)
at TestApp2.Program.Main(String[] args) in D:\Bureau\App\TestApp2\TestApp2\Program.vb:line 14
drg

Windows for business Windows Server User experience PowerShell
{count} votes

Accepted answer
  1. MotoX80 36,291 Reputation points
    2022-01-17T12:48:53.163+00:00

    TestApp2.Program.Main(String[] args) in D:\Bureau\App\TestApp2\TestApp2\Program.vb:line 14

    A VB script is a text file with a .VBS extension that is processed by cscript.exe or wscript.exe. You appear to be using compiled VB.Net.

    Public member 'run' on type 'IWshShell3' not found.

    There is no reason to use the Windows Script Shell object in VB.Net. Use process.start to run an external program.

    https://www.thoughtco.com/how-to-use-processstart-in-vbnet-3424455

    https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.process.start?view=net-6.0

    but the goal is to incorporate the powershell script straight into the VBScript.

    That's a great idea. If you're using an IDE like Visual Studio, you can take advantage of code snippets, auto complete, and it's help features to write code more easily. But obviously it all depends on what your code is trying to do.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.