PoshCode Archive  Artifact [cc3e541514]

Artifact cc3e541514bd2279581139f4e1f988dbdee5311d2e6ad3f51f98f0921c888e81:

  • File visual-cmd-bat.ps1 — part of check-in [fdc357a0d9] at 2018-06-10 13:58:36 on branch trunk — save script with .cmd or .bat extension and launch. this demo just shows current directory entries. (user: greg zakharov size: 1246)

# encoding: ascii
# api: xml
# title: visual cmd\bat
# description: save script with .cmd or .bat extension and launch. this demo just shows current directory entries.
# version: 0.1
# type: script
# author: greg zakharov
# license: CC0
# x-poshcode-id: 5654
# x-archived: 2015-01-04T10:40:34
# x-published: 2015-12-27T19:01:00
#
#
<!-- :
@echo off
  setlocal
    start "" mshta.exe "%~f0"
  endlocal
exit /b
-->

<!DOCTYPE html>
<html>
  <head>
    <title>Visual CMD\BAT</title>
    <style type="text/css">
      body { font-family: tahoma; margin: 0 5; padding: 0; }
      p { margin: 0; padding: 0; }
    </style>
    <script language="JScript">
      function resize() { window.window.resizeTo(300, 300); }
    </script>
  </head>
  <body onload="resize();">
    <script>
      (function() {
        var std, arr, i;
        with (new ActiveXObject('WScript.Shell')) {
          std = Exec('cmd /q /k echo off');
          std.StdIn.WriteLine('dir /b & exit');
          arr = std.StdOut.ReadAll().split('\n');
          
          for (i = 0; i < arr.length; i++) {
            document.write('<p>' + arr[i] + '</p>');
          } //for
        }
      }());
    </script>
  </body>
</html>