PageRenderTime 13ms CodeModel.GetById 9ms app.highlight 3ms RepoModel.GetById 0ms app.codeStats 0ms

/3rd_party/wtl/AppWizMobile/setup90.js

https://code.google.com/p/softart/
JavaScript | 109 lines | 83 code | 13 blank | 13 comment | 8 complexity | 998642a6c08d1173ad93d0441d1c2249 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-3-Clause, JSON, MPL-2.0-no-copyleft-exception, GPL-2.0, GPL-3.0, LGPL-3.0, BSD-2-Clause
  1// Windows Template Library - WTL version 8.1
  2// Copyright (C) Microsoft Corporation. All rights reserved.
  3//
  4// This file is a part of the Windows Template Library.
  5// The use and distribution terms for this software are covered by the
  6// Common Public License 1.0 (http://opensource.org/licenses/cpl1.0.php)
  7// which can be found in the file CPL.TXT at the root of this distribution.
  8// By using this software in any fashion, you are agreeing to be bound by
  9// the terms of this license. You must not remove this notice, or
 10// any other, from this software.
 11
 12// Setup program for the Windows Mobile WTL App Wizard for VC++ 9.0 (Orcas)
 13
 14// Elevated privilege check
 15try 
 16{
 17	var bElevated = false;
 18	var Args = WScript.Arguments;
 19	for(i = 0; i < Args.length ; i++)
 20		if (bElevated = (Args(i) == "/elevated"))
 21			break;
 22
 23	var AppShell = WScript.CreateObject("Shell.Application");
 24
 25	if (!bElevated && AppShell.IsRestricted("System", "EnableLUA")) 
 26		throw (WScript.Interactive == true) ? "Restricted" : "Elevation required.";
 27}
 28catch(e)
 29{
 30	if (e == "Restricted")
 31		AppShell.ShellExecute("WScript.exe", "\"" + WScript.ScriptFullName + "\"" + " /elevated", null, "RunAs");
 32	else
 33		WScript.Echo("Error: " + e);
 34
 35	WScript.Quit();
 36}
 37
 38// WTLMobile AppWizard registration
 39try
 40{
 41	var fso = WScript.CreateObject("Scripting.FileSystemObject");
 42	var SourceBase = fso.GetParentFolderName(WScript.ScriptFullName) + "\\Files";
 43	var Source = SourceBase + "\\WTLMobile.";
 44
 45	var shell = WScript.CreateObject("WScript.Shell");
 46	var DestBase;
 47	try {
 48	    DestBase = shell.RegRead("HKLM\\Software\\Microsoft\\VisualStudio\\9.0\\Setup\\VC\\ProductDir") + "\\vcprojects";
 49	}
 50	catch (e) {
 51	    try {
 52	        DestBase = shell.RegRead("HKLM\\Software\\Wow6432Node\\Microsoft\\VisualStudio\\9.0\\Setup\\VC\\ProductDir") + "\\vcprojects";
 53	    }
 54	    catch (e) {
 55	        WScript.Echo("ERROR: Cannot find where Visual Studio 9.0 is installed.");
 56	        WScript.Quit();
 57	    }
 58	}
 59	var Dest = DestBase + "\\WTLMobile.";
 60
 61	var vsz = Source + "vsz";
 62	var vsdir = Source + "vsdir";
 63	var vszText, vsdirText; 
 64
 65	var ts = fso.OpenTextFile(vsz,1);
 66	vszText = ts.ReadAll();
 67	ts.Close();
 68	vszText = vszText.replace(/8\.0/g,"9.0");
 69	vszText = vszText.replace(/(.+PATH\s=).+/,"$1" + SourceBase +"\"\r");
 70	ts = fso.OpenTextFile(vsdir, 1);
 71	vsdirText = ts.ReadAll();
 72	ts.Close();
 73
 74	fso.CopyFile(Source + "ico", Dest + "ico");
 75
 76	ts = fso.OpenTextFile(Dest + "vsz", 2, true);
 77	ts.Write(vszText);
 78	ts.Close();
 79
 80	ts = fso.OpenTextFile(Dest + "vsdir", 2, true);
 81	ts.Write(vsdirText);
 82	ts.Close();
 83
 84	vsdirText = "..\\" + vsdirText;
 85
 86	var DestFolder = DestBase + "\\WTL";
 87	if(!fso.FolderExists(DestFolder))
 88		fso.CreateFolder(DestFolder);
 89
 90	Dest = DestBase + "\\WTL\\WTLMobile.vsdir";
 91	ts = fso.OpenTextFile(Dest, 2, true);
 92	ts.Write(vsdirText);
 93	ts.Close();
 94
 95	DestFolder = DestBase + "\\smartdevice";
 96	if(!fso.FolderExists(DestFolder))
 97		fso.CreateFolder(DestFolder);
 98
 99	Dest = DestBase + "\\smartdevice\\WTLMobile.vsdir";
100	ts = fso.OpenTextFile(Dest, 2, true);
101	ts.Write(vsdirText);
102	ts.Close();
103
104	WScript.Echo("WTL Mobile App Wizard successfully installed!");
105}
106catch(e)
107{
108	WScript.Echo("Error " + e);
109}