Page 1 of 1 1
Topic Options
#214350 - 2026-07-14 04:26 PM Win11 25H2 kills KixTrat Function
Lipman Offline
Getting the hang of it

Registered: 2005-05-09
Posts: 52
Loc: Jersey Shore USA
I have been using this function in a utility to provide a GUI to select a file and pass that file name to be processed.

 Code:
Function SelectFile()
	Dim $objSHELLexec, $CMD, $objSHELL
	$SelectFile=""
	$CMD='mshta.exe "about:< input type=file id=FILE><script>FILE.click();new ActiveXObject("Scripting.FileSystemObject").GetStandardStream(1).WriteLine(FILE.value);close();resizeTo(0,0);</script>" '
	$objSHELL=CreateObject("WScript.Shell")
	$objSHELLexec=$objSHELL.Exec($CMD)
	$SelectFile=$objSHELLexec.StdOut.ReadLine()
EndFunction


Now that I updated a PC from 23H2 to 25H2, the above function is no longer viable so I am seeking another function to do likewise usable in Win11 25H2.


Top
#214351 - 2026-07-16 05:52 PM Re: Win11 25H2 kills KixTrat Function [Re: Lipman]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4572
Loc: USA
VBSCript, and probably by relation Wscript.shell, is not installed by default in newer versions of Windows 11. VBScript has been depreciated but not removed.

https://www.elevenforum.com/t/install-or-uninstall-vbscript-feature-in-windows-11.13095/

Manually
Start\Settings\Apps\Optional Features\Add a Feature\
Search for VBScript + Next
Install

DISM
DISM /Online /Add-Capability /CapabilityName:VBSCRIPT~~~~
_________________________
(... better days ahead)

Top
#214352 - 2026-07-16 08:11 PM Re: Win11 25H2 kills KixTrat Function [Re: Allen]
Lipman Offline
Getting the hang of it

Registered: 2005-05-09
Posts: 52
Loc: Jersey Shore USA
Thank you Allen

that was done already, and it does not effectuate any difference.

Top
#214353 - 2026-07-16 08:21 PM Re: Win11 25H2 kills KixTrat Function [Re: Allen]
Lipman Offline
Getting the hang of it

Registered: 2005-05-09
Posts: 52
Loc: Jersey Shore USA
I also see, now that the post is out of moderation, the code had been truncated by the Forum'ware :-(

Not the first time I have seen that behaviour on a Forum either.

Top
#214354 - 2026-07-16 08:26 PM Re: Win11 25H2 kills KixTrat Function [Re: Lipman]
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11634
Loc: CA
Let me try to post the code

Function SelectFile()
Dim $objSHELLexec, $CMD, $objSHELL
$SelectFile=""
$CMD='mshta.exe "about:<input type=file id=FILE><script>FILE.click();new ActiveXObject("Scripting.FileSystemObject").GetStandardStream(1).WriteLine(FILE.value);close();resizeTo(0,0);</script>" '
$objSHELL=CreateObject("WScript.Shell")
$objSHELLexec=$objSHELL.Exec($CMD)
$SelectFile=$objSHELLexec.StdOut.ReadLine()
EndFunction


Edited by Allen (2026-07-17 02:06 AM)

Top
#214355 - 2026-07-16 10:03 PM Re: Win11 25H2 kills KixTrat Function [Re: NTDOC]
morganw Offline
Fresh Scripter

Registered: 2015-10-20
Posts: 22
Loc: UK
This isn't a KiXtart issue, it is a security change in Windows.
https://support.microsoft.com/en-US/serv...00-6725-preview

 Quote:
[MSHTA inline scripts] After installing this update, inline scripts passed directly to MSHTA.exe will no longer run and fail silently with no error code. This behavior is intentional; inline script execution was identified as a security vulnerability and was blocked as part of a planned security hardening change. Execution of .hta files that contain script within their HTML code continues to work as expected. Apps using inline scripts must shift to supported alternatives, such as invoking an .hta file or loading script from an external file.

Top
#214356 - 2026-07-16 10:04 PM Re: Win11 25H2 kills KixTrat Function [Re: NTDOC]
Lipman Offline
Getting the hang of it

Registered: 2005-05-09
Posts: 52
Loc: Jersey Shore USA
Thank you NTDOC at least now I can choose a File here to upload - LOL
Top
#214357 - 2026-07-17 02:03 AM Re: Win11 25H2 kills KixTrat Function [Re: Lipman]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4572
Loc: USA
@morganw, nice find.
_________________________
(... better days ahead)

Top
#214358 - 2026-07-17 02:06 AM Re: Win11 25H2 kills KixTrat Function [Re: Allen]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4572
Loc: USA
I edited the original post so the "choose file" interface didnt come up. I see NTDOC tried to do something, but the button is back again. I'm editing his post.
_________________________
(... better days ahead)

