Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #34772

Re: How to deal with "new Date()" error when running JScript in Windows Script Host ?

From Jon Ribbens <jon+usenet@unequivocal.eu>
Newsgroups comp.lang.javascript
Subject Re: How to deal with "new Date()" error when running JScript in Windows Script Host ?
Date 2018-03-13 12:06 +0000
Organization A noiseless patient Spider
Message-ID <slrnpaffm2.31p.jon+usenet@sable.unequivocal.eu> (permalink)
References <928d7c15-93f7-46e3-b5ee-78cb19ae02d1@googlegroups.com> <slrnpadjke.31p.jon+usenet@sable.unequivocal.eu> <0a336b95-6961-4150-b149-9c97f1a66e94@googlegroups.com>

Show all headers | View raw


On 2018-03-12, Dr J R Stockton <J.R.Stockton@physics.org> wrote:
> H'mmm - there should be an API for using WMIC directly from JScript?

Something like this perhaps:

  var oWMI = GetObject('winmgmts:')
  var eOSes = new Enumerator(oWMI.InstancesOf('Win32_OperatingSystem'))
  var oOS
  while (!(oOS && oOS.Primary) && !eOSes.atEnd()) {
  	oOS = eOSes.item()
  	eOSes.moveNext()
  }
  var oDate = new ActiveXObject('WbemScripting.SWbemDateTime')
  oDate.Value = oOS.LocalDateTime
  WScript.Echo(oDate.Day + '/' + oDate.Month + '/' + oDate.Year)

I'm not sure if bothering to search the operating system list is
overkill or if just 

  var oOS = new Enumerator(oWMI.InstancesOf('Win32_OperatingSystem')).item()

would be sufficient but presumably it doesn't hurt.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

How to deal with "new Date()" error when running JScript in Windows Script Host ? Dr J R Stockton <J.R.Stockton@physics.org> - 2018-03-12 11:26 -0700
  Re: How to deal with "new Date()" error when running JScript in Windows Script Host ? Jon Ribbens <jon+usenet@unequivocal.eu> - 2018-03-12 19:01 +0000
    Re: How to deal with "new Date()" error when running JScript in Windows Script Host ? Dr J R Stockton <J.R.Stockton@physics.org> - 2018-03-12 16:01 -0700
      Re: How to deal with "new Date()" error when running JScript in Windows Script Host ? Jon Ribbens <jon+usenet@unequivocal.eu> - 2018-03-13 12:06 +0000
      Re: How to deal with "new Date()" error when running JScript in Windows Script Host ? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2018-03-13 13:19 -0700
        Re: How to deal with "new Date()" error when running JScript in Windows Script Host ? Dr J R Stockton <J.R.Stockton@physics.org> - 2018-03-14 13:29 -0700
  Re: How to deal with "new Date()" error when running JScript in Windows Script Host ? Julio Di Egidio <julio@diegidio.name> - 2018-03-14 14:18 -0700
    Re: How to deal with "new Date()" error when running JScript in Windows Script Host ? Dr J R Stockton <J.R.Stockton@physics.org> - 2018-03-15 02:19 -0700
      Re: How to deal with "new Date()" error when running JScript in Windows Script Host ? Dr J R Stockton <J.R.Stockton@physics.org> - 2018-03-15 02:35 -0700
      Re: How to deal with "new Date()" error when running JScript in Windows Script Host ? Jon Ribbens <jon+usenet@unequivocal.eu> - 2018-03-15 11:38 +0000
        Re: How to deal with "new Date()" error when running JScript in Windows Script Host ? Dr J R Stockton <J.R.Stockton@physics.org> - 2018-03-15 13:37 -0700
          Re: How to deal with "new Date()" error when running JScript in Windows Script Host ? Jon Ribbens <jon+usenet@unequivocal.eu> - 2018-03-15 23:24 +0000
            Re: How to deal with "new Date()" error when running JScript in Windows Script Host ? Dr J R Stockton <J.R.Stockton@physics.org> - 2018-03-16 14:14 -0700
              Re: How to deal with "new Date()" error when running JScript in Windows Script Host ? Jon Ribbens <jon+usenet@unequivocal.eu> - 2018-03-16 23:34 +0000
                Re: How to deal with "new Date()" error when running JScript in Windows Script Host ? Dr J R Stockton <J.R.Stockton@physics.org> - 2018-04-18 03:15 -0700
                Re: How to deal with "new Date()" error when running JScript in Windows Script Host ? JJ <jj4public@vfemail.net> - 2018-04-18 22:58 +0700
      Re: How to deal with "new Date()" error when running JScript in Windows Script Host ? Julio Di Egidio <julio@diegidio.name> - 2018-03-15 10:50 -0700

csiph-web