Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This proof of concept script:</p> <pre><code>' pocBTicks.vbs - poor man's version of backticks (POC) Option Explicit ' Globals Const SW_SHOWMINNOACTIVE = 7 Const ForReading = 1 Dim goFS : Set goFS = CreateObject( "Scripting.FileSystemObject" ) Dim goWSH : Set goWSH = CreateObject( "WScript.Shell" ) ' Dispatch WScript.Quit demoBTicks() ' demoBTicks - Function demoBTicks() demoBTicks = 1 Dim aCmds : aCmds = Array( _ "dir pocBTicks.vbs" _ , "dur pocBTicks.vbs" _ , "xcopy /?" _ ) Dim sCmd For Each sCmd In aCmds WScript.Echo "########", sCmd Dim aRet : aRet = BTicks( sCmd ) Dim nIdx For nIdx = 0 To UBound( aRet ) WScript.Echo "--------", nIdx WScript.Echo aRet( nIdx ) Next Next demoBTicks = 0 End Function ' demoBTicks ' BTicks - execute sCmd via WSH.Run ' aRet( 0 ) : goWSH.Run() result ' aRet( 1 ) : StdErr / error message ' aRet( 2 ) : StdOut ' aRet( 3 ) : command to run Function BTicks( sCmd ) Dim aRet : aRet = Array( -1, "", "", "" ) Dim sFSpec2 : sFSpec2 = goFS.GetAbsolutePathName( "." ) Dim sFSpec1 : sFSpec1 = goFS.BuildPath( sFSpec2, goFS.GetTempName() ) sFSpec2 = goFS.BuildPath( sFSpec2, goFS.GetTempName() ) aRet( 3 ) = """%COMSPEC%"" /c """ + sCmd + " 1&gt;""" + sFSpec1 + """ 2&gt;""" + sFSpec2 + """""" Dim aErr On Error Resume Next aRet( 0 ) = goWSH.Run( aRet( 3 ), SW_SHOWMINNOACTIVE, True ) aErr = Array( Err.Number, Err.Description, Err.Source ) On Error GoTo 0 If 0 &lt;&gt; aErr( 0 ) Then aRet( 0 ) = aErr( 0 ) aRet( 1 ) = Join( Array( aErr( 1 ), aErr( 2 ), "(BTicks)" ), vbCrLf ) BTicks = aRet Exit Function End If Dim nIdx : nIdx = 1 Dim sFSpec For Each sFSpec In Array( sFSpec2, sFSpec1 ) If goFS.FileExists( sFSpec ) Then Dim oFile : Set oFile = goFS.GetFile( sFSpec ) If 0 &lt; oFile.Size Then aRet( nIdx ) = oFile.OpenAsTextStream( ForReading ).ReadAll() goFS.DeleteFile sFSpec End If End If nIdx = nIdx + 1 Next BTicks = aRet End Function </code></pre> <p>shows how to use .Run and temporary files to get something like backticks with a hidden console. Decent file handling, quoting in sCmd, cleaning of the returned strings, and dealing with encodings will require more work. But perhaps you can use the strategy to implement something that fits your needs.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload