merge the formfield patch from ooo-build
[ooovba.git] / odk / cfgWin.js
blob662bd3ae05f4a417666c7c140b4f18193ec1388b
1 // This script asks for variables, which are necessary for building the
2 // examples of the Office Development Kit. The script duplicates the template
3 // script and inserts the variables into the copied script.
4 // The Script was developed for the operating systems Microsoft Windows.
5 var regKeyOfficeCurrentUser = "HKEY_CURRENT_USER\\Software\\OpenOffice.org\\UNO\\InstallPath\\";
6 var regKeyOfficeLocaleMachine = "HKEY_LOCAL_MACHINE\\Software\\OpenOffice.org\\UNO\\InstallPath\\";
7 var regKeyDotNetInstallRoot = "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\.NETFramework\\InstallRoot";
8 var regKeyDotNet1_1 = "HKLM\\Software\\Microsoft\\.NETFramework\\policy\\v1.1\\4322";
9 var sDirDotNet1_1 = "v1.1.4322";
10 var regKeyDotNet2_0 = "HKLM\\Software\\Microsoft\\.NETFramework\\Policy\\v2.0\\50727";
11 var sDirDotNet2_0 = "v2.0.50727";
13 var regKeyJDK = "HKLM\\Software\\JavaSoft\\Java Development Kit\\";
14 //var regKeyVC70 = "HKLM\\SOFTWARE\\Microsoft\\VisualStudio\\7.0\\Setup\\VC\\ProductDir";
15 //var regKeyVC71 = "HKLM\\SOFTWARE\\Microsoft\\VisualStudio\\7.1\\Setup\\VC\\ProductDir";
16 var regKeyVC90 = "HKLM\\SOFTWARE\\Microsoft\\VisualStudio\\9.0\\Setup\\VC\\ProductDir";
18 //var regKeyVCExpress80 = "HKLM\\SOFTWARE\\Microsoft\\VCExpress\\8.0\\Setup\\VC\\ProductDir";
19 var regKeyVCExpress90 = "HKLM\\SOFTWARE\\Microsoft\\VCExpress\\9.0\\Setup\\VC\\ProductDir";
21 var regKeyWindowsSDK = "HKLM\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\CurrentInstallFolder";
23 var WshShell = WScript.CreateObject("WScript.Shell");
24 var WshSysEnv = WshShell.Environment("process");
25 var aFileSystemObject =  new ActiveXObject("Scripting.FileSystemObject");
26 var stdin = WScript.StdIn;
27 var stdout = WScript.StdOut;
29 stdout.WriteLine("\n" +
30 " *** Configure your SDK environment ***\n\n" +
31 " NOTE: This script is working only for Windows 2000, Windows XP or newer versions!\n");
33 var oo_sdk_name=WshSysEnv("OO_SDK_NAME");
34 var stldebug="";
35 var oo_sdk_home=getSdkHome();
36 var oo_user_sdk_dir=WshSysEnv("APPDATA") + "\\" + oo_sdk_name;
37 var oo_user_sdk_env_script=oo_user_sdk_dir + "\\setsdkenv_windows.bat";
39 var office_home=getOfficeHome();
40 var office_base_home=getOfficeBaseHome();
41 var oo_sdk_ure_home=getUreHome();
43 var oo_sdk_make_home=getMakeHome();
44 var oo_sdk_zip_home=getZipHome();
45 var oo_sdk_vc8_used="";
46 var oo_sdk_windowssdk="";
47 var oo_sdk_cpp_home=getCppHome();
48 var oo_sdk_cli_home=getCliHome();
49 var oo_sdk_java_home=getJavaHome();
50 var oo_sdk_out=getOutputDir();
51 var sdk_auto_deployment=getAutoDeployment();
53 writeBatFile(oo_user_sdk_dir, oo_user_sdk_env_script);
55 stdout.Write(
56         "\n ******************************************************************\n" +
57     " * ... \"" + oo_user_sdk_env_script + "\"\n" +
58     " * batch file has been prepared.\n" +
59     " * This batch file will be used in the future to prepare your\n" +
60         " * personal configured SDK environment.\n" +
61         " ******************************************************************\n\n");
62 //    " * For each time you want to use this configured SDK environment,\n" +
63 //    " * you have to run the \"setsdkenv_windows.bat\" file in a new shell!\n" +
65 // done -------------------------------------------------------------------------
68 function skipChoice(msg)
70         stdout.Write("\n Do you want to skip the choice of " + msg + " (YES/NO) [YES]:");
71         var sChoice = stdin.ReadLine();
72     if (sChoice == "" || sChoice.toLowerCase() == "yes")
73            return true;
75         return false;
78 function getSdkHome()
80         var sSuggestedHome = WshSysEnv("OO_SDK_HOME");
81     if (sSuggestedHome.length == 0) {
82         var scriptname = WScript.ScriptFullName;
83         sSuggestedHome = scriptname.substr(0,scriptname.length-10);
84     }
85     
86     while(true)
87     {
88         stdout.Write("\n Enter the Office Software Development Kit directory [" +
89                      sSuggestedHome + "]:");
90         var sHome = stdin.ReadLine();
91         if (sHome.length == 0)
92         {
93             //No user input, use default. 
94             if ( ! aFileSystemObject.FolderExists(sSuggestedHome))
95             {
96                 stdout.WriteLine("\n Error: Could not find directory \"" +
97                                  sSuggestedHome + "\". An SDK is required, please" +
98                                                                  " specify the path to a valid installation.");
99                 continue;
100             }       
101             sHome = sSuggestedHome;
102         }
103         else
104         {
105             //validate the user input
106             if ( ! aFileSystemObject.FolderExists(sHome))
107             {
108                 stdout.WriteLine("\n Error: The directory \"" + sHome + 
109                                  "\" does not exist. Please enter the path to a" +
110                                                                  "valid SDK installation.");
111                 continue;
112             }
113         }
114         //Check if this is an sdk folder by looking for the idl sub - dir
115         var idlDir = sHome + "\\idl";
116         if (! aFileSystemObject.FolderExists(idlDir))
117         {
118             stdout.WriteLine("\n Error: Could not find directory \"" +
119                              idlDir + "\". An SDK is required, please specify " +
120                              "the path to a valid SDK installation.");
121             continue;
122         }
124         if (aFileSystemObject.FileExists(sHome + "\\lib\\stlport_vc71_stldebug.lib")) {
125                     stldebug="_stldebug";
126                 }
128         return sHome;
129     }   
132 function getOfficeOrUre()
134     var suggestion = "Office";
135     var choice;
136     while (choice != "office" && choice != "ure") {
137         stdout.Write(
138             "\n Use an installed Office or an installed UNO Runtime"
139             + " Environment (Office/URE) [" + suggestion + "]:");
140         choice = stdin.ReadLine();
141         if (choice == "") {
142             choice = suggestion;
143         }
144         choice = choice.toLowerCase();
145     }
146     return choice;
149 function getOfficeHome()
151     var sSuggestedHome = WshSysEnv("OFFICE_HOME");
152     if (sSuggestedHome.length == 0)
153     {
154         try {   
155             sSuggestedHome = WshShell.RegRead(regKeyOfficeCurrentUser);
156                         //The registry entry points to the program folder but we need the 
157                         //installation folder
158         } catch(exc) {}
159         if (sSuggestedHome.length == 0)
160         {
161             try {
162                 sSuggestedHome = WshShell.RegRead(regKeyOfficeLocaleMachine);
163                 //The registry entry points to the program folder but we need 
164                                 //the installation folder
165             } catch (exc) {}
166         }
168                 var index=0;
169         if ((index = sSuggestedHome.lastIndexOf("\\")) != -1)   
170                    sSuggestedHome = sSuggestedHome.substr(0, index);
172         if (sSuggestedHome.length == 0)
173                    sSuggestedHome = searchOffice();
174     }
175     
176     while(true)
177     {
178         stdout.Write("\n Enter the Office base installation directory [" +
179                      sSuggestedHome + "]:");
180         var sHome = stdin.ReadLine();
181         if (sHome.length == 0)
182         {
183             //No user input, use default. 
184             if ( ! aFileSystemObject.FolderExists(sSuggestedHome))
185             {
186                 stdout.WriteLine("\n Error: Could not find directory \"" + 
187                                  sSuggestedHome + "\" An office installation is " +
188                                                                  "required, please specify the path to a valid " +
189                                                                  "office installation.");
190                 sSuggestedHome = "";
191                 continue;
192             }       
193             sHome = sSuggestedHome;
194         } else
195         {
196             //validate the user input
197             if ( ! aFileSystemObject.FolderExists(sHome))
198             {
199                 stdout.WriteLine("\n Error: The directory \"" + sHome + 
200                                  "\" does not exist. Please specify the path to " +
201                                                                  "a valid office installation.");
202                 continue;
203             }
204         }
205         //Check if this is a valid office installtion folder by looking for the 
206                 //program sub-directory
207         var progDir = sHome + "\\program";
208         if (! aFileSystemObject.FolderExists(progDir))
209         {
210             stdout.WriteLine("\n Error: Could not find directory \"" +
211                              progDir + "\". An office installation is required, " +
212                                                          "please specify the path to a valid office " +
213                                                          "installation.");
214             continue;
215         }
216         return sHome;
217     }
220 function searchOffice()
222         var tmp = oo_sdk_home;
223         var officepath ="";
224         var index=-1;
226         if ((index = tmp.lastIndexOf("\\Basis")) != -1) {
227            tmp = tmp.substr(0, index);
228         }
230         if (aFileSystemObject.FileExists(tmp + "\\program\\soffice.exe")) {
231            return tmp;
232         }
233   
234         return "";
238 function getOfficeBaseHome()
240         var officebase = oo_sdk_home;
241         var index=officebase.lastIndexOf("\\");
242         
243         officebase = officebase.substr(0, index);
245         return officebase;
248 function getUreHome()
250         var tmpure = oo_sdk_home;
251         var ure = "";
252         var index=0;
253     if ((index = tmpure.lastIndexOf("Basis")) != -1)   
254            tmpure = tmpure.substr(0, index);
256     if (aFileSystemObject.FileExists(tmpure + "\\URE\\bin\\uno.exe")) {
257            ure = tmpure + "\URE";
258         }
260         return ure;
263     var suggestion = WshSysEnv("OO_SDK_URE_HOME");
264     var choice;
265     for (;;) {
266         stdout.Write(
267             "\n Enter the URE installation directory [" + suggestion + "]:");
268         choice = stdin.ReadLine();
269         if (choice == "") {
270             choice = suggestion;
271         }
272         if (aFileSystemObject.FileExists(choice + "\\bin\\uno.exe")) {
273             break;
274         }
275         stdout.WriteLine("\n Error: A valid URE installation is required.");
276     }
277     return choice;
281 function getMakeHome()
283     var sSuggestedHome = WshSysEnv("OO_SDK_MAKE_HOME");
284     
285     while(true)
286     {
287         stdout.Write("\n Enter GNU make (3.79.1 or higher) tools directory [" +
288                      sSuggestedHome + "]:");
289         var sHome = stdin.ReadLine();
290         if (sHome.length == 0)
291         {
292             //No user input, use default. 
293             if ( ! aFileSystemObject.FolderExists(sSuggestedHome))
294             {
295                 stdout.WriteLine("\n Error: Could not find directory \"" +
296                                                                  sSuggestedHome + "\". GNU make is required, " +
297                                                                  "please specify a GNU make tools directory.");
298                 sSuggestedHome = "";
299                 continue;
300             }       
301             sHome = sSuggestedHome;
302         } else
303         {
304             //validate the user input
305             if ( ! aFileSystemObject.FolderExists(sHome))
306             {
307                 stdout.WriteLine("\n Error: The directory \"" + sHome + 
308                                  "\" does not exist. GNU make is required, " +
309                                                                  "please specify a GNU make tools directory.");
310                 continue;
311             }
312         }
313         //Check for the make executable
314         var sMakePath = sHome + "\\make.exe";
315         if (! aFileSystemObject.FileExists(sMakePath))
316         {
317                 sMakePath = sHome + "\\mingw32-make.exe";
318         }
319         if (! aFileSystemObject.FileExists(sMakePath))
320         {
321             stdout.WriteLine("\n Error: Could not find \"" + sMakePath + 
322                                                          "\". GNU make is required, please specify a GNU " +
323                                                          "make tools directory.");
324             continue;
325         }
326         return sHome;
327     }   
330 function getZipHome()
332     var sSuggestedHome = WshSysEnv("OO_SDK_ZIP_HOME");
333     
334     while(true)
335     {
336         stdout.Write("\n Enter a zip (2.3 or higher) tools directory [" +
337                      sSuggestedHome + "]:");
338         var sHome = stdin.ReadLine();
339         if (sHome.length == 0)
340         {
341             //No user input, use default. 
342             if ( ! aFileSystemObject.FolderExists(sSuggestedHome))
343             {
344                 stdout.WriteLine("\n Error: Could not find directory \"" + 
345                                                                  sSuggestedHome + "\". zip is required, please " +
346                                                                  "specify a zip tools directory.");
347                 sSuggestedHome = "";
348                 continue;
349             }       
350             sHome = sSuggestedHome;
351         }
352         else
353         {
354             //validate the user input
355             if ( ! aFileSystemObject.FolderExists(sHome))
356             {
357                 stdout.WriteLine("\n Error: The directory \"" + sHome + 
358                                  "\" does not exist. zip is required, please " +
359                                                                  "specify a zip tools directory.");
360                 continue;
361             }
362         }
363         //Check for the make executable
364         var sZipPath = sHome + "\\zip.exe";
365         if (! aFileSystemObject.FileExists(sZipPath))
366         {
367             stdout.WriteLine("\n Error: Could not find \"" + sZipPath + 
368                              "\". zip is required, please specify a zip tools " +
369                                                          "directory.");
370             continue;
371         }
372         return sHome;
373     }   
376 function getCppHome()
378     var sSuggestedHome = WshSysEnv("OO_SDK_CPP_HOME");
379     if (sSuggestedHome.length == 0)
380     {       
381         var sVC="";
382         try {
383             sVC = WshShell.RegRead(regKeyVCExpress90);
384         }catch (exc) {}
385         if (sVC.length == 0)
386         {
387                 try {
388                                 sVC = WshShell.RegRead(regKeyVC90);
389                         }catch (exc) {}
390                 }        
391                 // check Windows SDK if VC 9
392         if (sVC.length > 0)
393         {
394                         try {
395                                 oo_sdk_windowssdk = WshShell.RegRead(regKeyWindowsSDK);
396                         }catch (exc) {}
397                 }
398         if (sVC.length == 0)
399         {
400                 try {
401                                 sVC = WshShell.RegRead(regKeyVCExpress80);
402                         }catch (exc) {}
403                 }        
404         if (sVC.length == 0)
405         {
406                 try {
407                                 sVC = WshShell.RegRead(regKeyVC80);
408                         }catch (exc) {}
409                 }        
410         if (sVC.length == 0)
411         {
412                 try {
413                                 sVC = WshShell.RegRead(regKeyVCExpress80);
414                         }catch (exc) {}
415                 }        
416         if (sVC.length == 0)
417         {
418                 try {
419                                 sVC = WshShell.RegRead(regKeyVC71);
420                         }catch (exc) {}
421                 }        
422         if (sVC.length > 0)
423         {
424             sVC += "bin";
425             if (aFileSystemObject.FileExists(sVC + "\\cl.exe"))
426                 sSuggestedHome = sVC;                   
427         }
428     }
430     var bSkip = false;       
431     while(true)
432     {
433         stdout.Write("\n Enter the directory of the C++ compiler (optional) [" +
434                      sSuggestedHome + "]:");
435         var sHome = stdin.ReadLine();
436         if (sHome.length == 0)
437         {
438             //No user input, check OO_SDK_CPP_HOME or suggested value
439                         if ( sSuggestedHome.length == 0 ) {
440                             bSkip = true;
441                         } else {
442                             if ( !aFileSystemObject.FolderExists(sSuggestedHome) )
443                                 {
444                                         stdout.WriteLine("\n Error: Could not find directory \"" +
445                                                                          sSuggestedHome + "\".");
446                                         sSuggestedHome = "";
447                                         bSkip = true;
448                                 }
449                         }
450        
451             sHome = sSuggestedHome;
452         } else
453         {
454             //validate the user input
455             if ( ! aFileSystemObject.FolderExists(sHome))
456             {
457                 stdout.WriteLine("\n Error: Could not find directory \"" +
458                                  sHome + "\".");
459                 bSkip = true;
460             }
461         }
463                 if ( !bSkip) {
464                     //Check if the C++ compiler exist
465                     var cl = sHome + "\\cl.exe";
466                     var mt = sHome + "\\mt.exe";
467         
468                         if (! aFileSystemObject.FileExists(cl))
469                         {
470                                 stdout.WriteLine("\n Error: Could not find the C++ compiler \"" 
471                                                                  + cl + "\".");
472                                 sHome = "";
473                                 bSkip = true;
474                         } else {
475                             if (aFileSystemObject.FileExists(mt)) {
476                                     oo_sdk_vc8_used="true";                                
477                                 }
478                         }
479                 }
481                 if ( bSkip ) { 
482                    if ( skipChoice("the C++ compiler") ) {
483                            return "";
484                    } else {
485                            bSkip = false;
486                            continue;
487                    }
488                 }
490         return sHome;
491     }   
494 function getCliHome()
496     var sSuggestedHome = WshSysEnv("OO_SDK_CLI_HOME");
497     
498     if (sSuggestedHome.length == 0)
499     {
500         try {
501             var _ver = WshShell.RegRead(regKeyDotNet2_0);
502             if (_ver.length > 0)
503             {
504                 sSuggestedHome = WshShell.RegRead(regKeyDotNetInstallRoot);
505                 sSuggestedHome += sDirDotNet2_0;
506                 if ( ! aFileSystemObject.FolderExists(sSuggestedHome))
507                     sSuggestedHome = "";
508             }
510                         if (sSuggestedHome.length == 0) 
511                         {
512                                 _ver = WshShell.RegRead(regKeyDotNet1_1);
513                                 if (_ver.length > 0)
514                                 {
515                                         sSuggestedHome = WshShell.RegRead(regKeyDotNetInstallRoot);
516                                         sSuggestedHome += sDirDotNet1_1;
517                                         if ( ! aFileSystemObject.FolderExists(sSuggestedHome))
518                                            sSuggestedHome = "";
519                                 }
520                         }                               
521                 } catch (exc) {}
522     }
523     
524     var bSkip = false;       
525     while(true)
526     {
527         stdout.Write("\n Enter the directory of the C# and VB.NET compilers (optional) [" + sSuggestedHome + "]:");
528         var sHome = stdin.ReadLine();
529         if (sHome.length == 0)
530         {
531             //No user input, check OO_SDK_CLI_HOME or suggested value
532                         if ( sSuggestedHome.length == 0 ) {
533                             bSkip = true;
534                         } else {
535                             if ( !aFileSystemObject.FolderExists(sSuggestedHome) )
536                                 {
537                                         stdout.WriteLine("\n Error: Could not find directory \"" + 
538                                                                          sSuggestedHome + "\".");
539                                         sSuggestedHome = "";
540                                         bSkip = true;
541                                 } 
542                         }
544                     sHome = sSuggestedHome;
545         }
546         else
547         {
548             //validate the user input
549             if ( ! aFileSystemObject.FolderExists(sHome))
550             {
551                 stdout.WriteLine("\n Error: The directory \"" + sHome + 
552                                  "\" does not exist.");
553                 bSkip = true;
554             }
555         }
557                 if ( !bSkip ) {
558                     //Check if the C# and VB.NET compiler exist
559                     var csc = sHome + "\\csc.exe";
560                     var vbc = sHome + "\\vbc.exe";
561         
562                         if (! aFileSystemObject.FileExists(csc)) 
563                         {
564                                 stdout.WriteLine("\n Error: Could not find the C# compiler \"" + 
565                                                                  csc + "\".");
566                                 bSkip = true;
567                         }
568                         if (! aFileSystemObject.FileExists(vbc))
569                         {
570                                 stdout.WriteLine("\n Error: Could not find the VB.NET compiler \"" +
571                                                                  vbc + "\".");
572                                 bSkip = true;
573                         }
574                 }
576                 if ( bSkip ) { 
577                    if ( skipChoice("the C# and VB.NET compilers") ) {
578                            return "";
579                    } else {
580                            bSkip = false;
581                            continue;
582                    }
583                 }
585         return sHome;
586     }   
589 function getJavaHome()
591     var sSuggestedHome = WshSysEnv("OO_SDK_JAVA_HOME");
592     if (sSuggestedHome.length == 0)
593     {
594         try {
595             var currentVersion = WshShell.RegRead(regKeyJDK + "CurrentVersion");
596             if (currentVersion.length > 0)
597             {
598                 sSuggestedHome = WshShell.RegRead(regKeyJDK + currentVersion + 
599                                                                                                   "\\JavaHome");           
600                 if ( ! aFileSystemObject.FolderExists(sSuggestedHome) )
601                     sSuggestedHome = "";
602             }
603         } catch (exc) {}
604     }
605     
606     var bSkip = false;       
607     while(true)
608     {
609         stdout.Write("\n Enter JAVA SDK (1.4.1_01 or higher) installation directory (optional) [" + sSuggestedHome + "]:");
610         var sHome = stdin.ReadLine();
611         if (sHome.length == 0)
612         {
613             //No user input, check OO_SDK_JAVA_HOME or suggested value
614                         if ( sSuggestedHome.length == 0 ) {
615                             bSkip = true;
616                         } else {
617                             if ( !aFileSystemObject.FolderExists(sSuggestedHome) )
618                                 {
619                                         stdout.WriteLine("\n Error: Could not find directory \"" + 
620                                                                          sSuggestedHome + "\".");
621                                         sSuggestedHome = "";
622                                         bSkip=true;
623                                 }
624                         }       
625                         
626                         sHome = sSuggestedHome;
627         } else
628         {
629             //validate the user input
630             if ( ! aFileSystemObject.FolderExists(sHome))
631             {
632                 stdout.WriteLine("\n Error: The directory \"" + sHome + 
633                                  "\" does not exist.");
634                                 bSkip = true;
635             }
636         }
638                 if ( !bSkip) {
639                     //Check if this is an sdk folder by looking for the javac compiler
640                         var javacompiler = sHome + "\\bin\\javac.exe";
641                         if (! aFileSystemObject.FileExists(javacompiler))
642                         {
643                                 stdout.WriteLine("\n Error: Could not find \"" +
644                                                                  javacompiler + "\".");
645                                 bSkip = true;
646                         }
647         }
649                 if ( bSkip ) { 
650                    if ( skipChoice("the Java SDK") ) {
651                            return "";
652                    } else {
653                            bSkip = false;
654                            continue;
655                    }
656                 }
658         return sHome;
659     }   
662 function getOutputDir()
664         var defaultdir = "c:\\" + oo_sdk_name;
665     var sSuggestedDir = WshSysEnv("OO_SDK_OUT");
666         if (sSuggestedDir.length == 0)
667            sSuggestedDir = defaultdir;
669     var bSkip = false;       
670     while(true)
671     {
672         stdout.Write(
673                         "\n Default output directory is the \"c:\\" + oo_sdk_name + "\".\n" +
674             " Enter an existent directory if you prefer a different one. But note" +
675                         " that only\n a path without spaces is allowed because of a" +
676                         " limitation of gnu make. (optional) [" + sSuggestedDir + "]:");    
677         var sDir = stdin.ReadLine();
678         if (sDir.length == 0)
679         {
680             //No user input, check OO_SDK_OUT or suggested value
681                         if ( sSuggestedDir.length == 0 ) {
682                             bSkip = true;
683                         } else {
684                                 if (sSuggestedDir == oo_user_sdk_dir || sSuggestedDir == defaultdir) {
685                                     var fso = new ActiveXObject("Scripting.FileSystemObject");
686                                         if ( !fso.FolderExists(sSuggestedDir) )
687                                                 fso.CreateFolder(sSuggestedDir);
688                                 }                               
689                             if ( !aFileSystemObject.FolderExists(sSuggestedDir) )
690                                 {
691                                         stdout.WriteLine("\n Error: Could not find directory \"" +
692                                                                          sSuggestedDir + "\".");
693                                         sSuggestedDir = "";
694                                         bSkip = true;
695                                 }
696                         }
697        
698             sDir = sSuggestedDir;
699         }
700         else
701         {
702                         if (sDir.indexOf(' ') != -1) {
703                                 stdout.WriteLine("\n Error: your specified output directory " +
704                                                                  "\"" + sDir + "\" " +   
705                                                                  "contains one or more spaces.\n        That " +
706                                                                  "causes problems with gnu make. Please specifiy" +
707                                                                  " a directory without spaces.");
708                                 bSkip = true;
709                         }
710             //validate the user input
711             if ( ! aFileSystemObject.FolderExists(sDir))
712             {
713                 stdout.WriteLine("\n Error: Could not find directory \"" +
714                                  sDir + "\".");
715                 bSkip = true;
716             }
717         }
719                 if ( bSkip ) { 
720                    if ( skipChoice("a special output directory") ) {
721                            return "";
722                    } else {
723                            bSkip = false;
724                            continue;
725                    }
726                 }
727         
728         return sDir;
729     }   
732 function getAutoDeployment()
734     var sSuggestedAuto = WshSysEnv("SDK_AUTO_DEPLOYMENT");
735     if (sSuggestedAuto.length == 0)
736         sSuggestedAuto = "YES";
737     
738     while(true)
739     {
740         stdout.Write("\n Automatic deployment of UNO components (YES/NO) ["+
741                      sSuggestedAuto + "]:");   
742         var sAuto = stdin.ReadLine();
743         if (sAuto.length == 0)
744             sAuto = sSuggestedAuto;
745         else
746         {
747             sAutoU = sAuto.toUpperCase();
748             if (sAutoU != "YES" && sAutoU != "NO")
749             {
750                 stdout.WriteLine("\n Error: The value \"" + sAuto + "\" is " +
751                                                                  "invalid. Please answer YES or NO.")
752                     continue;
753             }
754             sAuto = sAutoU;
755         }
756         return sAuto;
757     }   
760 //The function uses sp2bv.exe to obtain a file URL from a
761 //system path. The URL is already escaped for use as bootstrap variable.
762 //($ -> \$). Then the resulting string is escaped for use in a bat file.
763 //That is % signs are made to double % (% -> %%);
764 function makeBootstrapFileUrl(systemPath)
766     var oExec = WshShell.Exec("sp2bv.exe \"" + systemPath + "\"");
767     var output="";
768     while (true)
769     {
770         if (!oExec.StdOut.AtEndOfStream)
771         {
772             var next = oExec.StdOut.Read(1);
773             if (next == '%')
774                 output += "%%";
775             else
776                 output += next;
777         }
778         else
779             break;
780     }
781     return output;
784 function writeBatFile(fdir, file)
786     var fso = new ActiveXObject("Scripting.FileSystemObject");
787     if ( !fso.FolderExists(fdir) )
788        fso.CreateFolder(fdir);
789     var newFile = fso.CreateTextFile(file, true);
790     newFile.Write(
791         "@echo off\n" +
792         "REM This script sets all enviroment variables, which\n" +
793         "REM are necessary for building the examples of the Office Development Kit.\n" +
794         "REM The Script was developed for the operating systems Windows.\n" +
795         "REM The SDK name\n" +
796         "REM Example: set OO_SDK_NAME=openoffice3.0_sdk\n" +
797         "set OO_SDK_NAME=" + oo_sdk_name  +
798         "\n\n" +
799         "REM Installation directory of the Software Development Kit.\n" +
800         "REM Example: set OO_SDK_HOME=C:\\Program Files\\OpenOffice.org\\Basic 3.0\\sdk\n" +
801         "set OO_SDK_HOME=" + oo_sdk_home  +
802         "\n\n" +
803         "REM Office installation directory.\n" +
804         "REM Example: set OFFICE_HOME=C:\\Program Files\\OpenOffice.org 3\n" +
805         "set OFFICE_HOME=" + office_home +
806         "\n\n" +
807         "REM Example: set OFFICE_HOME=C:\\Program Files\\OpenOffice.org\\Basis 3.0\n" +
808         "set OFFICE_BASE_HOME=" + office_base_home +
809         "\n\n" +
810         "REM URE installation directory.\n" +
811         "REM Example: set OO_SDK_URE_HOME=C:\\Program Files\\OpenOffice.org\\URE\n" +
812         "set OO_SDK_URE_HOME=" + oo_sdk_ure_home +
813         "\n\n" +
814         "REM Directory of the make command.\n" +
815         "REM Example: set OO_SDK_MAKE_HOME=D:\\NextGenerationMake\\make\n" + 
816         "set OO_SDK_MAKE_HOME=" + oo_sdk_make_home + 
817         "\n\n" +
818                 "REM Directory of the zip tool.\n" +
819                 "REM Example: set OO_SDK_ZIP_HOME=D:\\infozip\\bin\n" +
820                 "set OO_SDK_ZIP_HOME=" + oo_sdk_zip_home + 
821         "\n\n" +
822         "REM Directory of the C++ compiler.\n" + 
823         "REM Example:set OO_SDK_CPP_HOME=C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\bin\n" + 
824         "set OO_SDK_CPP_HOME=" + oo_sdk_cpp_home + 
825                 "\nset CPP_VC8=" + oo_sdk_vc8_used +
826                 "\nset CPP_WINDOWS_SDK=" + oo_sdk_windowssdk +
827         "\n\n" + 
828         "REM Directory of the C# and VB.NET compilers.\n" + 
829         "REM Example:set OO_SDK_CLI_HOME=C:\\WINXP\\Microsoft.NET\\Framework\\v1.0.3705\n" +
830         "set OO_SDK_CLI_HOME=" + oo_sdk_cli_home + 
831         "\n\n" +
832         "REM Java SDK installation directory.\n" + 
833         "REM Example: set OO_SDK_JAVA_HOME=C:\\Program Files\\Java\\jdk1.6.0_05\n" + 
834         "set OO_SDK_JAVA_HOME=" + oo_sdk_java_home + 
835         "\n\n" + 
836         "REM Special output directory\n" + 
837         "REM Example: set OO_SDK_OUT=C:\\" + oo_sdk_name + "\n" +
838         "set OO_SDK_OUT=" + oo_sdk_out + 
839         "\n\n" +
840         "REM Automatic deployment\n" + 
841         "REM Example: set SDK_AUTO_DEPLOYMENT=YES\n" +
842         "set SDK_AUTO_DEPLOYMENT=" + sdk_auto_deployment +
843         "\n\n" +
844                 "set STLDEBUG=" + stldebug + "\n" +
845                 "REM check stlport lib in 4NT shell\n" +
846                 "REM if exist \"%OO_SDK_HOME%\\windows\\lib\\stlport_vc71_stldebug.lib\". (\n" +
847                 "REM   set STLDEBUG=_stldebug\n" +
848                 "REM )\n\n" +
849         "REM Check installation path for the StarOffice Development Kit.\n" +
850         "if not defined OO_SDK_HOME (\n" +
851         "   echo Error: the variable OO_SDK_HOME is missing!\n" +
852         "   goto :error\n" +
853         " )\n" + 
854         "\n" + 
855         "REM Check installation path for the office.\n" + 
856         "REM if not defined OFFICE_HOME (\n" + 
857         "REM if not defined OO_SDK_URE_HOME (\n" + 
858         "REM    echo Error: either of the variables OFFICE_HOME and\n" +
859         "REM    echo OO_SDK_URE_HOME is missing!\n" + 
860         "REM    goto :error\n" + 
861         "REM  )\n" +
862         "REM  )\n" +
863         "\n" +
864         "REM Check installation path for GNU make.\n" + 
865         "if not defined OO_SDK_MAKE_HOME (\n" + 
866         "   echo Error: the variable OO_SDK_MAKE_HOME is missing!\n" +
867         "   goto :error\n" +
868         " )\n" + 
869         "\n" +
870         "REM Check installation path for the zip tool.\n" + 
871         "if not defined OO_SDK_ZIP_HOME (\n" +
872         "   echo Error: the variable OO_SDK_ZIP_HOME is missing!\n" + 
873         "   goto :error\n" +
874         " )\n" +
875         "\n" +
876         "REM Set library path. \n" + 
877         "set LIB=%OO_SDK_HOME%\\lib;%LIB%\n" +
878         "if defined CPP_WINDOWS_SDK (\n" +
879         "   set LIB=%LIB%;%CPP_WINDOWS_SDK%\\lib\n" +
880         " )\n" +
881         "\n" +
882         "REM Set office program path.\n" +
883         "if defined OFFICE_HOME (\n" +
884         "   set OFFICE_PROGRAM_PATH=%OFFICE_HOME%\\program\n" +
885         " )\n" +
886         "\n" +
887         "REM Set office program path.\n" +
888         "if defined OFFICE_BASE_HOME (\n" +
889         "   set OFFICE_BASE_PROGRAM_PATH=%OFFICE_BASE_HOME%\\program\n" +
890         " )\n" +
891         "\n" +
892                 "REM Set UNO path, necessary to ensure that the cpp examples using the\n" +
893                 "REM new UNO bootstrap mechanism use the configured office installation\n" +
894                 "REM (only set when using an Office).\n" +
895                 "if defined OFFICE_HOME (\n" +
896                 "   set UNO_PATH=%OFFICE_PROGRAM_PATH%\n" +
897                 " )\n" +
898         "\n" +
899         "REM if defined OO_SDK_URE_HOME (\n" +
900         "set OO_SDK_URE_BIN_DIR=%OO_SDK_URE_HOME%\\bin\n" +
901         "set OO_SDK_URE_LIB_DIR=%OO_SDK_URE_HOME%\\bin\n" +
902         "set OO_SDK_URE_JAVA_DIR=%OO_SDK_URE_HOME%\\java\n" +
903         "REM ) else (\n" +
904         "set OO_SDK_OFFICE_BIN_DIR=%OFFICE_PROGRAM_PATH%\n" +
905         "set OO_SDK_OFFICE_LIB_DIR=%OFFICE_BASE_PROGRAM_PATH%\n" +
906         "set OO_SDK_OFFICE_JAVA_DIR=%OFFICE_BASE_PROGRAM_PATH%\\classes\n" +
907         "REM )\n" +
908         "\n" +
909         "REM Set classpath\n" +
910         "set CLASSPATH=%OO_SDK_URE_JAVA_DIR%\\juh.jar;%OO_SDK_URE_JAVA_DIR%\\jurt.jar;%OO_SDK_URE_JAVA_DIR%\\ridl.jar;%OO_SDK_URE_JAVA_DIR%\\unoloader.jar;%OO_SDK_OFFICE_JAVA_DIR%\\unoil.jar\n" +
911         "REM if defined OFFICE_HOME (\n" +
912         "REM     set CLASSPATH=%CLASSPATH%;%OO_SDK_OFFICE_JAVA_DIR%\\unoil.jar\n" +
913         "REM  )\n" +
914         "\n" +
915         "REM Add directory of the SDK tools to the path.\n" +
916         "set PATH=%OO_SDK_HOME%\\bin;%OO_SDK_URE_BIN_DIR%;%OO_SDK_OFFICE_BIN_DIR%;%OO_SDK_HOME%\\WINexample.out\\bin;%PATH%\n" +
917         "\n" +
918         "REM Set PATH appropriate to the output directory\n" +
919         "if defined OO_SDK_OUT (\n" + 
920         "   set PATH=%OO_SDK_OUT%\\WINexample.out\\bin;%PATH%\n" + 
921         " ) else (\n" + 
922         "   set PATH=%OO_SDK_HOME%\\WINexample.out\\bin;%PATH%\n" + 
923         " )\n" + 
924         "\n" +
925         "REM Add directory of the command make to the path, if necessary.\n" +
926         "if defined OO_SDK_MAKE_HOME set PATH=%OO_SDK_MAKE_HOME%;%PATH%\n" + 
927         "\n" + 
928         "REM Add directory of the zip tool to the path, if necessary.\n" +
929         "if defined OO_SDK_ZIP_HOME set PATH=%OO_SDK_ZIP_HOME%;%PATH%\n" +
930         "\n" + 
931         "REM Add directory of the C++ compiler to the path, if necessary.\n" +
932         "if defined OO_SDK_CPP_HOME set PATH=%OO_SDK_CPP_HOME%;%PATH%\n" + 
933         "\n" +
934         "REM Add directory of the C# and VB.NET compilers to the path, if necessary.\n" + 
935         "if defined OO_SDK_CLI_HOME set PATH=%OO_SDK_CLI_HOME%;%PATH%\n" + 
936         "\n" + 
937         "REM Add directory of the Java tools to the path, if necessary.\n" + 
938         "if defined OO_SDK_JAVA_HOME set PATH=%OO_SDK_JAVA_HOME%\\bin;%OO_SDK_JAVA_HOME%\\jre\\bin;%PATH%\n" +
939         "\n" +
940         "REM Set environment for C++ compiler tools, if necessary.\n" + 
941         "if defined OO_SDK_CPP_HOME call \"%OO_SDK_CPP_HOME%\\VCVARS32.bat\"\n" +
942         "\n" +
943         "REM Set tilte to identify the prepared shell.\n" + 
944         "title Shell prepared for SDK\n" + 
945         "\nREM Prepare shell with all necessary environment variables.\n" +
946         "echo.\n" +
947         "echo  ******************************************************************\n" +
948         "echo  *\n" + 
949         "echo  * SDK environment is prepared for Windows\n" +
950         "echo  *\n" +       
951         "echo  * SDK = %OO_SDK_HOME%\n" +
952         "echo  * Office = %OFFICE_HOME%\n" +
953         "echo  * Office Base = %OFFICE_BASE_HOME%\n" +
954         "echo  * URE = %OO_SDK_URE_HOME%\n" +
955         "echo  * Make = %OO_SDK_MAKE_HOME%\n" +
956         "echo  * Zip = %OO_SDK_ZIP_HOME%\n" +
957         "echo  * C++ Compiler = %OO_SDK_CPP_HOME%\n" +
958         "echo  * C# and VB.NET compilers = %OO_SDK_CLI_HOME%\n" +
959         "echo  * Java = %OO_SDK_JAVA_HOME%\n" +
960         "echo  * Special Output directory = %OO_SDK_OUT%\n" +
961         "echo  * Auto deployment = %SDK_AUTO_DEPLOYMENT%\n" +
962         "echo  *\n" +
963         "echo  ******************************************************************\n" +
964         "echo.\n" +
965         "goto end\n" + 
966         "\n" +
967         " :error\n" +
968         "Error: Please insert the necessary environment variables into the batch file.\n" + 
969         "\n" + 
970         " :end\n" 
971         );
972         newFile.Close();