Files
rappaurio-sae501_502/app/node_modules/cejs/_documents/JsDoc/symbols/src/D__USB_cgi-bin_lib_JS_OS_Windows.origin.js.html
2023-09-25 13:27:24 +02:00

376 lines
75 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"> <style>
.KEYW {color: #933;}
.COMM {color: #bbb; font-style: italic;}
.NUMB {color: #393;}
.STRN {color: #393;}
.REGX {color: #339;}
.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
</style></head><body><pre><span class='line'> 1</span> <span class="TOKN"></span><span class="WHIT">
<span class='line'> 2</span> </span><span class="COMM">/**
<span class='line'> 3</span> * @name CeL function for Windows
<span class='line'> 4</span> * @fileoverview
<span class='line'> 5</span> * 本檔案包含了 Windows 專用的 functions。
<span class='line'> 6</span> * @since
<span class='line'> 7</span> */</span><span class="WHIT">
<span class='line'> 8</span>
<span class='line'> 9</span>
<span class='line'> 10</span> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">CeL</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 11</span>
<span class='line'> 12</span> </span><span class="COMM">/**
<span class='line'> 13</span> * 本 module 之 name(id)&lt;span style="text-decoration:line-through;">不設定時會從呼叫時之 path 取得&lt;/span>。
<span class='line'> 14</span> * @type String
<span class='line'> 15</span> * @constant
<span class='line'> 16</span> * @inner
<span class='line'> 17</span> * @ignore
<span class='line'> 18</span> */</span><span class="WHIT">
<span class='line'> 19</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">module_name</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'OS.Windows'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 20</span>
<span class='line'> 21</span> </span><span class="COMM">//===================================================</span><span class="WHIT">
<span class='line'> 22</span> </span><span class="COMM">/**
<span class='line'> 23</span> * 若欲 include 整個 module 時,需囊括之 code。
<span class='line'> 24</span> * @type Function
<span class='line'> 25</span> * @param {Function} library_namespace namespace of library
<span class='line'> 26</span> * @param load_arguments 呼叫時之 argument(s)
<span class='line'> 27</span> * @return
<span class='line'> 28</span> * @name CeL.OS.Windows
<span class='line'> 29</span> * @constant
<span class='line'> 30</span> * @inner
<span class='line'> 31</span> * @ignore
<span class='line'> 32</span> */</span><span class="WHIT">
<span class='line'> 33</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">code_for_including</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">library_namespace</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">load_arguments</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 34</span>
<span class='line'> 35</span> </span><span class="COMM">// requires</span><span class="WHIT">
<span class='line'> 36</span> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">eval</span><span class="PUNC">(</span><span class="NAME">library_namespace.use_function</span><span class="PUNC">(</span><span class="WHIT">
<span class='line'> 37</span> </span><span class="WHIT"> </span><span class="STRN">'code.compatibility.is_web,code.compatibility.is_HTA'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 38</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 39</span>
<span class='line'> 40</span>
<span class='line'> 41</span> </span><span class="COMM">/**
<span class='line'> 42</span> * null module constructor
<span class='line'> 43</span> * @class web 的 functions
<span class='line'> 44</span> */</span><span class="WHIT">
<span class='line'> 45</span> </span><span class="NAME">CeL.OS.Windows</span><span class="WHIT">
<span class='line'> 46</span> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 47</span> </span><span class="WHIT"> </span><span class="COMM">// null module constructor</span><span class="WHIT">
<span class='line'> 48</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 49</span>
<span class='line'> 50</span> </span><span class="COMM">/**
<span class='line'> 51</span> * for JSDT: 有 prototype 才會將之當作 Class
<span class='line'> 52</span> */</span><span class="WHIT">
<span class='line'> 53</span> </span><span class="NAME">CeL.OS.Windows</span><span class="WHIT">
<span class='line'> 54</span> </span><span class="PUNC">.</span><span class="NAME">prototype</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 55</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 56</span>
<span class='line'> 57</span>
<span class='line'> 58</span>
<span class='line'> 59</span>
<span class='line'> 60</span> </span><span class="COMM">//initialization_WScript_Objects();</span><span class="WHIT">
<span class='line'> 61</span> </span><span class="COMM">//initialization_WScript_Objects[generateCode.dLK]='is_web,is_HTA,ScriptHost,dirSp'.split(',');</span><span class="WHIT">
<span class='line'> 62</span> </span><span class="COMM">//initialization_WScript_Objects[generateCode.dLK].push('*var args,WshShell,WinShell,WinShell,fso;initialization_WScript_Objects();');</span><span class="WHIT">
<span class='line'> 63</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">initialization_WScript_Objects</span><span class="PUNC">(</span><span class="NAME">onlyHTML</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 64</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">library_namespace.WScript</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="WHIT">
<span class='line'> 65</span> </span><span class="WHIT"> </span><span class="COMM">// && typeof WScript.constructor=='undefined'</span><span class="WHIT">
<span class='line'> 66</span> </span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 67</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ScriptHost</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">WScript.FullName</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">lastIndexOf</span><span class="PUNC">(</span><span class="NAME">dirSp</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 68</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 69</span> </span><span class="WHIT"> </span><span class="NAME">ScriptHost</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ScriptHost.slice</span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 70</span> </span><span class="WHIT"> </span><span class="NAME">WshShell</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">WScript.CreateObject</span><span class="PUNC">(</span><span class="STRN">"WScript.Shell"</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">WinShell</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">WScript</span><span class="WHIT">
<span class='line'> 71</span> </span><span class="WHIT"> </span><span class="PUNC">.</span><span class="NAME">CreateObject</span><span class="PUNC">(</span><span class="STRN">"Shell.Application"</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">fso</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">WScript</span><span class="WHIT">
<span class='line'> 72</span> </span><span class="WHIT"> </span><span class="PUNC">.</span><span class="NAME">CreateObject</span><span class="PUNC">(</span><span class="STRN">"Scripting.FileSystemObject"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 73</span> </span><span class="WHIT"> </span><span class="NAME">args</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 74</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">=</span><span class="NAME">WScript.Arguments</span><span class="PUNC">,</span><span class="NAME">l</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">a.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">l</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 75</span> </span><span class="WHIT"> </span><span class="NAME">args.push</span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 76</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 77</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="COMM">// 用 IE 跑不能用 ActiveXObject</span><span class="WHIT">
<span class='line'> 78</span> </span><span class="WHIT"> </span><span class="PUNC">!</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">onlyHTML</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">is_web</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">is_HTA</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">onlyHTML</span><span class="PUNC">)</span><span class="COMM">// !onlyHTML//</span><span class="WHIT">
<span class='line'> 79</span> </span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">ActiveXObject</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 80</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="COMM">// 在.hta中typeof WScript=='undefined'</span><span class="WHIT">
<span class='line'> 81</span> </span><span class="WHIT"> </span><span class="COMM">// http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/reference/objects/shell/application.asp</span><span class="WHIT">
<span class='line'> 82</span> </span><span class="WHIT"> </span><span class="COMM">// http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/programmersguide/shell_intro.asp</span><span class="WHIT">
<span class='line'> 83</span> </span><span class="WHIT"> </span><span class="NAME">WshShell</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">ActiveXObject</span><span class="PUNC">(</span><span class="STRN">"WScript.Shell"</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 84</span> </span><span class="WHIT"> </span><span class="NAME">WinShell</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">ActiveXObject</span><span class="PUNC">(</span><span class="STRN">"Shell.Application"</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 85</span> </span><span class="WHIT"> </span><span class="NAME">fso</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">ActiveXObject</span><span class="PUNC">(</span><span class="STRN">"Scripting.FileSystemObject"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 86</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">is_HTA.HTA</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 87</span> </span><span class="WHIT"> </span><span class="NAME">args</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">is_HTA.HTA.commandLine.split</span><span class="PUNC">(</span><span class="REGX">/\s+/</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">args.shift</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 88</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 89</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 90</span> </span><span class="WHIT"> </span><span class="COMM">// 判斷假如尚未load則排入以確定是否為HTA</span><span class="WHIT">
<span class='line'> 91</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">is_web</span><span class="PUNC">(</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">is_HTA</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 92</span> </span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="NAME">document.getElementsByTagName</span><span class="PUNC">(</span><span class="STRN">'body'</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">length</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 93</span> </span><span class="WHIT"> </span><span class="NAME">setTimeout</span><span class="PUNC">(</span><span class="STRN">'initialization_WScript_Objects();'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">9</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 94</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 95</span>
<span class='line'> 96</span> </span><span class="WHIT"> </span><span class="COMM">// if (typeof newXMLHttp == 'function') XMLHttp = newXMLHttp();</span><span class="WHIT">
<span class='line'> 97</span>
<span class='line'> 98</span> </span><span class="COMM">/* @cc_on
<span class='line'> 99</span> @if(@_jscript_version >= 5)
<span class='line'>100</span> // JScript gives us Conditional compilation, we can cope with old IE versions.
<span class='line'>101</span> // and security blocked creation of the objects.
<span class='line'>102</span> ;//else..
<span class='line'>103</span> @end@*/</span><span class="WHIT">
<span class='line'>104</span>
<span class='line'>105</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>106</span>
<span class='line'>107</span>
<span class='line'>108</span>
<span class='line'>109</span>
<span class='line'>110</span>
<span class='line'>111</span>
<span class='line'>112</span> </span><span class="COMM">/* 2007/11/17 23:3:53
<span class='line'>113</span> 使用 ADSI (Active Directory Service Interface) 存取資料
<span class='line'>114</span> http://support.microsoft.com/kb/234001
<span class='line'>115</span> http://www.dbworld.com.tw/member/article/010328b.htm
<span class='line'>116</span> http://support.microsoft.com/kb/216393
<span class='line'>117</span> */</span><span class="WHIT">
<span class='line'>118</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">addUser</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">,</span><span class="NAME">pw</span><span class="PUNC">,</span><span class="NAME">group</span><span class="PUNC">,</span><span class="NAME">computer</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>119</span> </span><span class="WHIT"> </span><span class="COMM">// http://msdn.microsoft.com/library/en-us/script56/html/wsmthenumprinterconnections.asp</span><span class="WHIT">
<span class='line'>120</span> </span><span class="WHIT"> </span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>121</span> </span><span class="WHIT"> </span><span class="COMM">// 連上伺服器</span><span class="WHIT">
<span class='line'>122</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">oIADs</span><span class="PUNC">,</span><span class="NAME">o</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>123</span> </span><span class="WHIT"> </span><span class="COMM">// 利用Create指令指定產生一個新的使用者類別以及使用者帳號的名稱。使用SetInfo的指令將目錄服務中的資料更新。</span><span class="WHIT">
<span class='line'>124</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="PUNC">{</span><span class="NAME">oIADs</span><span class="PUNC">=</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Enumerator</span><span class="PUNC">(</span><span class="NAME">GetObject</span><span class="PUNC">(</span><span class="NAME">computer</span><span class="PUNC">=</span><span class="STRN">'WinNT://'</span><span class="PUNC">+</span><span class="PUNC">(</span><span class="NAME">computer</span><span class="PUNC">||</span><span class="PUNC">(</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">ActiveXObject</span><span class="PUNC">(</span><span class="STRN">'WScript.Network'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">ComputerName</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="COMM">//WScript.CreateObject('WScript.Network')</span><span class="WHIT">
<span class='line'>125</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">oIADs</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="COMM">//try{</span><span class="WHIT">
<span class='line'>126</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>127</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="PUNC">{</span><span class="NAME">o</span><span class="PUNC">=</span><span class="NAME">oIADs.Create</span><span class="PUNC">(</span><span class="STRN">'user'</span><span class="PUNC">,</span><span class="NAME">name</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="NAME">o</span><span class="PUNC">=</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Enumerator</span><span class="PUNC">(</span><span class="NAME">GetObject</span><span class="PUNC">(</span><span class="NAME">computer</span><span class="PUNC">+</span><span class="STRN">'/'</span><span class="PUNC">+</span><span class="NAME">name</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>128</span> </span><span class="WHIT"> </span><span class="KEYW">with</span><span class="PUNC">(</span><span class="NAME">o</span><span class="PUNC">)</span><span class="NAME">SetPassword</span><span class="PUNC">(</span><span class="NAME">pw</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="COMM">/*FullName=name,Description=name,*/</span><span class="NAME">SetInfo</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>129</span> </span><span class="WHIT"> </span><span class="COMM">// Administrators</span><span class="WHIT">
<span class='line'>130</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">group</span><span class="PUNC">)</span><span class="PUNC">(</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Enumerator</span><span class="PUNC">(</span><span class="NAME">GetObject</span><span class="PUNC">(</span><span class="NAME">computer</span><span class="PUNC">+</span><span class="STRN">'/'</span><span class="PUNC">+</span><span class="NAME">group</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">Add</span><span class="PUNC">(</span><span class="NAME">o.ADsPath</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// o.ADsPath: computer+'/'+name</span><span class="WHIT">
<span class='line'>131</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">o</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// 得到用戶</span><span class="WHIT">
<span class='line'>132</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>133</span>
<span class='line'>134</span> </span><span class="WHIT"> </span><span class="COMM">//oIADs.Filter=['user'];//new VBArray('user'); // no use, 改用.AccountDisabled</span><span class="WHIT">
<span class='line'>135</span> </span><span class="WHIT"> </span><span class="NAME">o</span><span class="PUNC">=</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>136</span> </span><span class="WHIT"> </span><span class="COMM">// http://msdn2.microsoft.com/en-us/library/aa746343.aspx</span><span class="WHIT">
<span class='line'>137</span> </span><span class="WHIT"> </span><span class="COMM">// 對所有的oIADs通常有Name,Description</span><span class="WHIT">
<span class='line'>138</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">,</span><span class="NAME">j</span><span class="PUNC">,</span><span class="NAME">a</span><span class="PUNC">,</span><span class="NAME">b</span><span class="PUNC">,</span><span class="NAME">p</span><span class="PUNC">=</span><span class="STRN">'Name,AccountDisabled,Description,FullName,HomeDirectory,IsAccountLocked,LastLogin,LoginHours,LoginScript,MaxStorage,PasswordExpirationDate,PasswordMinimumLength,PasswordRequired,Profile'</span><span class="PUNC">.</span><span class="NAME">split</span><span class="PUNC">(</span><span class="STRN">','</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="PUNC">!</span><span class="NAME">oIADs.atEnd</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="NAME">oIADs.moveNext</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">oIADs.item</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">AccountDisabled</span><span class="PUNC">==</span><span class="STRN">'boolean'</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>139</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">=</span><span class="NAME">oIADs.item</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="NAME">j</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NAME">a</span><span class="PUNC">=</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="NAME">j</span><span class="PUNC">&lt;</span><span class="NAME">p.length</span><span class="PUNC">;</span><span class="NAME">j</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">b</span><span class="PUNC">=</span><span class="NAME">p</span><span class="PUNC">[</span><span class="NAME">j</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="KEYW">try</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>140</span> </span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">[</span><span class="NAME">b</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="NAME">i</span><span class="PUNC">[</span><span class="NAME">b</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>141</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">a</span><span class="PUNC">[</span><span class="NAME">b</span><span class="PUNC">]</span><span class="PUNC">==</span><span class="STRN">'date'</span><span class="PUNC">)</span><span class="NAME">a</span><span class="PUNC">[</span><span class="NAME">b</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Date</span><span class="PUNC">(</span><span class="NAME">a</span><span class="PUNC">[</span><span class="NAME">b</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>142</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>143</span> </span><span class="WHIT"> </span><span class="COMM">//alert('addUser():\n['+i.name+'] does not has:\n'+b);</span><span class="WHIT">
<span class='line'>144</span> </span><span class="WHIT"> </span><span class="COMM">// 刪掉沒有的屬性。但僅少數不具有所以不能全刪。XP中沒有(?):,AccountExpirationDate,BadLoginAddress,BadLoginCount,Department,Division,EmailAddress,EmployeeID,FaxNumber,FirstName,GraceLoginsAllowed,GraceLoginsRemaining,HomePage,Languages,LastFailedLogin,LastLogoff,LastName,LoginWorkstations,Manager,MaxLogins,NamePrefix,NameSuffix,OfficeLocations,OtherName,PasswordLastChanged,Picture,PostalAddresses,PostalCodes,RequireUniquePassword,SeeAlso,TelephoneHome,TelephoneMobile,TelephoneNumber,TelephonePager,Title</span><span class="WHIT">
<span class='line'>145</span> </span><span class="WHIT"> </span><span class="COMM">//p[j]=0;//delete p[j];</span><span class="WHIT">
<span class='line'>146</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>147</span> </span><span class="WHIT"> </span><span class="NAME">o</span><span class="PUNC">[</span><span class="NAME">i.name</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="NAME">a</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>148</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>149</span>
<span class='line'>150</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">o</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>151</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="COMM">//catch(e){}</span><span class="WHIT">
<span class='line'>152</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>153</span> </span><span class="COMM">//a=addUser();for(i in a){d=[];for(j in a[i])d.push(j+': '+a[i][j]);alert(d.join('\n'));}</span><span class="WHIT">
<span class='line'>154</span>
<span class='line'>155</span>
<span class='line'>156</span>
<span class='line'>157</span>
<span class='line'>158</span>
<span class='line'>159</span> </span><span class="COMM">// 特殊功能 -------------------------------------------------------</span><span class="WHIT">
<span class='line'>160</span>
<span class='line'>161</span> </span><span class="COMM">/* 取得基本環境值
<span class='line'>162</span> // test
<span class='line'>163</span> if(0){
<span class='line'>164</span> var o=WinEnvironment;
<span class='line'>165</span> if(typeof o=='object'){var i,t='';for(i in o)t+=i+'='+o[i]+'\n';alert(t);}
<span class='line'>166</span> o=SpecialFolder;
<span class='line'>167</span> if(typeof o=='object'){var i,t='';for(i in o)t+=i+'='+o[i]+'\n';alert(t);}
<span class='line'>168</span> o=Network;
<span class='line'>169</span> if(typeof o=='object'){var i,t='';for(i in o)t+=i+'='+o[i]+'\n';alert(t);}
<span class='line'>170</span> o=NetDrive;
<span class='line'>171</span> if(typeof o=='object'){var i,t='';for(i in o)t+=i+'='+o[i]+'\n';alert(t);}
<span class='line'>172</span> o=NetPrinter;
<span class='line'>173</span> if(typeof o=='object'){var i,t='';for(i in o)t+=i+'='+o[i]+'\n';alert(t);}
<span class='line'>174</span> }
<span class='line'>175</span> */</span><span class="WHIT">
<span class='line'>176</span> </span><span class="COMM">//setTool();</span><span class="WHIT">
<span class='line'>177</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">WinEnvironment</span><span class="PUNC">,</span><span class="NAME">SpecialFolder</span><span class="PUNC">,</span><span class="NAME">Network</span><span class="PUNC">,</span><span class="NAME">NetDrive</span><span class="PUNC">,</span><span class="NAME">NetPrinter</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>178</span> </span><span class="NAME">getEnvironment</span><span class="PUNC">[</span><span class="NAME">generateCode.dLK</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="STRN">'WinEnvironment,SpecialFolder,Network,NetDrive,NetPrinter,*getEnvironment();'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>179</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">getEnvironment</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>180</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">WshShell</span><span class="PUNC">!=</span><span class="STRN">'object'</span><span class="PUNC">||</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">SpecialFolder</span><span class="PUNC">==</span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>181</span>
<span class='line'>182</span> </span><span class="WHIT"> </span><span class="NAME">WinEnvironment</span><span class="PUNC">=</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="NAME">Network</span><span class="PUNC">=</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="NAME">NetDrive</span><span class="PUNC">=</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="NAME">NetPrinter</span><span class="PUNC">=</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>183</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">,</span><span class="NAME">j</span><span class="PUNC">,</span><span class="NAME">k</span><span class="PUNC">,</span><span class="NAME">o</span><span class="PUNC">=</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Enumerator</span><span class="PUNC">(</span><span class="NAME">WshShell.Environment</span><span class="PUNC">(</span><span class="STRN">"Process"</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="COMM">/* Win9x、NTAdministratorもしくはほかのユーザーの区別なく、すべての場合でエラーが発生しないようにするには、strTypeに"PROCESS"を指定するとよいでしょう。
<span class='line'>184</span> 機器上所有已定義的環境變數Windows environment variables http://msdn2.microsoft.com/en-us/library/fd7hxfdd(VS.85).aspx http://www.roy.hi-ho.ne.jp/mutaguchi/wsh/refer/lesson11.htm http://nacelle.info/wsh/03001.php http://www.cs.odu.edu/~wild/windowsNT/Spring00/wsh.htm
<span class='line'>185</span> usual: ALLUSERSPROFILE,APPDATA,BLASTER,CLASSPATH,CLIENTNAME,CommonProgramFiles,COMPUTERNAME,ComSpec,DEVMGR_SHOW_NONPRESENT_DEVICES,HOMEDRIVE,HOMEPATH,INCLUDE,LIB,LOGONSERVER,NUMBER_OF_PROCESSORS,OS,Os2LibPath,Path,PATHEXT,PROCESSOR_ARCHITECTURE,PROCESSOR_IDENTIFIER,PROCESSOR_LEVEL,PROCESSOR_REVISION,ProgramFiles,PROMPT,QTJAVA,SESSIONNAME,SystemDrive,SystemRoot,TEMP,TMP,USERDOMAIN,USERNAME,USERPROFILE,VS71COMNTOOLS,VSCOMNTOOLS,windir,winbootdir
<span class='line'>186</span>
<span class='line'>187</span> WshShell.ExpandEnvironmentStrings("%windir%\\notepad.exe"); WshShell.Environment("Process")("TMP")
<span class='line'>188</span> MyShortcut.IconLocation = WSHShell.ExpandEnvironmentStrings("%windir%\\notepad.exe, 0");
<span class='line'>189</span>
<span class='line'>190</span> System HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
<span class='line'>191</span> User HKEY_CURRENT_USER\Environment
<span class='line'>192</span> Volatile HKEY_CURRENT_USER\Volatile Environment ログオフとともにクリアされる
<span class='line'>193</span> Process, or 98:'WshShell.Environment'==WshShell.Environment("Process"),NT:==WshShell.Environment("System")ただし、Administratorアカウントを持つユーザー以外は、strTypeに"SYSTEM"を指定、もしくは省略するとエラーになります。
<span class='line'>194</span> */</span><span class="WHIT">
<span class='line'>195</span> </span><span class="WHIT"> </span><span class="KEYW">while</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">o.atEnd</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>196</span> </span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">=</span><span class="NAME">o.item</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>197</span> </span><span class="WHIT"> </span><span class="NAME">j</span><span class="PUNC">=</span><span class="NAME">i.indexOf</span><span class="PUNC">(</span><span class="STRN">'='</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="COMM">//if((j=i.indexOf('='))!=-1)</span><span class="WHIT">
<span class='line'>198</span> </span><span class="WHIT"> </span><span class="NAME">WinEnvironment</span><span class="PUNC">[</span><span class="NAME">i.slice</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NAME">j</span><span class="PUNC">)</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="NAME">i.substr</span><span class="PUNC">(</span><span class="NAME">j</span><span class="PUNC">+</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// value以';'作為分隔,若有必要可使用.split(';')</span><span class="WHIT">
<span class='line'>199</span> </span><span class="WHIT"> </span><span class="NAME">o.moveNext</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>200</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>201</span>
<span class='line'>202</span> </span><span class="WHIT"> </span><span class="COMM">// http://www.microsoft.com/japan/msdn/library/ja/script56/html/wsprospecialfolders.asp HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders</span><span class="WHIT">
<span class='line'>203</span> </span><span class="WHIT"> </span><span class="COMM">// VB中用For Each .. In可列舉出全部但JS則不行-_-所以得自己列舉</span><span class="WHIT">
<span class='line'>204</span> </span><span class="WHIT"> </span><span class="COMM">// fso.GetSpecialFolder( 0: Windows 文件夾 1: System 文件夾 2: Temp 文件夾 )</span><span class="WHIT">
<span class='line'>205</span> </span><span class="WHIT"> </span><span class="NAME">setObjValue</span><span class="PUNC">(</span><span class="STRN">'SpecialFolder'</span><span class="PUNC">,</span><span class="STRN">'AllUsersDesktop,AllUsersStartMenu,AllUsersPrograms,AllUsersStartup,AppData,Desktop,Favorites,Fonts,MyDocuments,NetHood,PrintHood,Programs,Recent,SendTo,StartMenu,Startup,Templates'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>206</span> </span><span class="WHIT"> </span><span class="NAME">o</span><span class="PUNC">=</span><span class="NAME">WshShell.SpecialFolders</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>207</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">SpecialFolder</span><span class="PUNC">)</span><span class="NAME">SpecialFolder</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="NAME">o</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>208</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="NAME">i</span><span class="PUNC">&lt;</span><span class="NAME">o.Count</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="NAME">SpecialFolder</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="NAME">o.item</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>209</span>
<span class='line'>210</span> </span><span class="WHIT"> </span><span class="NAME">o</span><span class="PUNC">=</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">ActiveXObject</span><span class="PUNC">(</span><span class="STRN">"WScript.Network"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="COMM">//WScript.CreateObject("WScript.Network");</span><span class="WHIT">
<span class='line'>211</span> </span><span class="WHIT"> </span><span class="COMM">// http://msdn.microsoft.com/library/en-us/script56/html/wsmthenumprinterconnections.asp</span><span class="WHIT">
<span class='line'>212</span> </span><span class="WHIT"> </span><span class="NAME">Network.ComputerName</span><span class="PUNC">=</span><span class="NAME">o.ComputerName</span><span class="PUNC">,</span><span class="NAME">Network.UserDomain</span><span class="PUNC">=</span><span class="NAME">o.UserDomain</span><span class="PUNC">,</span><span class="NAME">Network.UserName</span><span class="PUNC">=</span><span class="NAME">o.UserName</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>213</span> </span><span class="WHIT"> </span><span class="COMM">// Network Drive & Printer mappings</span><span class="WHIT">
<span class='line'>214</span> </span><span class="WHIT"> </span><span class="NAME">j</span><span class="PUNC">=</span><span class="NAME">o.EnumNetworkDrives</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="NAME">k</span><span class="PUNC">=</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>215</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="NAME">i</span><span class="PUNC">&lt;</span><span class="NAME">j.Count</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="NAME">i</span><span class="PUNC">+</span><span class="PUNC">=</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="NAME">NetDrive</span><span class="PUNC">[</span><span class="NAME">j.Item</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">?</span><span class="NAME">j.Item</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">:</span><span class="STRN">'Volatile'</span><span class="PUNC">+</span><span class="NAME">k</span><span class="PUNC">++</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="NAME">NetDrive</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">/</span><span class="NUMB">2</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="NAME">j.Item</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">+</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>216</span> </span><span class="WHIT"> </span><span class="NAME">j</span><span class="PUNC">=</span><span class="NAME">o.EnumPrinterConnections</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="NAME">k</span><span class="PUNC">=</span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>217</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">=</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="NAME">i</span><span class="PUNC">&lt;</span><span class="NAME">j.Count</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="NAME">i</span><span class="PUNC">+</span><span class="PUNC">=</span><span class="NUMB">2</span><span class="PUNC">)</span><span class="NAME">NetPrinter</span><span class="PUNC">[</span><span class="NAME">j.Item</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">)</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="NAME">NetPrinter</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">/</span><span class="NUMB">2</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="NAME">j.Item</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">+</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>218</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// function getEnvironment()</span><span class="WHIT">
<span class='line'>219</span>
<span class='line'>220</span>
<span class='line'>221</span>
<span class='line'>222</span>
<span class='line'>223</span> </span><span class="NAME">CeL.OS.Windows</span><span class="WHIT">
<span class='line'>224</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>225</span> </span><span class="COMM">/**
<span class='line'>226</span> * 取得 VB 的 Nothing
<span class='line'>227</span> * @returns VB 的 Nothing
<span class='line'>228</span> * @memberOf CeL.OS.Windows
<span class='line'>229</span> */</span><span class="WHIT">
<span class='line'>230</span> </span><span class="NAME">VBNothing</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>231</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>232</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">ActiveXObject</span><span class="PUNC">(</span><span class="STRN">"ADODB.RecordSet"</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">ActiveConnection</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>233</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>234</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>235</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>236</span>
<span class='line'>237</span> </span><span class="NAME">CeL.OS.Windows</span><span class="WHIT">
<span class='line'>238</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>239</span> </span><span class="COMM">/**
<span class='line'>240</span> * 轉換 VB 的 Safe Array 成為 JS Array.
<span class='line'>241</span> * @param vba VB 的 array
<span class='line'>242</span> * @returns
<span class='line'>243</span> * @memberOf CeL.OS.Windows
<span class='line'>244</span> */</span><span class="WHIT">
<span class='line'>245</span> </span><span class="NAME">VBA_to_JSA</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">vba</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>246</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>247</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">VBArray</span><span class="PUNC">(</span><span class="NAME">vba</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toArray</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>248</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>249</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>250</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>251</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>252</span>
<span class='line'>253</span> </span><span class="NAME">CeL.OS.Windows</span><span class="WHIT">
<span class='line'>254</span> </span><span class="PUNC">.</span><span class="WHIT">
<span class='line'>255</span> </span><span class="COMM">/**
<span class='line'>256</span> * 轉換JS Array成為VB的Safe Array.
<span class='line'>257</span> * Safe Array To JS Array: plaese use new VBArray().
<span class='line'>258</span> * JScriptの配列は実際にはCSV文字列だったりする。VBScriptのvartypeに食わせると8(VT_STRING)が返ってくることからもわかる。
<span class='line'>259</span> * @param array
<span class='line'>260</span> * @returns
<span class='line'>261</span> * @see
<span class='line'>262</span> * http://www.microsoft.com/japan/msdn/japan/msdn/library/ja/script56/html/js56jsobjvbarray.asp
<span class='line'>263</span> * @memberOf CeL.OS.Windows
<span class='line'>264</span> */</span><span class="WHIT">
<span class='line'>265</span> </span><span class="NAME">JSA_to_VBA</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">array</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>266</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">array</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>267</span> </span><span class="WHIT"> </span><span class="NAME">array</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="WHIT"> </span><span class="NAME">array</span><span class="WHIT"> </span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>268</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">dic</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">ActiveXObject</span><span class="PUNC">(</span><span class="STRN">"Scripting.Dictionary"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>269</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">array.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>270</span> </span><span class="WHIT"> </span><span class="NAME">dic.add</span><span class="PUNC">(</span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">array</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>271</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">dic.items</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>272</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>273</span>
<span class='line'>274</span>
<span class='line'>275</span>
<span class='line'>276</span>
<span class='line'>277</span> </span><span class="COMM">/* http://www.eggheadcafe.com/forumarchives/scriptingVisualBasicscript/Mar2006/post26047035.asp
<span class='line'>278</span> Application.DoEvents();
<span class='line'>279</span> */</span><span class="WHIT">
<span class='line'>280</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">DoEvents</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>281</span> </span><span class="WHIT"> </span><span class="COMM">// Triggers screen updates in an HTA...</span><span class="WHIT">
<span class='line'>282</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>283</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">DoEvents.w</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>284</span> </span><span class="WHIT"> </span><span class="NAME">DoEvents.w</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">WshShell</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">WshShell</span><span class="WHIT">
<span class='line'>285</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">ActiveXObject</span><span class="PUNC">(</span><span class="STRN">"WScript.Shell"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>286</span> </span><span class="WHIT"> </span><span class="NAME">DoEvents.w.Run</span><span class="PUNC">(</span><span class="STRN">"%COMSPEC% /c exit"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>287</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>288</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>289</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>290</span> </span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>291</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">DoNothing</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">DoEvents</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>292</span>
<span class='line'>293</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">Sleep</span><span class="PUNC">(</span><span class="NAME">_sec</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>294</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">isNaN</span><span class="PUNC">(</span><span class="NAME">_sec</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">_sec</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>295</span> </span><span class="WHIT"> </span><span class="NAME">_sec</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>296</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">WScript</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>297</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>298</span> </span><span class="WHIT"> </span><span class="COMM">// Win98的JScript沒有WScript.Sleep</span><span class="WHIT">
<span class='line'>299</span> </span><span class="WHIT"> </span><span class="NAME">WScript.Sleep</span><span class="PUNC">(</span><span class="NAME">_sec</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="NAME">e3</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>300</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>301</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>302</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
<span class='line'>303</span> </span><span class="WHIT"> </span><span class="COMM">// if(typeof window!='object')</span><span class="WHIT">
<span class='line'>304</span> </span><span class="WHIT"> </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>305</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">Sleep.w</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>306</span> </span><span class="WHIT"> </span><span class="NAME">Sleep.w</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">WshShell</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">WshShell</span><span class="WHIT">
<span class='line'>307</span> </span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">ActiveXObject</span><span class="PUNC">(</span><span class="STRN">"WScript.Shell"</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>308</span> </span><span class="WHIT"> </span><span class="NAME">Sleep.w.Run</span><span class="PUNC">(</span><span class="NAME">_sec</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">"%COMSPEC% /c ping -n "</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">_sec</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>309</span> </span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">" 127.0.0.1>nul 2>nul"</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"%COMSPEC% /c exit"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>310</span> </span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>311</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>312</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>313</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>314</span>
<span class='line'>315</span>
<span class='line'>316</span>
<span class='line'>317</span>
<span class='line'>318</span>
<span class='line'>319</span> </span><span class="COMM">/*
<span class='line'>320</span> 送key到application http://msdn.microsoft.com/library/en-us/script56/html/wsmthsendkeys.asp
<span class='line'>321</span> SendKeys('a') 送a
<span class='line'>322</span> SendKeys("a{1}4{2}5"); 送a,等1/10s,送4,等2/10s,送5
<span class='line'>323</span> timeOut: &lt;0:loop, 0 or not set:1 time, >0:be the time(ms)
<span class='line'>324</span> */</span><span class="WHIT">
<span class='line'>325</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">SendKeysU</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>326</span> </span><span class="NAME">SendKeys</span><span class="PUNC">[</span><span class="NAME">generateCode.dLK</span><span class="PUNC">]</span><span class="PUNC">=</span><span class="STRN">'Sleep'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>327</span> </span><span class="KEYW">function</span><span class="WHIT"> </span><span class="NAME">SendKeys</span><span class="PUNC">(</span><span class="NAME">keys</span><span class="PUNC">,</span><span class="NAME">appTitle</span><span class="PUNC">,</span><span class="NAME">timeOut</span><span class="PUNC">,</span><span class="NAME">timeInterval</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>328</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">WshShell</span><span class="PUNC">!=</span><span class="STRN">'object'</span><span class="PUNC">||</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">WshShell</span><span class="PUNC">!=</span><span class="STRN">'object'</span><span class="PUNC">&&</span><span class="KEYW">typeof</span><span class="PUNC">(</span><span class="NAME">WshShell</span><span class="PUNC">=</span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">ActiveXObject</span><span class="PUNC">(</span><span class="STRN">"WScript.Shell"</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">!=</span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>329</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">isNaN</span><span class="PUNC">(</span><span class="NAME">timeInterval</span><span class="PUNC">)</span><span class="PUNC">||</span><span class="NAME">timeInterval</span><span class="PUNC">&lt;</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="NAME">timeInterval</span><span class="PUNC">=</span><span class="NUMB">100</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// 時間間隔</span><span class="WHIT">
<span class='line'>330</span> </span><span class="WHIT"> </span><span class="NAME">timeOut</span><span class="PUNC">=</span><span class="NAME">timeOut</span><span class="PUNC">?</span><span class="NAME">timeOut</span><span class="PUNC">&lt;</span><span class="NUMB">0</span><span class="PUNC">?</span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">:</span><span class="NAME">Math.floor</span><span class="PUNC">(</span><span class="NAME">timeOut</span><span class="PUNC">/</span><span class="NAME">timeInterval</span><span class="PUNC">)</span><span class="PUNC">+</span><span class="NUMB">1</span><span class="PUNC">:</span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>331</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">appTitle</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>332</span> </span><span class="WHIT"> </span><span class="KEYW">while</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">WshShell.AppActivate</span><span class="PUNC">(</span><span class="NAME">appTitle</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>333</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">timeOut</span><span class="PUNC">--</span><span class="PUNC">)</span><span class="NAME">Sleep</span><span class="PUNC">(</span><span class="NAME">timeInterval</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>334</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">SendKeysU</span><span class="PUNC">)</span><span class="NAME">SendKeysU</span><span class="PUNC">=</span><span class="NUMB">100</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// 時間間隔單位</span><span class="WHIT">
<span class='line'>335</span> </span><span class="WHIT"> </span><span class="KEYW">while</span><span class="PUNC">(</span><span class="NAME">keys.match</span><span class="PUNC">(</span><span class="REGX">/\{([.\d]+)\}/</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>336</span> </span><span class="WHIT"> </span><span class="NAME">WshShell.SendKeys</span><span class="PUNC">(</span><span class="NAME">keys.substr</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="NAME">RegExp.index</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>337</span> </span><span class="WHIT"> </span><span class="NAME">Sleep</span><span class="PUNC">(</span><span class="NAME">SendKeysU</span><span class="PUNC">*</span><span class="NAME">RegExp.$1</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>338</span> </span><span class="WHIT"> </span><span class="NAME">keys</span><span class="PUNC">=</span><span class="NAME">keys.substr</span><span class="PUNC">(</span><span class="NAME">RegExp.lastIndex</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>339</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>340</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">WshShell.SendKeys</span><span class="PUNC">(</span><span class="NAME">keys</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>341</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>342</span>
<span class='line'>343</span>
<span class='line'>344</span>
<span class='line'>345</span>
<span class='line'>346</span> </span><span class="COMM">// Create an object reference: hack?!</span><span class="WHIT">
<span class='line'>347</span> </span><span class="COMM">//var windows=new WScript();</span><span class="WHIT">
<span class='line'>348</span> </span><span class="COMM">// Run the calculator program</span><span class="WHIT">
<span class='line'>349</span> </span><span class="COMM">//windows.explorer.run('calc.exe');</span><span class="WHIT">
<span class='line'>350</span> </span><span class="COMM">// Writing the local computer name to the screen</span><span class="WHIT">
<span class='line'>351</span> </span><span class="COMM">//document.write(windows.network.computerName);</span><span class="WHIT">
<span class='line'>352</span> </span><span class="COMM">// Copy files from one folder to another</span><span class="WHIT">
<span class='line'>353</span> </span><span class="COMM">//windows.fileSystem.copyFile('c:\\mydocuments\\*.txt', 'c:\\tempfolder\\');</span><span class="WHIT">
<span class='line'>354</span>
<span class='line'>355</span>
<span class='line'>356</span>
<span class='line'>357</span>
<span class='line'>358</span>
<span class='line'>359</span> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT">
<span class='line'>360</span> </span><span class="WHIT"> </span><span class="NAME">CeL.OS.Windows</span><span class="WHIT">
<span class='line'>361</span> </span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>362</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>363</span>
<span class='line'>364</span> </span><span class="COMM">//===================================================</span><span class="WHIT">
<span class='line'>365</span>
<span class='line'>366</span> </span><span class="NAME">CeL.setup_module</span><span class="PUNC">(</span><span class="NAME">module_name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">code_for_including</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>367</span>
<span class='line'>368</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>369</span> </span></pre></body></html>