0

How can I display the Windows Explorer "file properties page" via scripting code?

I have search with Google and have found no answers.

Something like... This code opens a Windows Explorer folder to path and selects file.

var path=(path to folder/file)  
var str= '"' + path+ '"';
var objShell = new ActiveXObject("WScript.shell");
objShell.Run('explorer.exe /n, /select, ' + str);
objShell = "";

A file context menu has a "Properties" option that opens a Properties dialog page for the file. How can this dialog be opened via script once the file is selected?

I found this third party command-line utility to open the standard Windows Properties sheet by passing the file/folder/drive path to it,but it requires .net 4.5! :( GeekDrop-Props

Jim Kolb
  • 21
  • 5
  • Related: https://stackoverflow.com/questions/40491266/shellexecuteex-with-properties-verb (a C++ question, but it tells you some important words like "ShellExecuteEx" and "properties verb") – RJHunter May 08 '18 at 23:55

1 Answers1

0

The Windows shell (not the WScript shell) provides a ShellExecute method which performs operations on files. The most common operation (verb) is open but the properties operation shows the property sheet dialog.

var shell = new ActiveXObject("shell.application");
shell.ShellExecute("example.txt", "", "", "properties");
RJHunter
  • 2,829
  • 3
  • 25
  • 30
  • The script failed in Microsoft Windows [Version 10.0.19042.1466]. The script shown error box: [Content] This file does not have an app associated with it for performing this action. Please install an app or, if one is already installed, create an association in the Default Apps Settings page. [OK] – lison Jan 25 '22 at 14:08