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