Top
#214359 - 2026-07-17 05:50 PM Re: Win11 25H2 kills KixTrat Function [Re: Allen]
Lipman Offline
Getting the hang of it

Registered: 2005-05-09
Posts: 52
Loc: Jersey Shore USA
Thanx all.

Still...

Looking for an alternative way in KiX, on Win11 25H2, to have a GUI function select file for processing.

Top
#214360 - 2026-07-17 09:35 PM Re: Win11 25H2 kills KixTrat Function [Re: Lipman]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4572
Loc: USA
 Code:
Function SelectFile()
  Dim $objSHELLexec, $CMD, $objSHELL

  $SelectFile = ""
  $CMD = 'powershell.exe -NoProfile -STA -Command "Add-Type -AssemblyName System.Windows.Forms; ' +
         '$f = New-Object System.Windows.Forms.OpenFileDialog; ' +
         'if ($f.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK) { $f.FileName }"'
  $objSHELL = CreateObject("WScript.Shell")
  $objSHELLexec = $objSHELL.Exec($CMD)
  If Not $objSHELLexec.StdOut.AtEndOfStream
    $SelectFile = $objSHELLexec.StdOut.ReadLine()
  EndIf
EndFunction


_________________________
(... better days ahead)

Top
#214361 - 2026-07-17 10:51 PM Re: Win11 25H2 kills KixTrat Function [Re: Allen]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4572
Loc: USA
Better version
 Code:
Function SelectFile(optional $InitialDir, $Filter)
  ; If $InitialDir is omitted, the dialog does NOT default to @scriptdir or the
  ; current working directory - it opens wherever the user last browsed to in
  ; ANY prior OpenFileDialog on this machine. Pass $InitialDir explicitly if
  ; starting location matters.
  Dim $objSHELLexec, $CMD, $objSHELL, $fh, $paramFile, $rc, $builtFilter

  $SelectFile = ""
  $paramFile = "%TEMP%\_selectfile_params.txt"

  ; $Filter accepts any bare extension - txt, pdf, exe, or whatever else - and
  ; gets built into a full "Label|*.ext" filter automatically, e.g. "txt"
  ; becomes "TXT files (*.txt)|*.txt". If the caller already passed a full
  ; filter string (detected by the presence of "|"), it's used exactly as
  ; given, untouched.
  If $Filter <> "" And InStr($Filter, "|") = 0
    If Left($Filter, 1) = "."
      $Filter = SubStr($Filter, 2)
    EndIf
    $builtFilter = UCase($Filter) + " files (*." + $Filter + ")|*." + $Filter
  Else
    $builtFilter = $Filter
  EndIf

  $fh = FreeFileHandle()
  $rc = Open($fh, $paramFile, 5)
  $rc = WriteLine($fh, $builtFilter + @CRLF)
  $rc = WriteLine($fh, $InitialDir + @CRLF)
  $rc = Close($fh)

  $CMD = 'powershell.exe -NoProfile -STA -Command "' +
         'Add-Type -AssemblyName System.Windows.Forms; ' +
         '$p = Get-Content ' + Chr(39) + $paramFile + Chr(39) + '; ' +
         '$f = New-Object System.Windows.Forms.OpenFileDialog; ' +
         'if ($p[0]) { $f.Filter = $p[0] }; ' +
         'if ($p[1]) { $f.InitialDirectory = $p[1] }; ' +
         'if ($f.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK) { $f.FileName }"'

  $objSHELL = CreateObject("WScript.Shell")
  $objSHELLexec = $objSHELL.Exec($CMD)

  If Not $objSHELLexec.StdOut.AtEndOfStream
    $SelectFile = $objSHELLexec.StdOut.ReadLine()
  EndIf

  Del $paramFile
EndFunction



 Code:
Dim $reportPath, $installerPath, $logPath

$reportPath = SelectFile("C:\Reports", "pdf")
If $reportPath <> ""
  ? "Selected report: " + $reportPath
EndIf

$installerPath = SelectFile("C:\Downloads", "exe")
If $installerPath <> ""
  ? "Selected installer: " + $installerPath
EndIf

$logPath = SelectFile("C:\Logs", "txt")
If $logPath <> ""
  ? "Selected log file: " + $logPath
EndIf
_________________________
(... better days ahead)

Top
#214362 - 2026-07-18 02:37 PM Re: Win11 25H2 kills KixTrat Function [Re: Allen]
Lipman Offline
Getting the hang of it

Registered: 2005-05-09
Posts: 52
Loc: Jersey Shore USA
AWESOME !

Thank you Allen !

That works and resolves my issue.

Thank you to all respondents.

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 710 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.088 seconds in which 0.037 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org