/3rd_party/wtl/AppWizMobile/setup90.js

https://code.google.com/p/softart/ · JavaScript · 109 lines · 78 code · 18 blank · 13 comment · 10 complexity · 998642a6c08d1173ad93d0441d1c2249 MD5 · raw file

  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. // Setup program for the Windows Mobile WTL App Wizard for VC++ 9.0 (Orcas)
  12. // Elevated privilege check
  13. try
  14. {
  15. var bElevated = false;
  16. var Args = WScript.Arguments;
  17. for(i = 0; i < Args.length ; i++)
  18. if (bElevated = (Args(i) == "/elevated"))
  19. break;
  20. var AppShell = WScript.CreateObject("Shell.Application");
  21. if (!bElevated && AppShell.IsRestricted("System", "EnableLUA"))
  22. throw (WScript.Interactive == true) ? "Restricted" : "Elevation required.";
  23. }
  24. catch(e)
  25. {
  26. if (e == "Restricted")
  27. AppShell.ShellExecute("WScript.exe", "\"" + WScript.ScriptFullName + "\"" + " /elevated", null, "RunAs");
  28. else
  29. WScript.Echo("Error: " + e);
  30. WScript.Quit();
  31. }
  32. // WTLMobile AppWizard registration
  33. try
  34. {
  35. var fso = WScript.CreateObject("Scripting.FileSystemObject");
  36. var SourceBase = fso.GetParentFolderName(WScript.ScriptFullName) + "\\Files";
  37. var Source = SourceBase + "\\WTLMobile.";
  38. var shell = WScript.CreateObject("WScript.Shell");
  39. var DestBase;
  40. try {
  41. DestBase = shell.RegRead("HKLM\\Software\\Microsoft\\VisualStudio\\9.0\\Setup\\VC\\ProductDir") + "\\vcprojects";
  42. }
  43. catch (e) {
  44. try {
  45. DestBase = shell.RegRead("HKLM\\Software\\Wow6432Node\\Microsoft\\VisualStudio\\9.0\\Setup\\VC\\ProductDir") + "\\vcprojects";
  46. }
  47. catch (e) {
  48. WScript.Echo("ERROR: Cannot find where Visual Studio 9.0 is installed.");
  49. WScript.Quit();
  50. }
  51. }
  52. var Dest = DestBase + "\\WTLMobile.";
  53. var vsz = Source + "vsz";
  54. var vsdir = Source + "vsdir";
  55. var vszText, vsdirText;
  56. var ts = fso.OpenTextFile(vsz,1);
  57. vszText = ts.ReadAll();
  58. ts.Close();
  59. vszText = vszText.replace(/8\.0/g,"9.0");
  60. vszText = vszText.replace(/(.+PATH\s=).+/,"$1" + SourceBase +"\"\r");
  61. ts = fso.OpenTextFile(vsdir, 1);
  62. vsdirText = ts.ReadAll();
  63. ts.Close();
  64. fso.CopyFile(Source + "ico", Dest + "ico");
  65. ts = fso.OpenTextFile(Dest + "vsz", 2, true);
  66. ts.Write(vszText);
  67. ts.Close();
  68. ts = fso.OpenTextFile(Dest + "vsdir", 2, true);
  69. ts.Write(vsdirText);
  70. ts.Close();
  71. vsdirText = "..\\" + vsdirText;
  72. var DestFolder = DestBase + "\\WTL";
  73. if(!fso.FolderExists(DestFolder))
  74. fso.CreateFolder(DestFolder);
  75. Dest = DestBase + "\\WTL\\WTLMobile.vsdir";
  76. ts = fso.OpenTextFile(Dest, 2, true);
  77. ts.Write(vsdirText);
  78. ts.Close();
  79. DestFolder = DestBase + "\\smartdevice";
  80. if(!fso.FolderExists(DestFolder))
  81. fso.CreateFolder(DestFolder);
  82. Dest = DestBase + "\\smartdevice\\WTLMobile.vsdir";
  83. ts = fso.OpenTextFile(Dest, 2, true);
  84. ts.Write(vsdirText);
  85. ts.Close();
  86. WScript.Echo("WTL Mobile App Wizard successfully installed!");
  87. }
  88. catch(e)
  89. {
  90. WScript.Echo("Error " + e);
  91. }