Leaked source code of windows server 2003
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.

500 lines
26 KiB

  1. OPTION EXPLICIT
  2. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  3. '-----Windows Script Host script to generate components needed to run ADO
  4. '-----under Windows PE.
  5. '-----Copyright 2001, Microsoft Corporation
  6. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  7. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  8. '-----DIM, DEFINE VARIABLES, SET SOME GLOBAL OBJECTS
  9. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  10. DIM strCmdArg, strCmdSwitch, arg, strCmdArray, CDDriveCollection, CDDrive, CDSource, FSO, Folder, HDDColl
  11. DIM HDD, FirstHDD, strAppend, WSHShell, strDesktop, strOptDest, strDestFolder
  12. DIM FILE, strCMDExpand, strCMDMid, strJobTitle, strNeedCD, iAmPlatform, iArchDir
  13. DIM iAmQuiet,iHaveSource, iHaveDest, iWillBrowse, WshSysEnv, strOSVer, strWantToView, strFolderName, intOneMore
  14. DIM strCMDado, strCMDmsadc, strCMDOle_db, strIDir, strSysDir
  15. Const ForAppending = 8
  16. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  17. '-----OFFER/TAKE CMDLINE PARAMETERS
  18. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  19. If WScript.Arguments.Count <> 0 Then
  20. For each arg in WScript.Arguments
  21. strCmdArg = (arg)
  22. strCmdArray = Split(strCmdArg, ":", 2, 1)
  23. IF lcase(strCmdArray(0)) = "/s" or lcase(strCmdArray(0)) = "-s" THEN
  24. iHaveSource = 1
  25. CDSource = TRIM(strCmdArray(1))
  26. END IF
  27. IF lcase(strCmdArray(0)) = "/d" or lcase(strCmdArray(0)) = "-d" THEN
  28. iHaveDest = 1
  29. strOptDest = TRIM(strCmdArray(1))
  30. END IF
  31. IF lcase(strCmdArray(0)) = "/?" OR lcase(strCmdArray(0)) = "-?" THEN
  32. MsgBox "The following command-line arguments are accepted by this script:"&vbCRLF&vbCRLF&_
  33. """/s:filepath"" - alternate source location other than the CD-ROM drive."&vbCRLF&vbCRLF&"Examples:"&vbCRLF&_
  34. "/S:C:\"&vbCRLF&_
  35. "-s:Z:\"&vbCRLF&_
  36. "or"&vbCRLF&_
  37. "-S:\\Myserver\Myshare"&vbCRLF&vbCRLF&_
  38. "The script will still attempt to verify the presence of Windows XP files."&vbCrLF&vbCrLF&_
  39. "/D - Destination. Opposite of CD - specifies build destination. Otherwise placed on desktop."&vbCRLF&vbCRLF&_
  40. "/64 - build for Itanium. Generates scripts for Windows on the Itanium Processor Family."&vbCRLF&vbCRLF&_
  41. "/Q - run without any dialog. This will not confirm success, will notify on failure."&vbCRLF&vbCRLF&_
  42. "/E - explore completed files. Navigate to the created files when completed.", vbInformation, "Command-line arguments"
  43. WScript.Quit
  44. END IF
  45. IF lcase(strCmdArray(0)) = "/64" OR lcase(strCmdArray(0)) = "-64" THEN
  46. iAmPlatform = "Itanium"
  47. END IF
  48. IF lcase(strCmdArray(0)) = "/q" OR lcase(strCmdArray(0)) = "-q" THEN
  49. iAmQuiet = 1
  50. END IF
  51. IF lcase(strCmdArray(0)) = "/e" OR lcase(strCmdArray(0)) = "-e" THEN
  52. iWillBrowse = 1
  53. END IF
  54. Next
  55. ELSE
  56. iHaveSource = 0
  57. END IF
  58. IF strOptDest = "" THEN
  59. iHaveDest = 0
  60. ELSEIF INSTR(UCASE(strOptDest), "I386\") <> 0 OR INSTR(UCASE(strOptDest), "IA64\") <> 0 OR INSTR(UCASE(strOptDest), "SYSTEM32") <> 0 THEN
  61. MsgBox "The destination path needs to be the root of your newly created WinPE install - remove any extraneous path information, such as ""I386"" or ""System32""", vbCritical, "Destination Path Incorrect"
  62. WScript.Quit
  63. END IF
  64. IF iAmQuiet <> 1 THEN
  65. iAmQuiet = 0
  66. END IF
  67. IF iAmPlatform <> "Itanium" THEN
  68. iAmPlatform = "x86"
  69. END IF
  70. IF Right(strOptDest, 1) = "\" THEN
  71. strOptDest = Left(strOptDest, LEN(strOptDest)-1)
  72. END IF
  73. IF Right(CDSource, 1) = "\" THEN
  74. CDSource = Left(CDSource, LEN(CDSource)-1)
  75. END IF
  76. IF iAmPlatform = "Itanium" THEN
  77. iArchDir = "ia64"
  78. ELSEIF iAmPlatform = "x86" THEN
  79. iArchDir = "i386"
  80. END IF
  81. strJobTitle = "ADO Component Generation"
  82. SET WshShell = WScript.CreateObject("WScript.Shell")
  83. SET WshSysEnv = WshShell.Environment("SYSTEM")
  84. SET FSO = CreateObject("Scripting.FileSystemObject")
  85. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  86. '-----ERROR OUT IF NOT RUNNING ON Windows 2000 OR HIGHER
  87. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  88. strOSVer = WshSysEnv("OS")
  89. IF strOSVer <> "Windows_NT" THEN
  90. MsgBox "This script must be run on Windows 2000 or Windows XP", vbCritical, "Incorrect Windows Version"
  91. WScript.Quit
  92. END IF
  93. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  94. '-----GENERATE COLLECTION OF CD-ROM DRIVES VIA WMI. PICK FIRST AVAILABLE
  95. '-----ERROR OUT IF NO DRIVES FOUND
  96. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  97. IF iHaveSource = 0 THEN
  98. SET CDDriveCollection = GetObject("winmgmts:").ExecQuery("SELECT * FROM Win32_CDROMDrive")
  99. IF CDDriveCollection.Count <= 0 THEN
  100. MsgBox "No CD-ROM drives found. Exiting Script.", vbCritical, "No CD-ROM drive found"
  101. WScript.Quit
  102. END IF
  103. FOR EACH CDDrive IN CDDriveCollection
  104. CDSource = CDDrive.Drive(0)
  105. EXIT FOR
  106. NEXT
  107. END IF
  108. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  109. '-----PROMPT FOR WINDOWS CD - QUIT IF CANCELLED
  110. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  111. IF iAmQuiet = 0 THEN
  112. strNeedCD = MsgBox("This script will place a folder on your desktop containing all necessary files needed to "&_
  113. "install ADO (ActiveX Data Objects) support under Windows PE."&vbCrLF&vbCrLF&"Please ensure that your "&_
  114. "Windows XP Professional CD or Windows XP Professional binaries are available now on: "&vbCrLF&CDSource&vbCrLF&vbCrLF&"This script is only designed to be used with Windows PE/Windows XP RC1 "&_
  115. "or newer.", 65, strJobTitle)
  116. END IF
  117. IF strNeedCD = 2 THEN
  118. WScript.Quit
  119. END IF
  120. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  121. '-----TEST VIA WMI TO INSURE MEDIA IS PRESENT AND READABLE
  122. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  123. IF iHaveSource = 0 THEN
  124. TestForMedia()
  125. END IF
  126. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  127. '-----TESTS FOR EXISTANCE OF SEVERAL KEY FILES, AND A FILE COUNT IN I386 or IA64 TO INSURE
  128. '-----WINDOWS XP PRO MEDIA
  129. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  130. Validate(iArchDir)
  131. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  132. '-----FIND THE USER'S DESKTOP. PUT NEW FOLDER THERE. APPEND TIMESTAMP IF THE FOLDER
  133. '-----ALREADY EXISTS.
  134. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  135. strDesktop = WshShell.SpecialFolders("Desktop")
  136. strFolderName = "ADO Build Files ("&iArchDir&")"
  137. IF iHaveDest = 0 THEN
  138. strDestFolder = strDesktop&"\"&strFolderName
  139. IF FSO.FolderExists(strDestFolder) THEN
  140. GetUnique()
  141. strDestFolder = strDestFolder&strAppend
  142. strFolderName = strFolderName&strAppend
  143. END IF
  144. FSO.CreateFolder(strDestFolder)
  145. ELSE
  146. strDestFolder = strOptDest
  147. IF NOT FSO.FolderExists(strDestFolder) THEN
  148. FSO.CreateFolder(strDestFolder)
  149. END IF
  150. END IF
  151. IF iHaveDest = 1 THEN
  152. strIDir = strDestFolder&"\"&iArchDir
  153. strSysDir = strDestFolder&"\"&iArchDir&"\System32"
  154. FSO.CreateFolder(strDestFolder&"\Program Files")
  155. FSO.CreateFolder(strDestFolder&"\Program Files\Common Files")
  156. FSO.CreateFolder(strDestFolder&"\Program Files\Common Files\System")
  157. FSO.CreateFolder(strDestFolder&"\Program Files\Common Files\System\ado")
  158. FSO.CreateFolder(strDestFolder&"\Program Files\Common Files\System\msadc")
  159. FSO.CreateFolder(strDestFolder&"\Program Files\Common Files\System\Ole db")
  160. FSO.CreateFolder(strIDir&"\Registration")
  161. strCMDado = """ """&strDestFolder&"\Program Files\Common Files\System\ado\"
  162. strCMDmsadc = """ """&strDestFolder&"\Program Files\Common Files\System\msadc\"
  163. strCMDOle_db = """ """&strDestFolder&"\Program Files\Common Files\System\Ole db\"
  164. strDestFolder = strSysDir
  165. IF FSO.FileExists(strDestFolder&"\autoexec.cmd") THEN
  166. SET FILE = FSO.OpenTextFile(strDestFolder&"\autoexec.cmd", ForAppending, true)
  167. FILE.WriteLine("call ADO.bat")
  168. FILE.Close()
  169. END IF
  170. ELSE
  171. FSO.CreateFolder(strDestFolder&"\Program Files")
  172. FSO.CreateFolder(strDestFolder&"\Program Files\Common Files")
  173. FSO.CreateFolder(strDestFolder&"\Program Files\Common Files\System")
  174. FSO.CreateFolder(strDestFolder&"\Program Files\Common Files\System\ado")
  175. FSO.CreateFolder(strDestFolder&"\Program Files\Common Files\System\msadc")
  176. FSO.CreateFolder(strDestFolder&"\Program Files\Common Files\System\Ole db")
  177. FSO.CreateFolder(strDestFolder&"\Registration")
  178. strCMDado = """ """&strDestFolder&"\Program Files\Common Files\System\ado\"
  179. strCMDmsadc = """ """&strDestFolder&"\Program Files\Common Files\System\msadc\"
  180. strCMDOle_db = """ """&strDestFolder&"\Program Files\Common Files\System\Ole db\"
  181. END IF
  182. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  183. '-----SET COMMON VARIABLES SO THE STRINGS AREN'T SO LARGE
  184. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  185. strCMDExpand = "EXPAND """&CDSource&"\"&iArchDir&"\"
  186. strCMDMid = """ """&strDestFolder&"\"
  187. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  188. '-----SHELL OUT THE EXPANSION OF core ADO Files. (EXE, TLB, DLL, OCX)
  189. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  190. WshShell.Run strCMDExpand&"msado20.tl_"&strCMDado&"msado20.tlb""", 0, FALSE
  191. WshShell.Run strCMDExpand&"msado21.tl_"&strCMDado&"msado21.tlb""", 0, FALSE
  192. WshShell.Run strCMDExpand&"msado25.tl_"&strCMDado&"msado25.tlb""", 0, FALSE
  193. WshShell.Run strCMDExpand&"msjro.dl_"&strCMDado&"msjro.dll""", 0, FALSE
  194. WshShell.Run strCMDExpand&"msado26.tl_"&strCMDado&"msado26.tlb""", 0, FALSE
  195. WshShell.Run strCMDExpand&"msader15.dl_"&strCMDado&"msader15.dll""", 0, FALSE
  196. WshShell.Run strCMDExpand&"msado15.dl_"&strCMDado&"msado15.dll""", 0, FALSE
  197. WshShell.Run strCMDExpand&"msadomd.dl_"&strCMDado&"msadomd.dll""", 0, FALSE
  198. WshShell.Run strCMDExpand&"msador15.dl_"&strCMDado&"msador15.dll""", 0, FALSE
  199. WshShell.Run strCMDExpand&"msadoX.dl_"&strCMDado&"msadoX.dll""", 0, FALSE
  200. WshShell.Run strCMDExpand&"msadrh15.dl_"&strCMDado&"msadrh15.dll""", 0, FALSE
  201. WshShell.Run strCMDExpand&"msadce.dl_"&strCMDmsadc&"msadce.dll""", 0, FALSE
  202. WshShell.Run strCMDExpand&"msadcer.dl_"&strCMDmsadc&"msadcer.dll""", 0, FALSE
  203. WshShell.Run strCMDExpand&"msadcf.dl_"&strCMDmsadc&"msadcf.dll""", 0, FALSE
  204. WshShell.Run strCMDExpand&"msadcfr.dl_"&strCMDmsadc&"msadcfr.dll""", 0, FALSE
  205. WshShell.Run strCMDExpand&"msadco.dl_"&strCMDmsadc&"msadco.dll""", 0, FALSE
  206. WshShell.Run strCMDExpand&"msadcor.dl_"&strCMDmsadc&"msadcor.dll""", 0, FALSE
  207. WshShell.Run strCMDExpand&"msadcs.dl_"&strCMDmsadc&"msadcs.dll""", 0, FALSE
  208. WshShell.Run strCMDExpand&"msadds.dl_"&strCMDmsadc&"msadds.dll""", 0, FALSE
  209. WshShell.Run strCMDExpand&"msaddsr.dl_"&strCMDmsadc&"msaddsr.dll""", 0, FALSE
  210. WshShell.Run strCMDExpand&"msdarem.dl_"&strCMDmsadc&"msdarem.dll""", 0, FALSE
  211. WshShell.Run strCMDExpand&"msdaremr.dl_"&strCMDmsadc&"msdaremr.dll""", 0, FALSE
  212. WshShell.Run strCMDExpand&"msdfmap.dl_"&strCMDmsadc&"msdfmap.dll""", 0, FALSE
  213. WshShell.Run strCMDExpand&"sqloledb.rl_"&strCMDOle_db&"sqloledb.rll""", 0, FALSE
  214. WshShell.Run strCMDExpand&"sqlxmlx.rl_"&strCMDOle_db&"sqlxmlx.rll""", 0, FALSE
  215. WshShell.Run strCMDExpand&"msdadc.dl_"&strCMDOle_db&"msdadc.dll""", 0, FALSE
  216. WshShell.Run strCMDExpand&"msdaenum.dl_"&strCMDOle_db&"msdaenum.dll""", 0, FALSE
  217. WshShell.Run strCMDExpand&"msdaer.dl_"&strCMDOle_db&"msdaer.dll""", 0, FALSE
  218. WshShell.Run strCMDExpand&"msdaora.dl_"&strCMDOle_db&"msdaora.dll""", 0, FALSE
  219. WshShell.Run strCMDExpand&"msdaorar.dl_"&strCMDOle_db&"msdaorar.dll""", 0, FALSE
  220. WshShell.Run strCMDExpand&"msdaosp.dl_"&strCMDOle_db&"msdaosp.dll""", 0, FALSE
  221. WshShell.Run strCMDExpand&"msdasc.dl_"&strCMDOle_db&"msdasc.dll""", 0, FALSE
  222. WshShell.Run strCMDExpand&"msdasql.dl_"&strCMDOle_db&"msdasql.dll""", 0, FALSE
  223. WshShell.Run strCMDExpand&"msdasqlr.dl_"&strCMDOle_db&"msdasqlr.dll""", 0, FALSE
  224. WshShell.Run strCMDExpand&"msdatl3.dl_"&strCMDOle_db&"msdatl3.dll""", 0, FALSE
  225. WshShell.Run strCMDExpand&"msdatt.dl_"&strCMDOle_db&"msdatt.dll""", 0, FALSE
  226. WshShell.Run strCMDExpand&"msdaurl.dl_"&strCMDOle_db&"msdaurl.dll""", 0, FALSE
  227. WshShell.Run strCMDExpand&"msxactps.dl_"&strCMDOle_db&"msxactps.dll""", 0, FALSE
  228. WshShell.Run strCMDExpand&"oledb32.dl_"&strCMDOle_db&"oledb32.dll""", 0, FALSE
  229. WshShell.Run strCMDExpand&"oledb32r.dl_"&strCMDOle_db&"oledb32r.dll""", 0, FALSE
  230. WshShell.Run strCMDExpand&"sqloledb.dl_"&strCMDOle_db&"sqloledb.dll""", 0, FALSE
  231. WshShell.Run strCMDExpand&"sqlxmlx.dl_"&strCMDOle_db&"sqlxmlx.dll""", 0, FALSE
  232. WshShell.Run strCMDExpand&"msdatsrc.tl_"&strCMDMid&"msdatsrc.tlb""", 0, FALSE
  233. WshShell.Run strCMDExpand&"cliconfg.ex_"&strCMDMid&"cliconfg.exe""", 0, FALSE
  234. WshShell.Run strCMDExpand&"cliconfg.rl_"&strCMDMid&"cliconfg.rll""", 0, FALSE
  235. WshShell.Run strCMDExpand&"sqlsrv32.rl_"&strCMDMid&"sqlsrv32.rll""", 0, FALSE
  236. WshShell.Run strCMDExpand&"cliconfg.dl_"&strCMDMid&"cliconfg.dll""", 0, FALSE
  237. WshShell.Run strCMDExpand&"dbmsadsn.dl_"&strCMDMid&"dbmsadsn.dll""", 0, FALSE
  238. WshShell.Run strCMDExpand&"dbmsrpcn.dl_"&strCMDMid&"dbmsrpcn.dll""", 0, FALSE
  239. WshShell.Run strCMDExpand&"dbnetlib.dl_"&strCMDMid&"dbnetlib.dll""", 0, FALSE
  240. WshShell.Run strCMDExpand&"dbnmpntw.dl_"&strCMDMid&"dbnmpntw.dll""", 0, FALSE
  241. WshShell.Run strCMDExpand&"ds32gt.dl_"&strCMDMid&"ds32gt.dll""", 0, FALSE
  242. WshShell.Run strCMDExpand&"mscpx32r.dl_"&strCMDMid&"mscpx32r.dll""", 0, FALSE
  243. WshShell.Run strCMDExpand&"mscpxl32.dl_"&strCMDMid&"mscpxl32.dll""", 0, FALSE
  244. WshShell.Run strCMDExpand&"msdart.dl_"&strCMDMid&"msdart.dll""", 0, FALSE
  245. WshShell.Run strCMDExpand&"msorc32r.dl_"&strCMDMid&"msorc32r.dll""", 0, FALSE
  246. WshShell.Run strCMDExpand&"msorcl32.dl_"&strCMDMid&"msorcl32.dll""", 0, FALSE
  247. WshShell.Run strCMDExpand&"odbcbcp.dl_"&strCMDMid&"odbcbcp.dll""", 0, FALSE
  248. WshShell.Run strCMDExpand&"sqlsrv32.dl_"&strCMDMid&"sqlsrv32.dll""", 0, FALSE
  249. WshShell.Run strCMDExpand&"sqlunirl.dl_"&strCMDMid&"sqlunirl.dll""", 0, FALSE
  250. WshShell.Run strCMDExpand&"12520437.cp_"&strCMDMid&"12520437.cpx""", 0, FALSE
  251. WshShell.Run strCMDExpand&"12520850.cp_"&strCMDMid&"12520850.cpx""", 0, FALSE
  252. WshShell.Run strCMDExpand&"ds16gt.dl_"&strCMDMid&"ds16gt.dll""", 0, FALSE
  253. WshShell.Run strCMDExpand&"instcat.sq_"&strCMDMid&"instcat.sql""", 0, FALSE
  254. WshShell.Run strCMDExpand&"expsrv.dl_"&strCMDMid&"expsrv.dll""", 0, FALSE
  255. WshShell.Run strCMDExpand&"vbajet32.dl_"&strCMDMid&"vbajet32.dll""", 0, FALSE
  256. WshShell.Run strCMDExpand&"CLBCATQ.DL_"&strCMDMid&"CLBCATQ.DLL""", 0, FALSE
  257. WshShell.Run strCMDExpand&"colbact.DL_"&strCMDMid&"colbact.DLL""", 0, FALSE
  258. WshShell.Run strCMDExpand&"COMRes.dl_"&strCMDMid&"COMRes.dll""", 0, FALSE
  259. WshShell.Run strCMDExpand&"comsvcs.dl_"&strCMDMid&"comsvcs.dll""", 0, FALSE
  260. WshShell.Run strCMDExpand&"DBmsLPCn.dl_"&strCMDMid&"DBmsLPCn.dll""", 0, FALSE
  261. WshShell.Run strCMDExpand&"MSCTF.dl_"&strCMDMid&"MSCTF.dll""", 0, FALSE
  262. WshShell.Run strCMDExpand&"mslbui.dl_"&strCMDMid&"mslbui.dll""", 0, FALSE
  263. WshShell.Run strCMDExpand&"MTXCLU.DL_"&strCMDMid&"MTXCLU.DLL""", 0, FALSE
  264. WshShell.Run strCMDExpand&"RESUTILS.DL_"&strCMDMid&"RESUTILS.DLL""", 0, FALSE
  265. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  266. '-----CREATE THE SAMPLE ADO/WSH SCRIPT .
  267. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  268. SET FILE = fso.CreateTextFile(strDestFolder&"\testado.vbs", True)
  269. FILE.WriteLine ("set objDBConnection = Wscript.CreateObject(""ADODB.Connection"")")
  270. FILE.WriteLine ("set RS = Wscript.CreateObject(""ADODB.Recordset"")")
  271. FILE.WriteLine ("")
  272. FILE.WriteLine ("SERVER = InputBox(""Enter the name of the SQL Server (SQL 7.0 or SQL 2000) you wish to connect to""&vbcrlf&vbcrlf&""This SQL Server must have the Northwind sample database installed."", ""Connect to SQL Server..."")")
  273. FILE.WriteLine ("IF LEN(TRIM(SERVER)) = 0 THEN")
  274. FILE.WriteLine (" MsgBox ""You did not enter the name of a machine to query. Exiting script."", vbCritical, ""No machine requested.""")
  275. FILE.WriteLine (" WScript.Quit")
  276. FILE.WriteLine ("END IF")
  277. FILE.WriteLine ("")
  278. FILE.WriteLine ("USERNAME = InputBox(""Enter the name of the SQL Server username to query with"", ""Enter SQL username..."")")
  279. FILE.WriteLine ("IF LEN(TRIM(USERNAME)) = 0 THEN")
  280. FILE.WriteLine (" MsgBox ""You did not enter the SQL Server username to query with. Exiting script."", vbCritical, ""No username specified.""")
  281. FILE.WriteLine (" WScript.Quit")
  282. FILE.WriteLine ("END IF")
  283. FILE.WriteLine ("")
  284. FILE.WriteLine ("PWD = InputBox(""Enter the password of the SQL Server you wish to connect to""&vbcrlf&vbcrlf&""Leave blank if no password is needed."", ""Enter SQL password..."")")
  285. FILE.WriteLine ("")
  286. FILE.WriteLine ("")
  287. FILE.WriteLine ("SQLQuery1 =""SELECT Employees.FirstName AS FirstName, Employees.City AS City FROM Employees WHERE Employees.Lastname = 'Suyama'""")
  288. FILE.WriteLine ("objDBConnection.open ""Provider=SQLOLEDB;Data Source=""&SERVER&"";Initial Catalog=Northwind;User ID=""&USERNAME&"";Password=""&PWD&"";""")
  289. FILE.WriteLine ("")
  290. FILE.WriteLine ("Set GetRS = objDBConnection.Execute(SQLQuery1)")
  291. FILE.WriteLine ("")
  292. FILE.WriteLine ("IF GetRS.EOF THEN")
  293. FILE.WriteLine (" MsgBox ""No employees were found with the last name you searched on!""")
  294. FILE.WriteLine ("ELSE")
  295. FILE.WriteLine (" Do While Not GetRS.EOF")
  296. FILE.WriteLine (" MsgBox ""There is an employee in ""&GetRS(""City"")&"" named ""&GetRS(""FirstName"")&"" with the last name you searched on.""")
  297. FILE.WriteLine (" GetRS.MoveNext")
  298. FILE.WriteLine (" Loop")
  299. FILE.WriteLine ("END IF")
  300. FILE.Close
  301. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  302. '-----CREATE the BATS THAT WILL INSTALL THE ADO ENVIRONMENT.
  303. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  304. SET FILE = fso.CreateTextFile(strDestFolder&"\ADO.bat", True)
  305. FILE.WriteLine ("@ECHO OFF")
  306. FILE.WriteLine ("START ""Installing ADO"" /MIN ADO2.bat")
  307. FILE.Close
  308. SET FILE = fso.CreateTextFile(strDestFolder&"\ADO2.bat", True)
  309. FILE.WriteLine ("")
  310. FILE.WriteLine ("REM - INSTALL ADO COMPONENTS")
  311. FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\msadc\msadce.dll"" /S")
  312. FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\msadc\msadcf.dll"" /S")
  313. FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\msadc\msadco.dll"" /S")
  314. FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\msadc\msadds.dll"" /S")
  315. FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\ado\msado15.dll"" /S")
  316. FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\ado\msadomd.dll"" /S")
  317. FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\ado\msador15.dll"" /S")
  318. FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\ado\msadoX.dll"" /S")
  319. FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\ado\msadrh15.dll"" /S")
  320. FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\Ole DB\msdadc.dll"" /S")
  321. FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\Ole DB\msdaenum.dll"" /S")
  322. FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\Ole DB\msdaer.dll"" /S")
  323. FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\Ole DB\msdaora.dll"" /S")
  324. FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\Ole DB\msdaosp.dll"" /S")
  325. FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\msadc\msdarem.dll"" /S")
  326. FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\Ole DB\msdasc.dll"" /S")
  327. FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\Ole DB\msdasql.dll"" /S")
  328. FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\Ole DB\msdatt.dll"" /S")
  329. FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\Ole DB\msdaurl.dll"" /S")
  330. FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\msadc\msdfmap.dll"" /S")
  331. FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\ado\msjro.dll"" /S")
  332. FILE.WriteLine ("regsvr32 %SystemRoot%\System32\msorcl32.dll /S")
  333. FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\Ole DB\msxactps.dll"" /S")
  334. FILE.WriteLine ("regsvr32 %SystemRoot%\System32\odbcconf.dll /S")
  335. FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\Ole DB\oledb32.dll"" /S")
  336. FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\Ole DB\oledb32r.dll"" /S")
  337. FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\Ole DB\sqloledb.dll"" /S")
  338. FILE.WriteLine ("regsvr32 %SystemDrive%""\Program Files\Common Files\System\Ole DB\sqlxmlx.dll"" /S")
  339. FILE.WriteLine ("regsvr32 %SystemRoot%\System32\CLBCATQ.DLL /S")
  340. FILE.WriteLine ("regsvr32 %SystemRoot%\system32\colbact.DLL /S")
  341. FILE.WriteLine ("regsvr32 %SystemRoot%\system32\comsvcs.dll /S")
  342. FILE.WriteLine ("regsvr32 %SystemRoot%\System32\MSCTF.dll /S")
  343. FILE.WriteLine ("regsvr32 %SystemRoot%\System32\mslbui.dll /S")
  344. FILE.WriteLine ("regsvr32 %SystemRoot%\system32\ole32.dll /S")
  345. FILE.WriteLine ("EXIT")
  346. FILE.Close
  347. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  348. '-----FILES READY - ASK IF THE USER WANTS TO EXPLORE TO THEM.
  349. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  350. IF iAmQuiet = 0 THEN
  351. strWantToView = MsgBox("This script has successfully retrieved all necessary files needed to "&_
  352. "install ADO on Windows PE. The files have been placed on your desktop in a directory named """&strFolderName&"""."&vbCrLF&vbCrLF&_
  353. "In order to install the ADO components within Windows PE, place the contents of this folder (not the folder itself) into the I386\System32 or IA64\System32 directory "&_
  354. "of your Windows PE CD, Hard drive install, or RIS Server installation, and modify your startnet.cmd to run the file ""ADO.bat"" (without quotes)."&vbCrLF&vbCrLF&_
  355. "A sample script named test.vbs that you can use to verify installation has been provided as well. You can remove this for your production version of Windows PE."&vbCrLF&vbCrLF&_
  356. "Would you like to open this folder now?", 36, strJobTitle)
  357. END IF
  358. IF strWantToView = 6 OR iWillBrowse = 1 THEN
  359. WshShell.Run("Explorer "&strDestFolder)
  360. END IF
  361. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  362. '-----WMI TEST OF CD LOADED AND CD READ INTEGRITY.
  363. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  364. SUB TestForMedia()
  365. IF CDDrive.MediaLoaded(0) = FALSE THEN
  366. MsgBox "Please place the Windows XP Professional CD in drive "&CDSource&" before continuing.", vbCritical, "No CD in drive "&CDSource&""
  367. WScript.Quit
  368. ELSE
  369. IF CDDrive.DriveIntegrity(0) = FALSE THEN
  370. MsgBox "Could not read files from the CD in drive "&CDSource&".", vbCritical, "CD in drive "&CDSource&" is unreadable."
  371. WScript.Quit
  372. END IF
  373. END IF
  374. END SUB
  375. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  376. '-----FSO TEST TO SEE IF THE CMDLINE PROVIDED FOLDER EXISTS.
  377. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  378. FUNCTION TestForFolder(a)
  379. IF NOT FSO.FolderExists(a) THEN
  380. FailOut()
  381. END IF
  382. END FUNCTION
  383. SUB Validate(a)
  384. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  385. '-----TEST FOR THE EXISTANCE OF A FOLDER OR FILE, OR THE NONEXISTANCE OF A FILE.
  386. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  387. TestForFolder(CDSource&"\"&a&"")
  388. TestForFolder(CDSource&"\DOCS")
  389. TestForFolder(CDSource&"\SUPPORT")
  390. TestForFolder(CDSource&"\VALUEADD")
  391. TestForFile(CDSource&"\"&a&"\System32\smss.exe")
  392. TestForFile(CDSource&"\"&a&"\System32\ntdll.dll")
  393. TestForFile(CDSource&"\"&a&"\winnt32.exe")
  394. TestForFile(CDSource&"\setup.exe")
  395. TestForANDFile CDSource&"\WIN51.B2", CDSource&"\WIN51.RC1", CDSource&"\WIN51.RC1"
  396. TestForANDFile CDSource&"\WIN51IP.B2", CDSource&"\WIN51IP.RC1", CDSource&"\WIN51MP.RC1"
  397. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  398. '-----TEST TO INSURE THAT THEY AREN'T TRYING TO INSTALL FROM Windows PE CD ITSELF
  399. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  400. Set Folder = FSO.GetFolder(CDSource&"\"&a&"\System32")
  401. IF Folder.Files.Count > 10 THEN
  402. FailOut()
  403. END IF
  404. END SUB
  405. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  406. '-----TEST FOR THE EXISTANCE OF A FOLDER OR FILE, OR THE NONEXISTANCE OF A FILE.
  407. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  408. FUNCTION TestForFolder(a)
  409. IF NOT FSO.FolderExists(a) THEN
  410. FailOut()
  411. END IF
  412. END FUNCTION
  413. FUNCTION TestForFile(a)
  414. IF NOT FSO.FileExists(a) THEN
  415. FailOut()
  416. END IF
  417. END FUNCTION
  418. FUNCTION TestForANDFile(a,b,c)
  419. IF NOT FSO.FileExists(a) AND NOT FSO.FileExists(b) AND NOT FSO.FileExists(c) THEN
  420. FailOut()
  421. END IF
  422. END FUNCTION
  423. FUNCTION TestNoFile(a)
  424. IF FSO.FileExists(a) THEN
  425. FailOut()
  426. END IF
  427. END FUNCTION
  428. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  429. '-----GENERIC ERROR IF WE FAIL MEDIA RECOGNITION.
  430. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  431. SUB FailOut()
  432. MsgBox"The CD in drive "&CDSource&" does not appear to be a valid Windows XP Professional CD.", vbCritical, "Invalid CD in Drive "&CDSource
  433. WScript.Quit
  434. END SUB
  435. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  436. '-----ADD DATE, AND ADD ZEROS SO WE DON'T HAVE A GIBBERISH TIMESTAMP ON UNIQUE FOLDERNAME.
  437. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  438. SUB GetUnique()
  439. strAppend=FixUp(Hour(Now()))&FixUp(Minute(Now()))&FixUp(Second(Now()))
  440. IF Len(strAppend) = 5 THEN
  441. strAppend = strAppend&"0"
  442. ELSEIF Len(strAppend) = 4 THEN
  443. strAppend = strAppend&"00"
  444. END IF
  445. END SUB
  446. FUNCTION FixUp(a)
  447. If Len(a) = 1 THEN
  448. FixUp = 0&a
  449. ELSE
  450. Fixup = a
  451. END IF
  452. END FUNCTION
  453. FUNCTION CleanLocation(a)
  454. CleanLocation = REPLACE(a, """", "")
  455. END FUNCTION