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


Groups > comp.lang.javascript > #10028

Re: JScript - is a file of a known Type?

From Dr J R Stockton <reply1201@merlyn.demon.co.uk>
Newsgroups microsoft.public.scripting.jscript, microsoft.public.scripting.vbscript, comp.lang.javascript
Subject Re: JScript - is a file of a known Type?
Date 2012-01-07 21:54 +0000
Organization Home
Message-ID <0q7CDMOe8LCPFwj2@invalid.uk.co.demon.merlyn.invalid> (permalink)
References (2 earlier) <je0plc$u6g$1@news.albasani.net> <je1mtu$50r$1@dont-email.me> <je1ocf$e6m$1@dont-email.me> <je1qn9$t3u$1@dont-email.me> <4924e3fd-a25a-4cbe-8410-6f1c7f6984e4@r5g2000yqc.googlegroups.com>

Cross-posted to 3 groups.

Show all headers | View raw


In comp.lang.javascript message <4924e3fd-a25a-4cbe-8410-6f1c7f6984e4@r5
g2000yqc.googlegroups.com>, Thu, 5 Jan 2012 22:01:48, "Michael Haufe
(TNO)" <tno@thenewobjective.com> posted:

>On Jan 3, 11:09 am, Dr J R Stockton <reply1...@merlyn.demon.co.uk>
>wrote:
>> In Windows Script Host, given a File Object with properties including
>> Name and Type, is there a direct guaranteed infallible way in
>> JScript/VBScript to find whether the file is a known Type?
>
>Generally not as there is not a bijection between the TYPE and its
>registry entry. One would have to use the file extension as a key to
>lookup the existence of an entry to get more accurate results.

Well, the extension can be obtained from the File Object, and the method
in the code that you cite is certainly direct enough.  All I need do is
to take your try/catch and adapt it for the target context, in
<http://www.merlyn.demon.co.uk.programs/32-bit/seakfyle.js>.

You have a habit, I think, of getting to the core of the matter and
giving an appropriate answer.

>Here is some code that creates a similar result on my machine:
>
><https://gist.github.com/1569247>

Hence, installed and working,

        function Haufe(It) {
          var fName = It.Name,
            ext = fName.slice(fName.lastIndexOf(".")).toLowerCase()
          try { WshShell.RegRead("HKCR\\"+ext+"\\") ; return true }
          catch(e) { return false }
          }

However, it returns true for extension $$$, which needs thinking about.

Also, your way of getting the extension is eleven characters shorter
than what I had.

Thanks.

-- 
 (c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk  Turnpike 6.05  WinXP.
 Web  <http://www.merlyn.demon.co.uk/> - FAQ-type topics, acronyms, and links.
 Command-prompt MiniTrue is useful for viewing/searching/altering files. Free,
 DOS/Win/UNIX now 2.0.6; see <URL:http://www.merlyn.demon.co.uk/pc-links.htm>.

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


Thread

JScript - is a file of a known Type? Dr J R Stockton <reply1201@merlyn.demon.co.uk> - 2012-01-03 17:09 +0000
  Re: JScript - is a file of a known Type? "Mayayana" <mayayana@invalid.nospam> - 2012-01-03 21:13 -0500
    Re: JScript - is a file of a known Type? Todd Vargo <tlvargo@sbcglobal.netz> - 2012-01-04 00:55 -0500
      Re: JScript - is a file of a known Type? "Mayayana" <mayayana@invalid.nospam> - 2012-01-04 09:18 -0500
        Re: JScript - is a file of a known Type? "Dave \"Crash\" Dummy" <invalid@invalid.invalid> - 2012-01-04 09:40 -0500
          Re: JScript - is a file of a known Type? "Mayayana" <mayayana@invalid.nospam> - 2012-01-04 10:23 -0500
            Re: JScript - is a file of a known Type? Todd Vargo <tlvargo@sbcglobal.netz> - 2012-01-04 20:22 -0500
            Re: JScript - is a file of a known Type? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2012-01-05 22:01 -0800
              Re: JScript - is a file of a known Type? John G Harris <john@nospam.demon.co.uk> - 2012-01-06 11:04 +0000
                Re: JScript - is a file of a known Type? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2012-01-06 04:26 -0800
                Re: JScript - is a file of a known Type? John G Harris <john@nospam.demon.co.uk> - 2012-01-06 14:58 +0000
                Re: JScript - is a file of a known Type? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2012-01-06 12:27 -0800
              Re: JScript - is a file of a known Type? Dr J R Stockton <reply1201@merlyn.demon.co.uk> - 2012-01-07 21:54 +0000
          JScript - WScript output similar to CScript output> Dr J R Stockton <reply1201@merlyn.demon.co.uk> - 2012-01-05 20:29 +0000
            Re: JScript - WScript output similar to CScript output> "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2012-01-05 22:05 -0800
              Re: JScript - WScript output similar to CScript output> Bwig Zomberi <zomberiMAPSONNOSPAM@gmail.invalid> - 2012-01-06 14:31 +0530
                Re: JScript - WScript output similar to CScript output> Dr J R Stockton <reply1201@merlyn.demon.co.uk> - 2012-01-07 21:14 +0000
              Re: JScript - WScript output similar to CScript output> Dr J R Stockton <reply1201@merlyn.demon.co.uk> - 2012-01-07 21:10 +0000
                Re: JScript - WScript output similar to CScript output> "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2012-01-08 14:52 -0800
                Re: JScript - WScript output similar to CScript output> Dr J R Stockton <reply1202@merlyn.demon.co.uk> - 2012-01-09 23:45 +0000
                Re: JScript - WScript output similar to CScript output> Todd Vargo <tlvargo@sbcglobal.netz> - 2012-01-10 00:27 -0500
                Re: JScript - WScript output similar to CScript output> Dr J R Stockton <J.R.Stockton@physics.org> - 2012-01-10 13:40 -0800
                Re: JScript - WScript output similar to CScript output> "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2012-01-10 17:04 -0800
                Re: JScript - WScript output similar to CScript output> Dr J R Stockton <reply1202@merlyn.demon.co.uk> - 2012-01-12 23:43 +0000
                Re: JScript - WScript output similar to CScript output> "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2012-01-12 22:36 -0800
                Re: JScript - WScript output similar to CScript output> "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2012-01-12 22:47 -0800
                Re: JScript - WScript output similar to CScript output> Dr J R Stockton <J.R.Stockton@physics.org> - 2012-01-14 12:15 -0800
            Re: JScript - WScript output similar to CScript output> Bwig Zomberi <zomberiMAPSONNOSPAM@gmail.invalid> - 2012-01-06 14:43 +0530
            Re: JScript - WScript output similar to CScript output> Todd Vargo <tlvargo@sbcglobal.netz> - 2012-01-06 05:20 -0500
              Re: JScript - WScript output similar to CScript output> "Mayayana" <mayayana@invalid.nospam> - 2012-01-06 08:33 -0500
                Re: JScript - WScript output similar to CScript output> Dr J R Stockton <reply1201@merlyn.demon.co.uk> - 2012-01-07 20:11 +0000

csiph-web