Getting errors when running shell explorer Share command

Hello everyone, I am trying to integrate some windows features into my node application. I am getting an error however. My code is as follows:

[pre]$shell = new-object -com “Shell.Application”;

$folder = $shell.Namespace(“C:\Users\igweo”);

$item = $folder.Parsename(“NailsMAIN.jpg”);

$verb = $item.Verbs() | ? {$_.Name -eq ‘Share’};

if ($verb) { $verb.DoIt(); };[/pre]

But I get the following error:

[pre] STDERR:Invalid window handle. (Exception from HRESULT: 0x80070578)

STDERR:At line:1 char:14

  • if ($verb) { $verb.DoIt(); };
  • CategoryInfo : OperationStopped: (:slight_smile: [], COMException
  • FullyQualifiedErrorId : System.Runtime.InteropServices.COMException[/pre]

I want a pop up similar to sure what to do. Every other command works OK. Please help.

Hey daibatzu47

I try below code and it was working in my side.If you give me more infomation what you are trying to achive, I may help you more.

$shell = new-object -com “Shell.Application”;
$folder = $shell.Namespace(“C:\Users\igweo”);
$item = $folder.Parsename(“NailsMAIN.jpg”);
$verb = $item.Verbs() | ? {$_.Name -like ‘Share’};
if ($verb) { $verb.DoIt(); };