3 ' vbslib ver3.00 Sep.22, 2009
\r
4 ' Copyright (c) 2008-2009, T's-Neko at Sage Plaisir 21 (Japan)
\r
5 ' All rights reserved. Based on 3-clause BSD license.
\r
8 '// Set g_vbslib_path=(this script full path) and g_vbslib_folder=(vbslib folder full path) before including this script.
\r
11 Dim g_vbslib_path, g_vbslib_folder
\r
12 Dim g_vbslib_ver_folder
\r
13 Dim g_debug_vbs_inc, g_debug_params
\r
14 Dim g_debug, g_debug_or_test, g_IncludePathes, g_CommandPrompt
\r
15 Dim g_b_cscript_exe, g_admin, g_curdir
\r
17 Dim g_f, g_i, g_err, g_path
\r
20 Dim g_SrcPath : g_SrcPath = g_vbslib_path
\r
21 Dim g_vbslib_var, g_vbslib_var_break_symbol
\r
22 Dim g_FinalizeInModulesCaller
\r
25 If IsEmpty(g_vbslib_path) Then _
\r
26 Err.Raise 1,,"vbs_inc needs other script using vbslib header"
\r
28 If IsEmpty(g_vbslib_folder) Then _
\r
29 g_vbslib_folder = g_fs.GetParentFolderName( g_vbslib_path )
\r
30 g_vbslib_ver_folder = g_fs.GetParentFolderName( g_vbslib_path ) + "\"
\r
31 g_curdir = g_sh.CurrentDirectory
\r
33 'If IsEmpty(g_fs) Then Set g_fs = CreateObject( "Scripting.FileSystemObject" )
\r
34 'If IsEmpty(g_sh) Then Set g_sh = WScript.CreateObject("WScript.Shell")
\r
36 If Not IsEmpty( WScript.Arguments.Named("g_debug") ) Then g_debug = True
\r
37 g_debug_vbs_inc = Not IsEmpty( WScript.Arguments.Named("debug") )
\r
38 If IsEmpty( g_debug_or_test ) Then g_debug_or_test = g_debug
\r
40 Set g_vbslib_var = CreateObject("Scripting.Dictionary")
\r
43 '//=== Debug print command line parameters ....
\r
44 If (g_debug or g_debug_vbs_inc ) And (LCase( Right( WScript.FullName, 11 ) ) = "cscript.exe") Then
\r
45 echo_c_in_vbs_inc ">" + g_fs.GetFileName( WScript.FullName ) + " """ + WScript.ScriptFullName + """"
\r
46 echo_c_in_vbs_inc "CurrentDirectory = " + g_sh.CurrentDirectory
\r
47 For i = 0 to WScript.Arguments.Count - 1
\r
48 echo_c_in_vbs_inc "Arguments("&i&") = """+ WScript.Arguments(i) + """"
\r
50 echo_c_in_vbs_inc "g_vbslib_path = " + g_vbslib_path
\r
54 '//=== change to command prompt ...
\r
60 '//=== Load setting script
\r
61 If g_debug or g_debug_vbs_inc Then echo_c_in_vbs_inc ">include setting folders"
\r
62 g_path = g_vbslib_ver_folder + "setting_default"
\r
63 If g_fs.FolderExists( g_path ) Then
\r
64 Set g_i = g_fs.GetFolder( g_path )
\r
65 For Each g_f in g_i.Files
\r
69 g_path = g_sh.ExpandEnvironmentStrings( "%myhome_mem%\prog\vbslib\setting_mem" )
\r
70 If g_path <> "%myhome_mem%\prog\vbslib\setting_mem" Then
\r
71 If g_fs.FolderExists( g_path ) Then
\r
72 Set g_i = g_fs.GetFolder( g_path )
\r
73 For Each g_f in g_i.Files
\r
78 g_path = g_sh.ExpandEnvironmentStrings( "%ProgramFiles%\vbslib\%USERNAME%\setting" )
\r
79 If g_fs.FolderExists( g_path ) Then
\r
80 Set g_i = g_fs.GetFolder( g_path )
\r
81 For Each g_f in g_i.Files
\r
85 g_path = g_vbslib_ver_folder + "setting"
\r
86 If g_fs.FolderExists( g_path ) Then
\r
87 Set g_i = g_fs.GetFolder( g_path )
\r
88 For Each g_f in g_i.Files
\r
95 '//=== variables of innitialize/finalize
\r
96 Dim g_InitializeModule
\r
97 Redim g_InitializeModules(-1)
\r
98 Redim g_InitializeModules_VBSPath(-1)
\r
100 Dim g_FinalizeModule
\r
101 Dim g_FinalizeLevel
\r
102 Redim g_FinalizeModules(-1)
\r
103 Redim g_FinalizeLevels(-1)
\r
104 Redim g_FinalizeModules_VBSPath(-1)
\r
107 '//=== read and execute g_IncludePathes( )
\r
108 If not IsDefined( "Setting_getIncludePathes" ) Then _
\r
109 Err.Raise 1,,"Not defined ""Setting_getIncludePathes"" in SettingDefault.vbs or Setting.vbs"
\r
111 g_IncludePathes = Setting_getIncludePathes( Empty )
\r
113 If g_debug or g_debug_vbs_inc Then echo_c_in_vbs_inc ">include libraries by g_IncludePathes in vbs_inc_setting.vbs"
\r
114 For g_i = 0 To UBound( g_IncludePathes )
\r
115 If Not IsEmpty( g_IncludePathes(g_i) ) Then
\r
117 If g_debug or g_debug_vbs_inc Then echo_c_in_vbs_inc ">include """ + g_vbslib_ver_folder + g_IncludePathes(g_i) + """"
\r
119 '//=== set default value
\r
120 g_InitializeModule = Empty
\r
121 g_FinalizeModule = Empty
\r
122 g_FinalizeLevel = 100
\r
125 '//=== read and execute g_IncludePathes(g_i)
\r
126 On Error Resume Next
\r
127 Set g_f = g_fs.OpenTextFile( g_fs.GetAbsolutePathName( g_vbslib_ver_folder + g_IncludePathes(g_i) ) )
\r
128 g_err = Err.Number : On Error Goto 0
\r
131 If g_err = 53 or g_err = 76 Then
\r
132 Err.Raise g_err, "Include path " + _
\r
133 g_fs.GetAbsolutePathName( g_vbslib_ver_folder + g_IncludePathes(g_i) ) + _
\r
134 " is not found. See " + g_vbslib_ver_folder + "vbs_inc_setting.vbs"
\r
140 g_SrcPath = g_fs.GetAbsolutePathName( g_vbslib_ver_folder + g_IncludePathes(g_i) )
\r
142 If not g_debug Then
\r
143 On Error Resume Next
\r
144 Execute g_f.ReadAll()
\r
145 g_err = Err.Number : On Error Goto 0
\r
147 Execute "'// " + g_SrcPath +vbCRLF+ g_f.ReadAll()
\r
150 g_SrcPath = g_vbslib_path
\r
153 If g_err = &h411 Then
\r
154 Err.Raise g_err, "Class, Member, Const name is duplicated in " + _
\r
155 g_fs.GetAbsolutePathName( g_vbslib_ver_folder + g_IncludePathes(g_i) )
\r
156 ElseIf g_err = &h3f7 Or g_err = &h400 Then
\r
157 Err.Raise g_err, "Syntax Error. Please double click " + _
\r
158 g_fs.GetAbsolutePathName( g_vbslib_ver_folder + g_IncludePathes(g_i) )
\r
160 Err.Raise g_err, "Error in including " + _
\r
161 g_fs.GetAbsolutePathName( g_vbslib_ver_folder + g_IncludePathes(g_i) )
\r
166 '//=== g_InitializeModules( ) <= g_InitializeModule
\r
167 '//=== g_InitializeModules_VBSPath( ) <= g_IncludePathes(g_i)
\r
168 If Not IsEmpty( g_InitializeModule ) Then
\r
169 Redim Preserve g_InitializeModules( UBound( g_InitializeModules ) + 1 )
\r
170 Set g_InitializeModules( UBound( g_InitializeModules ) ) = g_InitializeModule
\r
171 g_InitializeModule = Empty
\r
173 Redim Preserve g_InitializeModules_VBSPath( UBound( g_InitializeModules_VBSPath ) + 1 )
\r
174 g_InitializeModules_VBSPath( UBound( g_InitializeModules_VBSPath ) ) = g_IncludePathes(g_i)
\r
178 '//=== g_FinalizeModules( ) <= g_FinalizeModule
\r
179 If Not IsEmpty( g_FinalizeModule ) Then
\r
180 Redim Preserve g_FinalizeModules( UBound( g_FinalizeModules ) + 1 )
\r
181 Set g_FinalizeModules( UBound( g_FinalizeModules ) ) = g_FinalizeModule
\r
182 g_FinalizeModule = Empty
\r
184 Redim Preserve g_FinalizeModules_VBSPath( UBound( g_FinalizeModules_VBSPath ) + 1 )
\r
185 g_FinalizeModules_VBSPath( UBound( g_FinalizeModules_VBSPath ) ) = g_IncludePathes(g_i)
\r
187 Redim Preserve g_FinalizeLevels( UBound( g_FinalizeLevels ) + 1 )
\r
188 g_FinalizeLevels( UBound( g_FinalizeLevels ) ) = g_FinalizeLevel
\r
195 CallInitializeInModules
\r
197 Set g_FinalizeInModulesCaller = new FinalizeInModulesCaller
\r
205 '********************************************************************************
\r
206 ' <<< [echo_c_in_vbs_inc] >>>
\r
207 '********************************************************************************
\r
208 Sub echo_c_in_vbs_inc( Message )
\r
209 If g_CommandPrompt <> 0 Then WScript.Echo Message
\r
212 '********************************************************************************
\r
213 ' <<< [ChangeScriptMode] >>>
\r
214 '********************************************************************************
\r
215 Sub ChangeScriptMode
\r
216 Dim c_debug, c_admin, b_vista_admin
\r
217 Dim cmd, exe, host, host_opt, script, params, opt, exit_cmd, host_end
\r
218 Dim b_close_finish, i, key, directory, window_style
\r
221 If IsEmpty(g_debug) Then g_debug = False
\r
222 If IsEmpty(g_CommandPrompt) Then g_CommandPrompt = True
\r
226 g_b_cscript_exe = (LCase( Right( WScript.FullName, 11 ) ) = "cscript.exe")
\r
227 c_debug = Not IsEmpty( WScript.Arguments.Named("debug") )
\r
228 c_admin = Not IsEmpty( WScript.Arguments.Named("admin") )
\r
230 If Not IsEmpty( WScript.Arguments.Named("g_debug") ) Then g_debug=True:c_debug=True
\r
231 If g_debug=1 Then g_debug=True
\r
232 If g_debug=0 Then g_debug=False
\r
234 If (g_CommandPrompt and 4) = 4 Then window_style = 7
\r
235 If (g_CommandPrompt and 3) = 2 Then b_close_finish = False
\r
236 If (g_CommandPrompt and 3) = 1 Then b_close_finish = True
\r
237 If (g_CommandPrompt and 3) = 0 Then b_close_finish = False
\r
238 g_admin = ( g_admin <> 0 )
\r
241 '//=== Make command line
\r
242 directory = g_sh.CurrentDirectory
\r
243 If g_CommandPrompt > 0 Then
\r
246 host = "cmd /K (cd /d """ + directory + """ & cscript //nologo"
\r
250 host = "cmd /K (cscript //nologo"
\r
254 '//If IsEmpty( g_curdir ) Then directory = g_sh.CurrentDirectory Else directory = g_curdir
\r
266 '// If g_CommandPrompt > 0 Then
\r
267 '// script = " """ + g_fs.GetFileName( WScript.ScriptFullName ) + """"
\r
269 script = " """ + WScript.ScriptFullName + """"
\r
273 For i=0 To WScript.Arguments.Count - 1
\r
274 If InStr( WScript.Arguments(i), " " ) = 0 Then
\r
275 params=params+" "+WScript.Arguments(i)
\r
277 params=params+" """+WScript.Arguments(i)+""""
\r
280 If not IsEmpty( g_debug_params ) Then
\r
281 params=params+" "+g_debug_params
\r
291 opt = opt + " /admin:1"
\r
294 If b_close_finish Then
\r
295 exit_cmd = " & if errorlevel 21 exit"
\r
302 If g_b_cscript_exe<>(g_CommandPrompt>0) or c_debug<>g_debug or c_admin<>g_admin Then
\r
304 cmd = host + host_opt + script + params + opt + exit_cmd + host_end
\r
306 If g_admin and ( GetOSVersion() >= 6.0 ) Then
\r
308 '// Run as administrator on Windows Vista
\r
310 Set sh_ap = CreateObject( "Shell.Application" )
\r
311 sh_ap.ShellExecute exe, Mid( cmd, Len(exe)+2 ), directory, "runas", window_style
\r
314 '// Change to runas command
\r
316 i = g_sh.ExpandEnvironmentStrings("%ProgramFiles%\vbslib\%USERNAME%\setting\account_setting.vbs")
\r
317 If g_fs.FileExists( i ) Then include i
\r
318 If IsDefined( "Setting_getAdminUserName" ) Then
\r
319 i = Setting_getAdminUserName()
\r
320 If MsgBox( "Do you start as Administrator user?" + vbCRLF + "user: " + i + vbCRLF +_
\r
321 "command: " +WScript.ScriptFullName + " " + params,_
\r
322 vbOKCancel, "Warning: " & WScript.ScriptName ) <> vbOK Then WScript.Quit 1
\r
323 If not IsEmpty( i ) Then cmd = "runas /user:" + i + " """ + Replace( cmd, """", "\""" )+""""
\r
327 '// Run the command
\r
328 '// g_sh.CurrentDirectory = directory
\r
330 '// g_sh.Run cmd, window_style, Not IsEmpty(WScript.Arguments.Named.Item("waitfin"))
\r
331 g_sh.Run cmd, window_style, True
\r
340 '********************************************************************************
\r
341 ' <<< [CallInitializeInModules] >>>
\r
342 '********************************************************************************
\r
343 Sub CallInitializeInModules
\r
346 For i = 0 To UBound( g_InitializeModules )
\r
347 g_InitializeModules( i )( g_InitializeModules_VBSPath( i ) )
\r
353 '********************************************************************************
\r
354 ' <<< [CallFinalizeInModules] >>>
\r
355 '********************************************************************************
\r
356 Sub CallFinalizeInModules( Reason )
\r
357 Dim i, min_lv, min_over_lv, b
\r
358 Const limit=999999999
\r
360 min_over_lv = -limit
\r
363 For i = 0 To UBound( g_FinalizeModules )
\r
364 If g_FinalizeLevels( i ) < min_lv And g_FinalizeLevels( i ) > min_over_lv Then _
\r
365 min_lv = g_FinalizeLevels( i )
\r
367 If min_lv = limit Then Exit Do
\r
369 For i = 0 To UBound( g_FinalizeModules )
\r
370 If g_FinalizeLevels( i ) = min_lv Then _
\r
371 Call g_FinalizeModules( i )( g_FinalizeModules_VBSPath( i ), Reason )
\r
373 min_over_lv = min_lv
\r
375 g_FinalizeInModulesCaller.m_bDisableCall = True
\r
378 Const Pass_Num = 21, Skip_Num = 22
\r
381 If Err.Number = Pass_Num Then
\r
382 exit_code = Pass_Num
\r
383 ElseIf Err.Number <> 0 Then
\r
384 If Left( Err.Description, 1 ) = "<" or Err.Number = Skip_Num Then
\r
385 WScript.Echo Err.Description
\r
387 WScript.Echo GetErrStr( Err.Number, Err.Description )
\r
389 If g_CommandPrompt = 1 Then
\r
391 If not IsEmpty( g_CUI ) Then
\r
392 While Left( g_CUI.m_Auto_Keys, 1 ) <> "" and _
\r
393 Left( g_CUI.m_Auto_Keys, 1 ) <> "."
\r
394 g_CUI.m_Auto_Keys = Mid( g_CUI.m_Auto_Keys, 2 )
\r
399 If not IsEmpty( g_CUI ) Then
\r
400 If Left( g_CUI.m_Auto_Keys, 1 ) = "." Then
\r
401 If not IsEmpty( WScript.Arguments.Named.Item("GUI_input") ) Then _
\r
402 WScript.StdOut.WriteLine "<WARNING msg='
\83G
\83\89\81[
\82ª
\94
\90¶
\82µ
\82½
\83v
\83\8d\83Z
\83X
\82Í
\8bN
\93®
\82µ
\82½
\82Æ
\82«
\82Ì
\83v
\83\8d\83Z
\83X
\82Æ
\88Ù
\82È
\82è
\82Ü
\82·' current_vbs='" + _
\r
403 WScript.ScriptFullName +"'/>"
\r
404 WScript.StdOut.Write "
\8fI
\97¹
\82·
\82é
\82É
\82Í Enter
\83L
\81[
\82ð
\89\9f\82µ
\82Ä
\82
\82¾
\82³
\82¢ . . . "
\r
405 g_CUI.m_Auto_Keys = Mid( g_CUI.m_Auto_Keys, 2 )
\r
410 If IsEmpty( WScript.Arguments.Named.Item("GUI_input") ) Then
\r
411 WScript.StdOut.Write "
\8fI
\97¹
\82·
\82é
\82É
\82Í Enter
\83L
\81[
\82ð
\89\9f\82µ
\82Ä
\82
\82¾
\82³
\82¢ . . . "
\r
412 Wscript.StdIn.ReadLine
\r
414 WScript.StdOut.WriteLine "<WARNING msg='
\83G
\83\89\81[
\82ª
\94
\90¶
\82µ
\82½
\83v
\83\8d\83Z
\83X
\82Í
\8bN
\93®
\82µ
\82½
\82Æ
\82«
\82Ì
\83v
\83\8d\83Z
\83X
\82Æ
\88Ù
\82È
\82è
\82Ü
\82·' current_vbs='" + _
\r
415 WScript.ScriptFullName +"'/>"
\r
416 WScript.StdOut.Write "
\8fI
\97¹
\82·
\82é
\82É
\82Í Enter
\83L
\81[
\82ð
\89\9f\82µ
\82Ä
\82
\82¾
\82³
\82¢ . . . "
\r
417 MsgBox "
\8fI
\97¹
\82·
\82é
\82É
\82Í Enter
\83L
\81[
\82ð
\89\9f\82µ
\82Ä
\82
\82¾
\82³
\82¢ . . . "
\r
421 exit_code = Err.Number
\r
423 exit_code = Pass_Num
\r
424 If not IsEmpty( g_ExitCode ) Then exit_code = g_ExitCode
\r
428 WScript.Echo "exit code = " & exit_code & vbCRLF & _
\r
429 "(but now exit code = 0 with debugger.)"
\r
430 Exit Sub '// WScript.Quit occurs unknown error with debugger
\r
432 WScript.Quit exit_code ' If error was raised here, WSH-exe return is zero only.
\r
438 '********************************************************************************
\r
439 ' <<< [FinalizeInModulesCaller] >>>
\r
440 '********************************************************************************
\r
441 Class FinalizeInModulesCaller
\r
442 Public m_bDisableCall
\r
443 Private Sub Class_Terminate()
\r
444 If IsEmpty( m_bDisableCall ) and Err.Number <> &h8004FFFD Then 'h8004FFFD=WScript.Quit
\r
445 Const Pass_Num = 21, Skip_Num = 22
\r
446 If Err.Number = Pass_Num or Err.Number = Skip_Num Then CallFinalizeInModules 0 _
\r
447 Else CallFinalizeInModules 1
\r
453 '********************************************************************************
\r
454 ' <<< [ResumePush] >>>
\r
455 '********************************************************************************
\r
456 Function ResumePush
\r
457 ResumePush = ( g_debug = 0 )
\r
458 '// If error occured, WSH process returns 0.
\r
459 '// ResumePop catches error for returning error code.
\r
464 '********************************************************************************
\r
465 ' <<< [ResumePop] >>>
\r
466 '********************************************************************************
\r
468 Const Pass_Num = 21
\r
469 If Err.Number = 0 or Err.Number = Pass_Num Then
\r
470 CallFinalizeInModules 0
\r
472 CallFinalizeInModules 1
\r
478 '********************************************************************************
\r
479 ' <<< [GetErrStr] >>>
\r
480 '********************************************************************************
\r
481 Function GetErrStr( en, ed )
\r
483 GetErrStr = "no error"
\r
484 ElseIf en = 21 Then
\r
485 GetErrStr = "[Pass]"
\r
486 ElseIf en > 0 And en <= &h7FFF Then
\r
487 GetErrStr = "<ERROR err_number='" & en & "' err_description='" & ed & "'/>"
\r
489 GetErrStr = "<ERROR err_number='0x" & Hex(en) & "' err_description='" & ed & "'/>"
\r
495 '********************************************************************************
\r
496 ' <<< [SetVar] >>>
\r
497 '********************************************************************************
\r
498 Sub SetVar( Symbol, Value )
\r
499 echo ">SetVar """ + Symbol + """, """ & Value & """"
\r
500 If Symbol = g_vbslib_var_break_symbol Then Stop '// Look at then caller function using watch window of debugger
\r
501 g_vbslib_var.Item( Symbol ) = Value
\r
506 '********************************************************************************
\r
507 ' <<< [GetVar] >>>
\r
508 '********************************************************************************
\r
509 Function GetVar( Symbol )
\r
510 GetVar = g_vbslib_var.Item( Symbol )
\r
511 If IsEmpty( GetVar ) Then GetVar = g_sh.ExpandEnvironmentStrings( "%"+Symbol+"%" )
\r
512 If InStr( GetVar, "%" ) > 0 Then GetVar = Empty
\r
514 If Symbol = g_vbslib_var_break_symbol Then Stop '// Look at then caller function using watch window of debugger
\r
519 '********************************************************************************
\r
520 ' <<< [SetVarBreak] >>>
\r
521 '********************************************************************************
\r
522 Sub SetVarBreak( Symbol, Opt )
\r
523 g_vbslib_var_break_symbol = Symbol
\r
525 Dim sym2 : sym2 = "%"+Symbol+"%"
\r
526 Dim value : value = g_sh.ExpandEnvironmentStrings( sym2 )
\r
527 If value <> sym2 Then _
\r
528 Stop '// (Symbol) OS environment variable is already defined.
\r
530 value = g_vbslib_var.Item( Symbol )
\r
531 If not IsEmpty( value ) Then _
\r
532 Stop '// (Symbol) vbslib variable is already defined.
\r
537 '********************************************************************************
\r
538 ' <<< [IsDefined] >>>
\r
539 '********************************************************************************
\r
540 Function IsDefined( Symbol )
\r
543 On Error Resume Next
\r
544 Call GetRef( Symbol )
\r
545 en = Err.Number : On Error GoTo 0
\r
547 IsDefined = ( en <> 5 )
\r
552 '********************************************************************************
\r
553 ' <<< [GetOSVersion] >>>
\r
554 '********************************************************************************
\r
555 Function GetOSVersion()
\r
557 '// Get OS Version from cimv2 of WMI
\r
558 Dim cimv2 : Set cimv2 = GetObject( "winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
\r
559 Dim os : Set os = cimv2.ExecQuery( "SELECT * FROM Win32_OperatingSystem" )
\r
564 cimv2 = Empty : os = Empty : v = Empty
\r
566 '// Cut build number
\r
568 i = InStr( ver, "." )
\r
569 i = InStr( i+1, ver, "." )
\r
570 GetOSVersion = CDbl( Left( ver, i-1 ) )
\r
575 '********************************************************************************
\r
576 ' <<< [GetExistPathInSetting] >>>
\r
577 '********************************************************************************
\r
578 Function GetExistPathInSetting( Pathes, SettingFuncName )
\r
580 For i=0 To UBound( Pathes )
\r
581 If g_fs.FileExists( Pathes(i) ) Then
\r
582 GetExistPathInSetting = g_fs.GetAbsolutePathName(Pathes(i)) '// set to same as Big/Little case
\r
586 t = "" : For i=0 To UBound( Pathes ) : t = t + vbCrLf + " " + Pathes(i) : Next
\r
587 Err.Raise 1,, SettingFuncName + "
\82Å
\90Ý
\92è
\82µ
\82Ä
\82¢
\82é
\88È
\89º
\82Ì
\82¢
\82¸
\82ê
\82©
\82Ì
\83t
\83@
\83C
\83\8b\82ª
\8c©
\82Â
\82©
\82è
\82Ü
\82¹
\82ñ
\81B" + _
\r
588 "
\81i
\8eQ
\8dl
\81Fvbslib
\82Ì
\90à
\96¾
\8f\91\82Ì setting
\83t
\83H
\83\8b\83_
\81j" + t
\r
593 '********************************************************************************
\r
594 ' <<< [include] >>>
\r
595 '********************************************************************************
\r
596 Sub include( ByVal path )
\r
597 Dim f, en,ed, current
\r
599 If g_debug or g_debug_vbs_inc Then echo_c_in_vbs_inc ">include """ + path + """"
\r
601 path = g_sh.ExpandEnvironmentStrings( path )
\r
603 If InStr( path, "*" ) > 0 Then include_objs path, Empty, Empty : Exit Sub
\r
604 If g_fs.FolderExists( path ) Then include_objs path, Empty, Empty : Exit Sub
\r
606 current = g_sh.CurrentDirectory
\r
607 g_SrcPath = g_fs.GetAbsolutePathName( path )
\r
608 If path <> g_fs.GetFileName( path ) Then
\r
609 if not g_fs.FileExists( path ) Then _
\r
610 Err.Raise 2,, "include: Not found """ + path + """ current=""" + g_sh.CurrentDirectory +""""
\r
611 g_sh.CurrentDirectory = g_fs.GetParentFolderName( g_fs.GetAbsolutePathName( path ) )
\r
614 On Error Resume Next
\r
615 Set f = g_fs.OpenTextFile( g_fs.GetFileName( path ) )
\r
616 en = Err.Number : ed = Err.Description : On Error GoTo 0
\r
617 If en <> 0 Then Err.Raise en,,ed + " in include( " + path + " )"
\r
619 On Error Resume Next
\r
620 ExecuteGlobal f.ReadAll()
\r
621 g_sh.CurrentDirectory = current
\r
622 en = Err.Number : ed = Err.Description : On Error GoTo 0
\r
623 If en=&h411 Then en = 0 '// &h411=Symbol Overrided
\r
624 If en <> 0 Then Err.Raise en,,ed + " in include( " + path + " )." + _
\r
625 " Please double click the vbs file, if syntax error occured."
\r
627 Dim t : t = "'// " + g_SrcPath +vbCRLF+ f.ReadAll() : f.Close : ExecuteGlobal t
\r
628 g_sh.CurrentDirectory = current
\r