Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

726 lines
26 KiB

  1. /***********************************************************************
  2. Created: 5th June 2001
  3. Last Modified: 28th June 2001
  4. ***********************************************************************/
  5. /** SCRIPT SPECIFIC VARIABLES **/
  6. var File; //used for input argument
  7. var LFile = "status.log"; //log file create (OK to change!)
  8. var Title = "Creating WinPE Images"; //title on all dialogs created (OK to change!)
  9. var Arch = "32"; //what arch to use, default to 32-bit
  10. var Temp_Loc = "WinPE.temp.build"; //where it temp copies files from opk (OK to change!)
  11. var Default_Dest_Name = "CustWinPE"; //default location to build WinPE. (OK to change!)
  12. var Default_ISO_Name = "WinPEImage.iso" //default ISO image name
  13. var OPK_Location = "d:"; //defaults to d:
  14. var XP_Location = "d:"; //default to d:
  15. var startfile = "winpesys.inf"; //the file which has the reg key for startnet.cmd
  16. var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";//used for checking drive avalibility on net usage
  17. var Max_Components = 10; //dufault number of maximum components
  18. var std_size = 80; //approx target size of the image in MB (used to check if it expanded files)
  19. var Drive_Space_Needed = 300; //space for build location (in MB)
  20. /** VARIABLE CONSTANTS **/
  21. var vbCritical = 16;
  22. var vbQuestion = 32;
  23. var vbExclam = 48;
  24. var vbInfo = 64;
  25. var vbOKOnly = 0;
  26. var vbOKCancel = 1;
  27. var vbAbort = 2;
  28. var vbYesNoCancel = 3;
  29. var vbYesNo = 4;
  30. var vbRetryCancel = 5;
  31. var drtype = new Array(5);//array for drive types
  32. drtype[0] = " Unknown ";
  33. drtype[1] = " Removable ";
  34. drtype[2] = " Fixed ";
  35. drtype[3] = " Remote ";
  36. drtype[4] = " CDROM ";
  37. drtype[5] = " RAMDisk ";
  38. var netdrive = new Array(2); //array for network connections
  39. netdrive[0] = "";
  40. netdrive[1] = "";
  41. var Component = new Array(Max_Components);
  42. var HelpMsg = "Usage: [/?] "+WScript.ScriptName+" <parameter file>\nTo generate a parameter file please run CreateWinPE.hta (double click it)";
  43. // vars used internally (Don't change these)
  44. var In_File;
  45. var OPK_Drive;
  46. var OPK_Loc;
  47. var XP_Loc;
  48. var XP_Drive;
  49. var Dest_Name;
  50. var Dest_Option;
  51. var CommandLine ="";
  52. var Wasnet="0";
  53. var Image_Destination;
  54. var line;
  55. var temp_dest;
  56. var temp_mkdir;
  57. var oDrive;
  58. var Startup="startnet.cmd"; //don't change this
  59. var Winbomp="winbom.ini"; //don't change this
  60. var ReturnVal;
  61. var Com_Count = 0;
  62. var count = 0;
  63. var delaywait = 15;
  64. var Home_Drv="c:";
  65. var Wallpaper="winpe.bmp";
  66. var Done_All = 1; //used for making sure each section in the parameter file is only entered once.
  67. //creating WSH object
  68. var wshShell = WScript.CreateObject("WScript.Shell");
  69. var wshNet = WScript.CreateObject("WScript.Network");
  70. var objEnv = wshShell.Environment("Process"); //doing this so that it uses current HOMEDRIVE
  71. Home_Drv = objEnv("HOMEDRIVE");
  72. Temp_Loc=Home_Drv+"\\"+Temp_Loc;
  73. Default_Dest_Name = Home_Drv+"\\"+Default_Dest_Name; //default location to build WinPE. (OK to change!)
  74. Default_ISO_Name = Home_Drv+"\\"+Default_ISO_Name; //default ISO image name
  75. //checking number of args. It HAS to be 1 else error out
  76. if(WScript.Arguments.length != 1)
  77. {
  78. wshShell.popup(HelpMsg,0,Title,vbInfo);
  79. WScript.Quit();
  80. }
  81. File=WScript.Arguments.Item(0); // saving 1st arg as File
  82. if (File == "/?" || File == "help") //checking of 1st arg is help
  83. {
  84. wshShell.popup(HelpMsg,0,Title,vbInfo);
  85. WScript.Quit();
  86. }
  87. //creating unique logfile name (comment this to disable)
  88. //LFile = "status_"+wshNet.UserName+".log";
  89. //creating objects necessary
  90. var fso=new ActiveXObject("Scripting.FileSystemObject"); //create file sys obj
  91. try{
  92. var logfile=fso.OpenTextFile(LFile,2,true); //logfile
  93. }
  94. catch(e){
  95. wshShell.Popup("ERROR: "+LFile+" is either write protected or being used by another program.\nTerminating Script!",0,Title,vbCritical);
  96. WScript.Quit();
  97. }
  98. logfile.WriteLine(Date()+"\tLOG FILE created!");
  99. logfile.WriteLine(Date()+"\tComputer Name=" + wshNet.ComputerName+",User Name=" + wshNet.UserName);
  100. logfile.WriteBlankLines(1);
  101. //checking if file exists
  102. if (!fso.FileExists(File))
  103. CleanUp("File "+ File + " does not exist!.");
  104. In_File = fso.OpenTextFile(File);
  105. // calling all function to operate now
  106. Read_Settings(); //reads the settings file for inputs to the script
  107. Copy_OPK_Files(); //copies OPK files to temp location
  108. Change_Startup(); //makes changes to add custom startnet.cmd
  109. Change_Wallpaper(); //adds custom wallpaper
  110. Change_Winbom(); //makes changes to add custom winbom.ini
  111. Image_Dest(); //runs mkimg.cmd in here
  112. CleanUp("OK");
  113. /*END OF MAIN*/
  114. /*********************** FUNCTIONs*****************************************/
  115. /*
  116. FUNCTION: Read_Settings()
  117. This function reads the parms from the parameter file, and saves them to local variables.
  118. IT also does some minimal error checking on those parms
  119. */
  120. function Read_Settings()
  121. {
  122. while (!In_File.AtEndOfStream)
  123. {
  124. switch (In_File.ReadLine().substring(0,5))
  125. {
  126. case "[Arch": //looks for [Architecture]
  127. //reading arch type (can be IA64, I386 32 or 64)
  128. Arch=In_File.ReadLine();
  129. Arch=Arch.toUpperCase();
  130. if (Arch != "32" && Arch != "64" && Arch != "I386" && Arch != "IA64" && Arch != "X86" )
  131. CleanUp("Arch type invalid! ");
  132. if (Arch == "32" || Arch == "x86" || Arch == "I386")
  133. Arch = "I386";
  134. else
  135. Arch = "IA64";
  136. logfile.WriteLine(Date()+"\t(*) Arch Type = "+Arch);
  137. Done_All = Done_All*2; //for verification
  138. break;
  139. case "[Imag": //looks for [Image Destination]
  140. Image_Destination = In_File.ReadLine(); //where to put it ex CD/HDD
  141. if(Image_Destination.toUpperCase() != "CD" && Image_Destination.toUpperCase() != "HDD")
  142. CleanUp("Image Dest not valid! Must be CD or HDD.");
  143. Dest_Name = In_File.ReadLine(); // name of dest
  144. if(Image_Destination.toUpperCase() == "HDD")
  145. {
  146. var d = fso.GetDrive(Dest_Name.substring(0,1));
  147. if (d.DriveType != 2)
  148. CleanUp("Can't create an image on a "+drtype[d.DriveType]+"drive. It must be a FIXED drive.\nPlease Change the [Image Destination] section in "+File+ " file to correct this.");
  149. }
  150. //checking the file extension ...if not .iso then making it so
  151. if(Dest_Name.substring(Dest_Name.length -4,Dest_Name.length).toLowerCase() != ".iso")
  152. {
  153. if(Image_Destination.toUpperCase() == "CD")
  154. Dest_Name=Dest_Name+".iso";
  155. }
  156. else
  157. {
  158. if(Image_Destination.toUpperCase() == "HDD")
  159. CleanUp("Image Name "+Dest_Name+" is invalid for HDD.");
  160. }
  161. //for special case when no option and its the end of the file.
  162. try{
  163. Dest_Option = In_File.ReadLine(); //will be NULL otherwise
  164. if(Dest_Option.toLowerCase() == "bootable")
  165. {
  166. wshShell.Popup("You have choosen to make this image bootable.\nThis may take longer to run.\nYou will be notified when the scrpit is complete.",delaywait,Title,0);
  167. }
  168. }catch(e)
  169. {
  170. CleanUp("Add an extra blank line to the end of "+File);
  171. }
  172. Done_All = Done_All*3; //for verification
  173. break;
  174. case "[OPK ": //looks for [OPK Location]
  175. OPK_Loc = In_File.ReadLine();
  176. if (OPK_Loc == "")
  177. CleanUp("OPK Location not specified!");
  178. logfile.WriteLine(Date()+"\t(*) OPK Locatoin = "+ OPK_Loc);
  179. Done_All = Done_All*5; //for verification
  180. break;
  181. case "[WinX": //looks for [WinXP Location]
  182. XP_Loc = In_File.ReadLine();
  183. if (OPK_Loc == "")
  184. CleanUp("Windows XP Location not specified!");
  185. logfile.WriteLine(Date()+"\t(*) Windows XP Locatoin = "+ XP_Loc);
  186. Done_All = Done_All*7; //for verification
  187. break;
  188. case "[Star": //for [Startup] , where startnet.cmd stuff goes
  189. Startup = In_File.ReadLine();
  190. if (Startup.toLowerCase() != "startnet.cmd" && Startup != "")
  191. if (!fso.FileExists(Startup)) //checking if file exists
  192. CleanUp(Startup+" -- Startup file not found!");
  193. Done_All = Done_All*11; //for verification
  194. break;
  195. case "[Winb": //for [Winbom] , where custom winbom.ini info is placed
  196. try{
  197. Winbom = In_File.ReadLine();
  198. }catch(e)
  199. {CleanUp("Must have [Winbom] section in "+File);}
  200. if (Winbom.toLowerCase() != "winbom.ini" && Winbom != "")
  201. if (!fso.FileExists(Winbom))
  202. CleanUp(Winbom+" -- winbom file not found!");
  203. Done_All = Done_All*13; //for verification
  204. break;
  205. case "[Opti": //for [Optional Components]
  206. count = 0;
  207. Component[count]=In_File.ReadLine();
  208. while(Component[count] != "" && count < 10) //loop which look at optional component
  209. {
  210. count++;
  211. try
  212. {
  213. Component[count]=In_File.ReadLine();
  214. }
  215. catch(e)
  216. {
  217. CleanUp("parmater file is incorrect!");
  218. }
  219. }
  220. if (count > 10)
  221. {
  222. CleanUp("Maximum optional components allowed is "+Max_Components);
  223. }
  224. Com_Count=count;
  225. for(count=0;count<Com_Count;count++)
  226. {
  227. if (!fso.FileExists(Component[count]))
  228. CleanUp(Component[count]+" install file not found!");
  229. }
  230. Done_All = Done_All*17; //for verification
  231. break;
  232. case "[Wall": // for [Wallpaper]
  233. Wallpaper = In_File.ReadLine();
  234. if(Wallpaper != "" && Wallpaper != "winpe.bmp")
  235. {
  236. if (!fso.FileExists(Wallpaper))
  237. CleanUp("Wallpaper "+Wallpaper+" file doesn't exist!");
  238. }
  239. break;
  240. default:
  241. break;
  242. }
  243. }
  244. /* The Done_All var id used to make sure that all the sections of the parameter file
  245. are entered only once. (The use of prime numbers allows for making sure each section
  246. is read only once). */
  247. if (Done_All != (2*3*5*7*11*13*17))
  248. CleanUp("The parameter file "+File+ " is incomplete. Refer to readme.htm for help.");
  249. } /*Read_Settings()*/
  250. function Copy_OPK_Files()
  251. {
  252. /* making dir for temp use ... this will be deleted on cleanup
  253. making sure its doesn't exist already..if so deleing it for good */
  254. if(fso.FolderExists(Temp_Loc))
  255. try{fso.DeleteFolder(Temp_Loc,true)}
  256. catch(e)
  257. {
  258. wshShell.Popup("Can't delete "+Temp_Loc+"\nTerminating script!",0,Title,vbCritical);
  259. logfile.WriteLine(Date()+"\t(E) Can't delete "+Temp_Loc);
  260. WScript.Quit()
  261. }
  262. fso.CreateFolder(Temp_Loc);
  263. /*Checking location if drive/net (for drive must be FIXED drive)
  264. checks if exists and ready */
  265. OPK_Location=Check_Loc(OPK_Loc,0);
  266. OPK_Drive=OPK_Location.substring(0,2);
  267. oDrive=fso.GetDrive(OPK_Drive); //get obj for that drive
  268. if( oDrive.DriveType == 4)
  269. wshShell.Popup("Please place the OPK CD into drive "+OPK_Drive,delaywait,Title,vbOKOnly);
  270. Verify_OPK_CD(OPK_Location);
  271. logfile.WriteLine(Date()+"\t(S) OPK CD is verified!");
  272. // CALLING Copy_XP_Files()
  273. Copy_XP_Files(); //copies XP files to dest location
  274. //copy the files over to the build location
  275. CommandLine="xcopy "+OPK_Location+"\\WINPE "+Temp_Loc+" /F /H";
  276. wshShell.Run(CommandLine,1,true);
  277. //copying factory.exe and netcfg.exe
  278. if(Arch == "I386")
  279. {
  280. CommandLine="xcopy "+OPK_Location+"\\TOOLS\\x86\\Factory.exe "+Temp_Loc;
  281. wshShell.Run(CommandLine,1,true);
  282. CommandLine="xcopy "+OPK_Location+"\\TOOLS\\x86\\Netcfg.exe "+Temp_Loc;
  283. wshShell.Run(CommandLine,1,true);
  284. }
  285. else
  286. {
  287. CommandLine="xcopy "+OPK_Location+"\\TOOLS\\"+Arch+"\\Factory.exe "+Temp_Loc;
  288. wshShell.Run(CommandLine,1,true);
  289. CommandLine="xcopy "+OPK_Location+"\\TOOLS\\"+Arch+"\\Netcfg.exe "+Temp_Loc;
  290. wshShell.Run(CommandLine,1,true);
  291. }
  292. logfile.WriteLine(Date()+"\t(S) OPK files copied from"+OPK_Loc+" to "+Temp_Loc);
  293. return;
  294. }/*Copy_OPK_Files()*/
  295. function Copy_XP_Files()
  296. {
  297. //Checking location if drive/net (for drive must be FIXED drive)
  298. //checks if exists and ready
  299. XP_Location=Check_Loc(XP_Loc,1);
  300. XP_Drive=XP_Location.substring(0,2);
  301. //if its a local drive making sure both aren't CDROM drives. IF so prompt to switch
  302. oDrive=fso.GetDrive(XP_Drive); //get obj for that drive
  303. //if cdrom then give some self destructing prompt
  304. if( oDrive.DriveType == 4)
  305. {
  306. //check if XP and OPK CD location are the same CDROM. If so then prompt to switch
  307. if (XP_Drive == OPK_Drive)
  308. {
  309. var User_Return = wshShell.Popup("Please remove the OPK CD from "+XP_Drive+" and place the WinXP CD into the drive",0,Title,vbOKCancel);
  310. if (User_Return == 2) //if cancel was pressed
  311. CleanUp("User canceled!");
  312. }
  313. else
  314. {
  315. wshShell.Popup("Please place the WinXP CD into drive "+XP_Drive,delaywait,Title,vbOKOnly);
  316. }
  317. }
  318. //make sure the CD is actually there
  319. Verify_XP(XP_Location);
  320. logfile.WriteLine(Date()+"\t(S) WinXP verified!");
  321. return;
  322. }/*Copy_XP_Files()*/
  323. function Verify_OPK_CD(parm)
  324. {
  325. var verify="yes";
  326. //check for certain files and folder to make sure CD is actually OPK CD
  327. if(!fso.FolderExists(parm+"\\WINPE"))
  328. verify="no";
  329. if(!fso.FileExists(parm+"\\winpe\\extra.inf"))
  330. verify="no";
  331. if(!fso.FileExists(parm+"\\winpe\\winpesys.inf"))
  332. verify="no";
  333. if(!fso.FileExists(parm+"\\winpe\\winbom.ini"))
  334. verify="no";
  335. if(!fso.FileExists(parm+"\\winpe\\mkimg.cmd"))
  336. verify="no";
  337. if(!fso.FileExists(parm+"\\winpe\\oemmint.exe"))
  338. verify="no";
  339. if(!fso.FolderExists(parm+"\\TOOLS"))
  340. verify="no";
  341. if (verify == "no")
  342. CleanUp(OPK_Loc+" isn't the location for the OPK!");
  343. }/*Verify_OPK_CD(parm)*/
  344. function Verify_XP(parm)
  345. {
  346. var verify="yes";
  347. //check for certain files and folder to make sure CD is actually OPK CD
  348. if(!fso.FileExists(parm+"\\setup.exe"))
  349. verify="no";
  350. if(!fso.FolderExists(parm+"\\"+Arch))
  351. verify="no";
  352. if(!fso.FolderExists(parm+"\\"+Arch+"\\SYSTEM32"))
  353. verify="no";
  354. if(!fso.FileExists(parm+"\\"+Arch+"\\System32\\smss.exe"))
  355. verify="no";
  356. if(!fso.FileExists(parm+"\\"+Arch+"\\System32\\ntdll.dll"))
  357. verify="no";
  358. if(!fso.FileExists(parm+"\\"+Arch+"\\winnt32.exe"))
  359. verify="no";
  360. if (verify == "no")
  361. CleanUp(XP_Loc+" isn't the location for Windows XP!");
  362. return;
  363. }/*Verify_XP(parm)*/
  364. function Check_Loc(parm,type)
  365. {
  366. if (parm == "")
  367. CleanUp("Value for OPK location or WinXP location is undefined!");
  368. if (type != 1 && type != 0) //XP=1,OPK=0
  369. CleanUp("Function Check_Loc was called incorrectly.");
  370. if (parm.substring(parm.length -1,parm.length) == "\\")
  371. parm = parm.substring(0,parm.length -1);
  372. if (parm.substring(0,2) == "\\\\") //its a net location
  373. {
  374. //making sure type is correct
  375. Wasnet="1"; //setting net location flag
  376. //checking for user domain
  377. if (wshNet.UserDomain == "")
  378. CleanUp("Domain must exist to connect to network!");
  379. netdrive[type]=FindDrive()+":";
  380. logfile.WriteLine(Date()+"\t(*) Mapping "+parm+" to "+netdrive[type]);
  381. try{
  382. wshNet.MapNetworkDrive(netdrive[type],parm);
  383. }
  384. catch(e)
  385. {
  386. Wasnet="0";
  387. if (type == 0)
  388. CleanUp("Error connecting to "+parm+"\n\nCheck the OPK Location manually before running the script again!");
  389. else
  390. CleanUp("Error connecting to "+parm+"\n\nCheck the Windows XP Location manually before running the script again!");
  391. }
  392. var Newname = netdrive[type]; //+ parm.substring(1,parm.length);
  393. return Newname;
  394. }
  395. else //its a drive (ie not a net connection
  396. {
  397. var Drive_Letter=parm.substring(0,1);
  398. //CHK :checks to see if drive exists
  399. if (!fso.DriveExists(Drive_Letter))
  400. CleanUp("Didn't find drive "+Drive_Letter);
  401. var oDrive=fso.GetDrive(Drive_Letter); //get obj for that drive
  402. //CHK: checks if drive is ready
  403. if (!oDrive.IsReady)
  404. CleanUp("Drive not ready. Verify that the drive you specified is working properly.");
  405. return parm;
  406. }
  407. }/*Check_Loc(parm)*/
  408. function Change_Startup()
  409. {
  410. ///////////////////////
  411. //opens winpesys.inf (or corresponding file) to change startnet.cmd to autoexec.cmd
  412. //will always happen
  413. var setupreg = fso.OpenTextFile(Temp_Loc+"\\"+startfile,1,false,-1); //opens in Unicode
  414. //opening tempfile to change to winpesys.inf after making changes
  415. var newsetupreg = fso.CreateTextFile(Temp_Loc+"\\newsetupreg.inf",true,true); //write in Unicode
  416. var replacethis="HKLM,\"Setup\",\"CmdLine\",,\"cmd.exe /k startnet.cmd\"";
  417. while (!setupreg.AtEndOfStream)
  418. {
  419. line = setupreg.ReadLine();
  420. if ( line != replacethis)
  421. newsetupreg.WriteLine(line);
  422. else
  423. newsetupreg.WriteLine("HKLM,\"Setup\",\"CmdLine\",,\"cmd.exe /k autoexec.cmd\"");
  424. }
  425. setupreg.Close();
  426. newsetupreg.Close();
  427. fso.DeleteFile(Temp_Loc+"\\"+startfile); //deletes old setupreg
  428. wshShell.Run("cmd /c ren "+Temp_Loc+"\\newsetupreg.inf "+startfile,1,true);
  429. ///////////////////////
  430. //creating autoexec.cmd
  431. var autoexec = fso.CreateTextFile(Temp_Loc+"\\autoexec.cmd",true);
  432. autoexec.WriteLine("@echo off");
  433. autoexec.Close();
  434. ///////////////////////
  435. //opening autoexec.cmd for startup commands in winpe
  436. autoexec= fso.OpenTextFile(Temp_Loc+"\\autoexec.cmd",8);
  437. var custfilename="";
  438. //for startnet.cmd or custom file
  439. if ( Startup.toLowerCase() == "startnet.cmd" || Startup == "")
  440. {
  441. autoexec.WriteLine("call startnet.cmd");
  442. custfilename="startnet.cmd";
  443. }
  444. else
  445. {
  446. //removing path etc before filename
  447. custfilename = Startup.substring(Startup.lastIndexOf("\\")+1,Startup.length);
  448. fso.CopyFile(Startup,Temp_Loc+"\\");
  449. autoexec.WriteLine("call "+custfilename);
  450. }
  451. autoexec.Close();
  452. ///////////////////////
  453. //now gonna hack extra.inf so that autoexec.cmd and other files are added to WinPE Image
  454. var xtra= fso.OpenTextFile(Temp_Loc+"\\extra.inf",1,false,-1); //opens in unicode
  455. var newextra = fso.CreateTextFile(Temp_Loc+"\\newextra.txt",true,true); //writes in unicode
  456. while (!xtra.AtEndOfStream)
  457. {
  458. line = xtra.ReadLine();
  459. if ( line == "[ExtraFiles]")
  460. {
  461. newextra.WriteLine(line);
  462. newextra.WriteLine("autoexec.cmd=1,,,,,,,,0,0,,1,2"); // adds autoexec.cmd
  463. newextra.WriteLine(custfilename+"=1,,,,,,,,0,0,,1,2"); // adds startnet.cmd or other file
  464. }
  465. else
  466. {
  467. newextra.WriteLine(line);
  468. }
  469. }
  470. xtra.Close();
  471. newextra.Close();
  472. fso.DeleteFile(Temp_Loc+"\\extra.inf"); //deletes old setupreg
  473. wshShell.Run("cmd /c ren "+Temp_Loc+"\\newextra.txt extra.inf ",1,true); //renaming
  474. logfile.WriteLine(Date()+"\t(S) Fixed "+startfile+" to run "+custfilename+" when WinPE starts up.");
  475. return;
  476. }/*Change_Startup()*/
  477. function Change_Winbom()
  478. {
  479. //don't need to mess with it - ie for default
  480. if (Winbom.toLowerCase() == "winbom.ini" || Winbom == "")
  481. return;
  482. fso.CopyFile(Winbom,Temp_Loc+"\\",true);
  483. logfile.WriteLine(Date()+"\t(S) Using custom winbom.ini located at "+Winbom);
  484. return;
  485. }/*Change_Winbom()*/
  486. function Image_Dest()
  487. {
  488. logfile.WriteLine(Date()+"\t(*) Now running mkimg.cmd");
  489. switch(Image_Destination.toUpperCase())
  490. {
  491. case "CD":
  492. if (Dest_Name == "")
  493. Dest_Name = Default_ISO_Name;
  494. if (Arch.toLowerCase() == "ia64")
  495. wshShell.Popup("Now creating 64-bit CD image. Place floppy in drive a: and click OK!",delaywait+20,Title,vbOKOnly);
  496. //CommandLine="cmd /c cd "+Temp_Loc+" & mkimg.cmd "+XP_Location +" "+Home_Drv+"\\testimage \""+Dest_Name+"\"";
  497. //before it was like this..now changed cause we need to add opt com's after running mkimg and to make .iso need to do extra stuff
  498. CommandLine="cmd /c cd "+Temp_Loc+" & mkimg.cmd "+XP_Location +" "+Home_Drv+"\\testimage ";
  499. wshShell.Run(CommandLine,1,true);
  500. Install_COM();
  501. Fix_Autoexec();
  502. Make_ISO(); //makes the .iso file
  503. fso.DeleteFolder(Home_Drv+"\\testimage");
  504. break;
  505. case "HDD":
  506. if (Dest_Name == "")
  507. Dest_Name = Default_Dest_Name;
  508. wshShell.Run("cmd /c "+Temp_Loc.substring(0,2),1,true);
  509. CommandLine="cmd /c cd "+Temp_Loc+" & mkimg.cmd "+XP_Location+" \""+Dest_Name+"\"";
  510. wshShell.Run(CommandLine,1,true);
  511. //installing optional components
  512. Install_COM();
  513. Fix_Autoexec();
  514. if (Dest_Option.toLowerCase() == "bootable")
  515. {
  516. // installing XP command console
  517. logfile.WriteLine(Date()+"\t(*) making HDD version of WinPE bootable!");
  518. wshShell.Run(XP_Location+"\\"+Arch+"\\winnt32.exe /cmdcons /unattend",1,true);
  519. //copies files to minint folder (will overwrite older minint if it exists)
  520. //fso.CopyFolder(Dest_Name+"\\"+Arch, Home_Drv+"\\Minint",true);
  521. wshShell.Run("xcopy "+Dest_Name+"\\"+Arch+" C:\\Minint /E /I /Y /H /F",1,true);
  522. fso.CopyFile(Dest_Name+"\\Winbom.ini", Home_Drv+"\\",true);
  523. wshShell.Run("cmd /c attrib -r C:\\Cmdcons\\txtsetup.sif");
  524. wshShell.Run("xcopy C:\\Minint\\txtsetup.sif C:\\Cmdcons\\ /Y");
  525. logfile.WriteLine(Date()+"\t(S) HDD version of WinPE in now bootable!");
  526. }
  527. //checks if its done
  528. if (!fso.FolderExists(Dest_Name))
  529. CleanUp("mkimg.cmd didn't work properly!\nCheck the parameter file "+File+" and try running the script again.");
  530. var fc = fso.GetFolder(Dest_Name);
  531. if (fc.Size < (std_size*1024*1024)) //is its less than 140MB then there's a prob.
  532. CleanUp("mkimg.cmd didn't copy all necessary file!\nCheck the parameter file "+File+" and try running the script again.");
  533. break;
  534. default:
  535. CleanUp("Not valid dest for image! "+Image_Destination);
  536. break;
  537. }
  538. logfile.WriteLine(Date()+"\t(S) mkimg.cmd complete!");
  539. //adding one line to autoexec.cmd
  540. autoexec= fso.OpenTextFile(Temp_Loc+"\\autoexec.cmd",8);
  541. autoexec.WriteLine("cd \\Minint");
  542. autoexec.Close();
  543. return;
  544. }/*Image_Dest()*/
  545. function Change_Wallpaper()
  546. {
  547. if (Wallpaper == "" || Wallpaper == "winpe.bmp")
  548. return;
  549. if(!fso.FileExists(Temp_Loc+"\\winpe.bmp"))
  550. {
  551. logfile.WriteLine(Date()+"\t(E) Default wallpaper file winpe.bmp doesn't exist. No wallpaper was added!");
  552. return;
  553. }
  554. //delete default wallpaper
  555. fso.DeleteFile(Temp_Loc+"\\winpe.bmp",true);
  556. //copy custom wallpaper to Temp_Loc
  557. fso.CopyFile(Wallpaper,Temp_Loc+"\\",true);
  558. //rename the wallpaper file to winpe.bmp
  559. CommandLine="cmd /c cd "+Temp_Loc+" && ren "+ Wallpaper.substring(Wallpaper.lastIndexOf("\\")+1,Wallpaper.length)+" winpe.bmp";
  560. wshShell.Run(CommandLine,0,true);
  561. logfile.WriteLine(Date()+"\t(S) Changed Wallpaper!");
  562. return;
  563. }
  564. function FindDrive()
  565. {
  566. var drivefound;
  567. var i;
  568. for(i=25;i>-1;i--)
  569. {
  570. drivefound=alphabet.substring(i,i+1);
  571. if (!fso.DriveExists(drivefound))
  572. return drivefound;
  573. }
  574. CleanUp("No net connections can be made cause all drive letters are used.");
  575. }/*FindDrive()*/
  576. function Install_COM()
  577. {
  578. ///////////////////////
  579. //calling component scripts
  580. if (Image_Destination.toUpperCase()=="CD")
  581. temp_dest = Home_Drv+"\\testimage";
  582. else
  583. temp_dest = Dest_Name;
  584. if (Com_Count != 0)
  585. {
  586. for(count=0;count<Com_Count;count++)
  587. {
  588. logfile.WriteLine(Date()+"\t(*) "+Component[count]+" is installing component.");
  589. if(Arch.toLowerCase() == "ia64")
  590. Return_Val = wshShell.Run(Component[count]+" /S:"+XP_Location+" /D:"+temp_dest+" /Q /64",0,true);
  591. else
  592. Return_Val = wshShell.Run(Component[count]+" /S:"+XP_Location+" /D:"+temp_dest+" /Q",0,true);
  593. if (Return_Val != 0)
  594. CleanUp(Component[count]+" component install file has error in it.");
  595. else
  596. logfile.WriteLine(Date()+"\t(S) "+Component[count]+" component installed.");
  597. }
  598. }
  599. else
  600. {
  601. logfile.WriteLine(Date()+"\t(*) No optional components being installed!");
  602. }
  603. return;
  604. }
  605. function Fix_Autoexec()
  606. {
  607. //this function add cd \minint to end of autoexec.cmd
  608. if (Image_Destination.toUpperCase()=="CD")
  609. temp_dest = Home_Drv+"\\testimage";
  610. else
  611. temp_dest = Dest_Name;
  612. autoexec= fso.OpenTextFile(temp_dest+"\\"+Arch+"\\system32\\autoexec.cmd",8);
  613. autoexec.WriteLine("cd \\Minint");
  614. autoexec.Close();
  615. }
  616. function Make_ISO()
  617. {
  618. //creating dir (if it exists nothing happens)
  619. temp_mkdir = Dest_Name.substring(0,Dest_Name.lastIndexOf("\\") );
  620. if (!fso.FolderExists(temp_mkdir))
  621. {
  622. wshShell.Run("cmd /c cd \ && mkdir "+temp_mkdir);
  623. logfile.WriteLine(Date()+"\t(S) Created folder "+temp_mkdir+" where ISO image file will be placed!");
  624. }
  625. if (Arch.toLowerCase() == "ia64")
  626. {
  627. wshShell.Run("xcopy "+Home_Drv+"\\testimage\\"+Arch+"\\setupldr.efi a:\ 2>1>nul",1,true);
  628. wshShell.Run("cmd /c cd "+Temp_Loc+" && dskimage.exe a: efisys.bin 2>1>nul",1,true);
  629. wshShell.Run("cmd /c cd "+Temp_Loc+" && oscdimg.exe -n -befisys.bin "+Home_Drv+"\\testimage \""+Dest_Name+"\"",1,true);
  630. }
  631. else
  632. {
  633. CommandLine="cmd /c cd "+Temp_Loc+" && oscdimg.exe -n -betfsboot.com "+Home_Drv+"\\testimage \""+Dest_Name+"\"";
  634. wshShell.Run(CommandLine,1,true);
  635. }
  636. logfile.WriteLine(Date()+"\t(S) Created ISO image file!");
  637. }
  638. function CleanUp(parm)
  639. {
  640. if (Wasnet == "1")
  641. {
  642. if (netdrive[0] != "")
  643. {
  644. CommandLine="net use "+netdrive[0]+" /del";
  645. wshShell.Run(CommandLine);
  646. wshShell.SendKeys("y");
  647. }
  648. if (netdrive[1] != "")
  649. {
  650. CommandLine="net use "+netdrive[1]+" /del";
  651. wshShell.Run(CommandLine);
  652. wshShell.SendKeys("y");
  653. }
  654. }
  655. if (parm == "OK")
  656. {
  657. logfile.WriteBlankLines(1);
  658. logfile.WriteLine(Date()+"\tThe new image of WinPE can be found at "+Dest_Name);
  659. logfile.WriteLine(Date()+"\tCOMPLETE");
  660. wshShell.Popup("Script Complete! \n",0,Title,vbInfo);
  661. }
  662. else
  663. {
  664. logfile.WriteLine(Date()+"\t(E) "+parm);
  665. logfile.WriteBlankLines(1);
  666. logfile.WriteLine("Script Terminated @ "+Date());
  667. wshShell.Popup(parm+"\n\n Terminating Script!",0,Title,vbCritical);
  668. }
  669. // deleting temp storage folder
  670. if (fso.FolderExists(Temp_Loc))
  671. {
  672. try{fso.DeleteFolder(Temp_Loc); }
  673. catch(e){ wshShell.Popup("Can't delete "+Temp_Loc,0,Title,vbInfo);}
  674. }
  675. logfile.Close(); //closing logfile
  676. WScript.Quit();
  677. }/*CleanUp(parm)*/