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.

2355 lines
79 KiB

  1. #include "stdafx.h"
  2. #include <ole2.h>
  3. #include "log.h"
  4. #include <winnetwk.h>
  5. extern int g_GlobalDebugLevelFlag;
  6. extern int g_GlobalDebugLevelFlag_WasSetByUnattendFile;
  7. extern int g_CheckIfMetabaseValueWasWritten;
  8. extern MyLogFile g_MyLogFile;
  9. void Check_For_DebugServiceFlag(void)
  10. {
  11. INFCONTEXT Context;
  12. TSTR strSectionName( MAX_PATH );
  13. TSTR strEntry( MAX_PATH );
  14. // Do this only if unattended install
  15. if (!g_pTheApp->m_fUnattended)
  16. {
  17. return;
  18. }
  19. // The section name to look for in the unattended file
  20. if ( !strSectionName.Copy( UNATTEND_FILE_SECTION ) ||
  21. !strEntry.Copy( _T("") ) )
  22. {
  23. return;
  24. }
  25. //
  26. // Look for our special setting
  27. //
  28. if ( SetupFindFirstLine(g_pTheApp->m_hUnattendFile, strSectionName.QueryStr(), _T("DebugService"), &Context) )
  29. {
  30. SetupGetStringField(&Context, 1, strEntry.QueryStr(), strEntry.QuerySize(), NULL);
  31. if (0 == _tcsicmp(strEntry.QueryStr(), _T("1")) || 0 == _tcsicmp(strEntry.QueryStr(), _T("true")) )
  32. {
  33. SetupSetStringId_Wrapper(g_pTheApp->m_hInfHandle, 34101, strEntry.QueryStr());
  34. }
  35. }
  36. return;
  37. }
  38. void Check_For_DebugLevel(void)
  39. {
  40. INFCONTEXT Context;
  41. TSTR strSectionName( MAX_PATH );
  42. TSTR strEntry( MAX_PATH );
  43. // Do this only if unattended install
  44. if (!g_pTheApp->m_fUnattended)
  45. {
  46. return;
  47. }
  48. // The section name to look for in the unattended file
  49. if ( !strSectionName.Copy( UNATTEND_FILE_SECTION ) ||
  50. !strEntry.Copy( _T("") ) )
  51. {
  52. return;
  53. }
  54. //
  55. // Look for our special setting
  56. //
  57. if ( SetupFindFirstLine(g_pTheApp->m_hUnattendFile, strSectionName.QueryStr(), _T("DebugLevel"), &Context) )
  58. {
  59. SetupGetStringField(&Context, 1, strEntry.QueryStr(), strEntry.QuerySize(), NULL);
  60. if (IsValidNumber( strEntry.QueryStr() ))
  61. {
  62. g_GlobalDebugLevelFlag = _ttoi( strEntry.QueryStr() );
  63. g_GlobalDebugLevelFlag_WasSetByUnattendFile = TRUE;
  64. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("DebugLevel=%d."),g_GlobalDebugLevelFlag));
  65. }
  66. if (g_GlobalDebugLevelFlag >= LOG_TYPE_TRACE_WIN32_API )
  67. {
  68. g_CheckIfMetabaseValueWasWritten = TRUE;
  69. }
  70. }
  71. return;
  72. }
  73. void Check_Custom_IIS_INF(void)
  74. {
  75. INFCONTEXT Context;
  76. TSTR strSectionName( MAX_PATH );
  77. TSTR_PATH strFullPath( MAX_PATH );
  78. // Do this only if unattended install
  79. if (!g_pTheApp->m_fUnattended)
  80. {
  81. return;
  82. }
  83. // The section name to look for in the unattended file
  84. if ( !strSectionName.Copy( UNATTEND_FILE_SECTION ) )
  85. {
  86. return;
  87. }
  88. //
  89. // Look for our special setting
  90. //
  91. if ( SetupFindFirstLine(g_pTheApp->m_hUnattendFile, strSectionName.QueryStr(), _T("AlternateIISINF"), &Context) &&
  92. SetupGetStringField(&Context, 1, strFullPath.QueryStr(), strFullPath.QuerySize(), NULL) &&
  93. strFullPath.ExpandEnvironmentVariables()
  94. )
  95. {
  96. if (!IsFileExist( strFullPath.QueryStr() ))
  97. {
  98. iisDebugOut((LOG_TYPE_WARN, _T("Check_Custom_IIS_INF:AlternateIISINF=%s.Not Valid.ignoring unattend value. WARNING.\n"), strFullPath.QueryStr() ));
  99. return;
  100. }
  101. g_pTheApp->m_hInfHandleAlternate = SetupOpenInfFile( strFullPath.QueryStr(), NULL, INF_STYLE_WIN4, NULL);
  102. if ( !g_pTheApp->m_hInfHandleAlternate ||
  103. ( g_pTheApp->m_hInfHandleAlternate == INVALID_HANDLE_VALUE )
  104. )
  105. {
  106. iisDebugOut((LOG_TYPE_WARN, _T("Check_Custom_IIS_INF: SetupOpenInfFile failed on file: %s.\n"), strFullPath.QueryStr() ));
  107. return;
  108. }
  109. iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("Check_Custom_IIS_INF:AlternateIISINF=%s\n"), strFullPath.QueryStr() ));
  110. }
  111. }
  112. void Check_Custom_WWW_or_FTP_Path(void)
  113. {
  114. INFCONTEXT Context;
  115. TSTR strSectionName( MAX_PATH );
  116. TSTR_PATH strPath( MAX_PATH );
  117. // Do this only if unattended install
  118. if (!g_pTheApp->m_fUnattended)
  119. {
  120. return;
  121. }
  122. //iisDebugOut((LOG_TYPE_TRACE, _T("Check_Custom_WWW_or_FTP_Path:start\n")));
  123. // The section name to look for in the unattended file
  124. if ( !strSectionName.Copy( UNATTEND_FILE_SECTION ) )
  125. {
  126. return;
  127. }
  128. //
  129. // FTP
  130. //
  131. if ( SetupFindFirstLine_Wrapped(g_pTheApp->m_hUnattendFile, strSectionName.QueryStr(), _T("PathFTPRoot"), &Context) &&
  132. SetupGetStringField(&Context, 1, strPath.QueryStr(), strPath.QuerySize(), NULL) &&
  133. strPath.ExpandEnvironmentVariables() )
  134. {
  135. if (IsValidDirectoryName( strPath.QueryStr() ))
  136. {
  137. iisDebugOut((LOG_TYPE_TRACE, _T("Check_Custom_WWW_or_FTP_Path:Unattendfilepath:PathFTPRoot=%s\n"), strPath.QueryStr() ));
  138. CustomFTPRoot( strPath.QueryStr() );
  139. g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_PATH_FTP;
  140. }
  141. else
  142. {
  143. iisDebugOut((LOG_TYPE_WARN, _T("Check_Custom_WWW_or_FTP_Path:Unattendfilepath:PathFTPRoot=%s.Not Valid.ignoring unattend value. WARNING.\n"), strPath.QueryStr() ));
  144. }
  145. }
  146. //
  147. // WWW
  148. //
  149. if ( SetupFindFirstLine_Wrapped(g_pTheApp->m_hUnattendFile, strSectionName.QueryStr(), _T("PathWWWRoot"), &Context) &&
  150. SetupGetStringField(&Context, 1, strPath.QueryStr(), strPath.QuerySize(), NULL) &&
  151. strPath.ExpandEnvironmentVariables() )
  152. {
  153. if (IsValidDirectoryName( strPath.QueryStr() ))
  154. {
  155. iisDebugOut((LOG_TYPE_TRACE, _T("Check_Custom_WWW_or_FTP_Path:Unattendfilepath:PathFTPRoot=%s\n"), strPath.QueryStr() ));
  156. CustomWWWRoot( strPath.QueryStr() );
  157. g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_PATH_FTP;
  158. }
  159. else
  160. {
  161. iisDebugOut((LOG_TYPE_WARN, _T("Check_Custom_WWW_or_FTP_Path:Unattendfilepath:PathFTPRoot=%s.Not Valid.ignoring unattend value. WARNING.\n"), strPath.QueryStr() ));
  162. }
  163. }
  164. //iisDebugOut((LOG_TYPE_TRACE, _T("Check_Custom_WWW_or_FTP_Path:end\n")));
  165. return;
  166. }
  167. CInitApp::CInitApp()
  168. {
  169. m_err = 0;
  170. m_hInfHandle = NULL;
  171. m_hInfHandleAlternate = NULL;
  172. m_bAllowMessageBoxPopups = TRUE;
  173. m_bThereWereErrorsChkLogfile = FALSE;
  174. m_bThereWereErrorsFromMTS = FALSE;
  175. m_bWin95Migration = FALSE;
  176. m_bIISAdminWasDisabled = FALSE;
  177. // Product name and application name
  178. m_csAppName = _T("");
  179. m_csIISGroupName = _T("");
  180. // account + passwd for anonymous user
  181. m_csGuestName = _T("");
  182. m_csGuestPassword = _T("");
  183. m_csWAMAccountName = _T("");
  184. m_csWAMAccountPassword = _T("");
  185. m_csWWWAnonyName = _T("");
  186. m_csWWWAnonyPassword = _T("");
  187. m_csFTPAnonyName = _T("");
  188. m_csFTPAnonyPassword = _T("");
  189. dwUnattendConfig = 0;
  190. m_csWAMAccountName_Unattend = _T("");
  191. m_csWAMAccountPassword_Unattend = _T("");
  192. m_csWWWAnonyName_Unattend = _T("");
  193. m_csWWWAnonyPassword_Unattend = _T("");
  194. m_csFTPAnonyName_Unattend = _T("");
  195. m_csFTPAnonyPassword_Unattend = _T("");
  196. m_csWAMAccountName_Remove = _T("");
  197. m_csWWWAnonyName_Remove = _T("");
  198. m_csFTPAnonyName_Remove = _T("");
  199. // machine status
  200. m_csMachineName = _T("");
  201. m_csUsersDomain = _T("");
  202. m_csUsersAccount = _T("");
  203. m_fUninstallMapList_Dirty = FALSE;
  204. m_csWinDir = _T("");
  205. m_csSysDir = _T("");
  206. m_csSysDrive = _T("");
  207. m_csPathSource = _T("");
  208. m_csPathOldInetsrv = _T(""); // the primary destination used by previous iis/pws products
  209. m_csPathInetsrv = _T(""); // the primary destination defaults to m_csSysDir\inetsrv
  210. m_csPathInetpub = _T("");
  211. m_csPathFTPRoot = _T("");
  212. m_csPathWWWRoot = _T("");
  213. m_csPathWebPub = _T("");
  214. m_csPathProgramFiles = _T("");
  215. m_csPathIISSamples = _T("");
  216. m_csPathScripts = _T("");
  217. m_csPathASPSamp = _T("");
  218. m_csPathAdvWorks = _T("");
  219. m_csPathIASDocs = _T("");
  220. m_csPathOldPWSFiles = _T("");
  221. m_csPathOldPWSSystemFiles = _T("");
  222. m_dwOSServicePack = 0;
  223. m_eOS = OS_OTHERS; // OS_W95, OS_NT, OS_OTHERS
  224. m_fNT5 = FALSE;
  225. m_fW95 = FALSE; // TRUE if Win95 (build xxx) or greater
  226. m_eNTOSType = OT_NT_UNKNOWN; // OT_PDC, OT_SAM, OT_BDC, OT_NTS, OT_NTW
  227. m_csPlatform = _T("");
  228. m_fTCPIP = FALSE; // TRUE if TCP/IP is installed
  229. m_eUpgradeType = UT_NONE; // UT_NONE, UT_10, UT_20, etc.
  230. m_bUpgradeTypeHasMetabaseFlag = FALSE;
  231. m_eInstallMode = IM_FRESH; // IM_FRESH, IM_MAINTENANCE, IM_UPGRADE
  232. m_dwSetupMode = SETUPMODE_CUSTOM;
  233. m_bRefreshSettings = FALSE;
  234. m_bPleaseDoNotInstallByDefault = FALSE;
  235. m_fNTOperationFlags=0;
  236. m_fNTGuiMode=0;
  237. m_fNtWorkstation=0;
  238. m_fInvokedByNT = 0;
  239. m_fUnattended = FALSE;
  240. m_csUnattendFile = _T("");
  241. m_hUnattendFile = NULL;
  242. m_fEULA = FALSE;
  243. // TRUE if m_csPathOldInetsrv != m_csPathInetsrv, which means,
  244. // we need to migrate the old inetsrv to the new one that is system32\inetsrv.
  245. m_fMoveInetsrv = FALSE;
  246. m_csPathSrcDir = _T("");
  247. m_csMissingFile = _T("");
  248. m_csMissingFilePath = _T("");
  249. m_fWebDownload = FALSE;
  250. }
  251. CInitApp::~CInitApp()
  252. {
  253. }
  254. // function: IsUpgrade
  255. //
  256. // Return whether this is an upgrade or not
  257. //
  258. BOOL
  259. CInitApp::IsUpgrade()
  260. {
  261. return ( m_eUpgradeType != UT_NONE );
  262. }
  263. // function: GetUpgradeVersion
  264. //
  265. // Return the version that we are upgrading from
  266. //
  267. DWORD
  268. CInitApp::GetUpgradeVersion()
  269. {
  270. DWORD dwVer = 0;
  271. if ( !IsUpgrade() )
  272. {
  273. // This is not an upgrade, so return 0
  274. return 0;
  275. }
  276. switch ( m_eUpgradeType )
  277. {
  278. case UT_351:
  279. case UT_10_W95:
  280. case UT_10:
  281. return 1;
  282. break;
  283. case UT_20:
  284. dwVer = 2;
  285. break;
  286. case UT_30:
  287. dwVer = 3;
  288. break;
  289. case UT_40:
  290. dwVer = 4;
  291. break;
  292. case UT_50:
  293. case UT_51:
  294. dwVer = 5;
  295. break;
  296. case UT_60:
  297. dwVer = 6;
  298. break;
  299. case UT_NONE:
  300. default:
  301. dwVer = 0;
  302. }
  303. return dwVer;
  304. }
  305. // The one and only CInitApp object <Global variable>
  306. // --------------------------------------------------
  307. BOOL CInitApp::GetMachineName()
  308. {
  309. TCHAR buf[ CNLEN + 10 ];
  310. DWORD dwLen = CNLEN + 10;
  311. m_csMachineName = _T("");
  312. // Get computername
  313. if ( GetComputerName( buf, &dwLen ))
  314. {
  315. if ( buf[0] != _T('\\') )
  316. {
  317. m_csMachineName = _T("\\");
  318. m_csMachineName += _T("\\");
  319. }
  320. m_csMachineName += buf;
  321. }
  322. else
  323. {
  324. m_err = IDS_CANNOT_GET_MACHINE_NAME;
  325. }
  326. return ( !(m_csMachineName.IsEmpty()) );
  327. }
  328. // Return TRUE, if NT or Win95
  329. // --------------------------------------------------
  330. BOOL CInitApp::GetOS()
  331. {
  332. OSVERSIONINFO VerInfo;
  333. VerInfo.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
  334. GetVersionEx( &VerInfo );
  335. switch (VerInfo.dwPlatformId)
  336. {
  337. case VER_PLATFORM_WIN32_NT:
  338. m_eOS = OS_NT;
  339. break;
  340. case VER_PLATFORM_WIN32_WINDOWS:
  341. m_eOS = OS_W95;
  342. break;
  343. default:
  344. m_eOS = OS_OTHERS;
  345. break;
  346. }
  347. if ( m_eOS == OS_OTHERS ) {m_err = IDS_OS_NOT_SUPPORT;}
  348. return (m_eOS != OS_OTHERS);
  349. }
  350. // Support NT 4.0 (SP3) or greater
  351. // --------------------------------------------------
  352. BOOL CInitApp::GetOSVersion()
  353. /*++
  354. Routine Description:
  355. This function detects OS version. NT5 or greater is required to run this setup.
  356. Arguments:
  357. None
  358. Return Value:
  359. BOOL
  360. return FALSE, if we fails to detect the OS version,
  361. or it is a NT version which is smaller than v5.0
  362. --*/
  363. {
  364. BOOL fReturn = FALSE;
  365. if ( m_eOS == OS_NT )
  366. {
  367. OSVERSIONINFO vInfo;
  368. vInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  369. if ( GetVersionEx(&vInfo) )
  370. {
  371. // NT5 or greater is required.
  372. if ( vInfo.dwMajorVersion < 5 )
  373. {
  374. m_err = IDS_NT5_NEEDED;
  375. return FALSE;
  376. }
  377. // Start allowing NT 6 for Longhorn builds
  378. if ( ( vInfo.dwMajorVersion == 5 ) ||
  379. ( vInfo.dwMajorVersion == 6 ) )
  380. {
  381. m_fNT5 = TRUE;
  382. fReturn = TRUE;
  383. }
  384. }
  385. }
  386. // this line may be used for win98
  387. if (m_eOS == OS_W95)
  388. {
  389. fReturn = TRUE;
  390. }
  391. if ( !fReturn )
  392. {
  393. m_err = IDS_OS_VERSION_NOT_SUPPORTED;
  394. }
  395. return (fReturn);
  396. }
  397. // find out it's a NTS, PDC, BDC, NTW, SAM(PDC)
  398. // --------------------------------------------------
  399. BOOL CInitApp::GetOSType()
  400. {
  401. BOOL fReturn = TRUE;
  402. if ( m_eOS == OS_NT )
  403. {
  404. // If we are in NT guimode setup
  405. // then the registry key stuff is not yet setup
  406. // use the passed in ocmanage.dll stuff to determine
  407. // what we are installing upon.
  408. if (g_pTheApp->m_fNTGuiMode)
  409. {
  410. if (g_pTheApp->m_fNtWorkstation) {m_eNTOSType = OT_NTW;}
  411. else {m_eNTOSType = OT_NTS;}
  412. }
  413. else
  414. {
  415. m_eNTOSType = OT_NTS; // default to stand-alone NTS
  416. CRegKey regProductPath( HKEY_LOCAL_MACHINE, REG_PRODUCTOPTIONS, KEY_READ);
  417. if ( (HKEY)regProductPath )
  418. {
  419. CString strProductType;
  420. LONG lReturnedErrCode = regProductPath.QueryValue( _T("ProductType"), strProductType );
  421. if (lReturnedErrCode == ERROR_SUCCESS)
  422. {
  423. strProductType.MakeUpper();
  424. // ToDo: Sam ?
  425. if (strProductType == _T("WINNT"))
  426. {
  427. m_eNTOSType = OT_NTW;
  428. }
  429. else if (strProductType == _T("SERVERNT"))
  430. {
  431. m_eNTOSType = OT_NTS;
  432. }
  433. else if (strProductType == _T("LANMANNT"))
  434. {
  435. m_eNTOSType = OT_PDC_OR_BDC;
  436. }
  437. else
  438. {
  439. iisDebugOutSafeParams((LOG_TYPE_ERROR, _T("ProductType=%1!s! (UnKnown). FAILER to detect ProductType\n"), strProductType));
  440. fReturn = FALSE;
  441. }
  442. }
  443. else
  444. {
  445. // Shoot, we can't get the registry key,
  446. // let's try using the ocmanage.dll passed in stuff.
  447. if (g_pTheApp->m_fNTGuiMode)
  448. {
  449. if (g_pTheApp->m_fNtWorkstation) {m_eNTOSType = OT_NTW;}
  450. else {m_eNTOSType = OT_NTS;}
  451. }
  452. else
  453. {
  454. GetErrorMsg(lReturnedErrCode, REG_PRODUCTOPTIONS);
  455. m_eNTOSType = OT_NTS; // default to stand-alone NTS
  456. }
  457. }
  458. }
  459. else
  460. {
  461. // Shoot, we can't get the registry key,
  462. // let's try using the ocmanage.dll passed in stuff.
  463. if (g_pTheApp->m_fNTGuiMode)
  464. {
  465. if (g_pTheApp->m_fNtWorkstation) {m_eNTOSType = OT_NTW;}
  466. else {m_eNTOSType = OT_NTS;}
  467. }
  468. else
  469. {
  470. GetErrorMsg(ERROR_CANTOPEN, REG_PRODUCTOPTIONS);
  471. }
  472. }
  473. }
  474. }
  475. if ( !fReturn )
  476. m_err = IDS_CANNOT_DETECT_OS_TYPE;
  477. return(fReturn);
  478. }
  479. // Get WinDir and SysDir of the machine
  480. // WinDir = C:\winnt SysDir = C:\Winnt\system32
  481. // --------------------------------------------------
  482. BOOL CInitApp::GetSysDirs()
  483. {
  484. BOOL fReturn = TRUE;
  485. TCHAR buf[_MAX_PATH];
  486. m_csWinDir = _T("");
  487. m_csSysDir = _T("");
  488. if ( !GetWindowsDirectory( buf, _MAX_PATH ) )
  489. {
  490. return FALSE;
  491. }
  492. m_csWinDir = buf;
  493. if ( !GetSystemDirectory( buf, _MAX_PATH ) )
  494. {
  495. return FALSE;
  496. }
  497. m_csSysDir = buf;
  498. if ( _tcslen( buf ) <= 2 )
  499. {
  500. return FALSE;
  501. }
  502. buf[2] = _T('\0'); // now buf contains the system drive letter
  503. m_csSysDrive = buf;
  504. return fReturn;
  505. }
  506. BOOL CInitApp::IsTCPIPInstalled()
  507. /*++
  508. Routine Description:
  509. This function detects whether TCP/IP is installed,
  510. and set m_fTCPIP appropriately.
  511. Arguments:
  512. None
  513. Return Value:
  514. BOOL
  515. set m_fTCPIP appropriately, and always return TRUE here.
  516. m_fTCPIP will be used later.
  517. --*/
  518. {
  519. // NT 5.0 STUFF
  520. m_fTCPIP = TCPIP_Check_Temp_Hack();
  521. return TRUE;
  522. }
  523. BOOL CInitApp::SetInstallMode()
  524. {
  525. BOOL fReturn = TRUE;
  526. int iTempInstallFreshNT = TRUE;
  527. m_eInstallMode = IM_FRESH;
  528. m_eUpgradeType = UT_NONE;
  529. m_bUpgradeTypeHasMetabaseFlag = FALSE;
  530. // -----------------------------------
  531. // Get the install mode from NT setup (g_pTheApp->m_fNTUpgrade_Mode)
  532. // Can either be:
  533. // 1. SETUPMODE_FRESH. user clicked on fresh option and wants to install NT5 fresh
  534. // a. install iis fresh. do not attempt to upgrade the old iis stuff.
  535. // 2. SETUPMODE_UPGRADE. user clicked on upgrade option and wants to upgrade to NT5
  536. // a. upgrade any iis installations
  537. // b. if no old iis detected, then do not install iis
  538. // 3. SETUPMODE_MAINTENANCE. user is running setup from the control panel add/remove.
  539. // -----------------------------------
  540. if (!m_fInvokedByNT)
  541. {
  542. // if we are not guimode or in add/remove
  543. // then we must be running standalone.
  544. // if we are running standalone, then everything is
  545. // either fresh or maintenance.
  546. m_eInstallMode = IM_FRESH;
  547. m_eUpgradeType = UT_NONE;
  548. if (TRUE == AreWeCurrentlyInstalled())
  549. {
  550. m_eInstallMode = IM_MAINTENANCE;
  551. m_eUpgradeType = UT_NONE;
  552. m_bUpgradeTypeHasMetabaseFlag = TRUE;
  553. }
  554. else
  555. {
  556. CRegKey regINetStp( HKEY_LOCAL_MACHINE, REG_INETSTP, KEY_READ);
  557. if ((HKEY) regINetStp)
  558. {
  559. // This must be an upgrade....
  560. if (SetUpgradeType() == TRUE)
  561. {
  562. iisDebugOut((LOG_TYPE_TRACE, _T("SetInstallMode=SETUPMODE_UPGRADE.Upgrading.\n")));
  563. }
  564. else
  565. {
  566. iisDebugOut((LOG_TYPE_TRACE, _T("SetInstallMode=SETUPMODE_UPGRADE.NothingToUpgrade.\n")));
  567. }
  568. }
  569. }
  570. goto SetInstallMode_Exit;
  571. }
  572. // --------------------------------
  573. // Check if we are in the ADD/REMOVE mode...
  574. // --------------------------------
  575. if (g_pTheApp->m_fNTOperationFlags & SETUPOP_STANDALONE)
  576. {
  577. //
  578. // We are in add remove...
  579. //
  580. iisDebugOut((LOG_TYPE_TRACE, _T("SetInstallMode=IM_MAINTENANCE\n")));
  581. m_eInstallMode = IM_MAINTENANCE;
  582. m_eUpgradeType = UT_NONE;
  583. m_bUpgradeTypeHasMetabaseFlag = FALSE;
  584. goto SetInstallMode_Exit;
  585. }
  586. // --------------------------------
  587. //
  588. // FRESH IIS install
  589. //
  590. // if we are not in NT upgrade
  591. // then set everything to do a fresh!
  592. //
  593. // --------------------------------
  594. iTempInstallFreshNT = TRUE;
  595. if (g_pTheApp->m_fNTOperationFlags & SETUPOP_WIN31UPGRADE){iTempInstallFreshNT = FALSE;}
  596. if (g_pTheApp->m_fNTOperationFlags & SETUPOP_WIN95UPGRADE){iTempInstallFreshNT = FALSE;}
  597. if (g_pTheApp->m_fNTOperationFlags & SETUPOP_NTUPGRADE){iTempInstallFreshNT = FALSE;}
  598. if (iTempInstallFreshNT)
  599. {
  600. iisDebugOut((LOG_TYPE_TRACE, _T("SetInstallMode=IM_FRESH\n")));
  601. m_eInstallMode = IM_FRESH;
  602. m_eUpgradeType = UT_NONE;
  603. m_bUpgradeTypeHasMetabaseFlag = FALSE;
  604. goto SetInstallMode_Exit;
  605. }
  606. // --------------------------------
  607. //
  608. // UPGRADE iis install
  609. //
  610. // if we get here then the user checked the "upgrade" button and
  611. // is trying to upgrade from an earlier WIN95/NT351/NT4/NT5 installation.
  612. //
  613. // --------------------------------
  614. //
  615. // Set Upgrade ONLY if there are iis components to upgrade!
  616. // do not install if there is nothing to upgrade
  617. ProcessSection(g_pTheApp->m_hInfHandle, _T("Set_Upgrade_Type_chk"));
  618. // if we processed the upgrade section from the inf and
  619. // we are still in a fresh install, then call this other
  620. // function to make sure we catch known iis upgrade types.
  621. if (g_pTheApp->m_eUpgradeType == UT_NONE)
  622. {SetUpgradeType();}
  623. SetInstallMode_Exit:
  624. if (m_fInvokedByNT){DefineSetupModeOnNT();}
  625. return fReturn;
  626. }
  627. void CInitApp::DefineSetupModeOnNT()
  628. /*++
  629. Routine Description:
  630. This function defines IIS setup mode when invoked by NT5.
  631. NOTE:
  632. Since IIS setup does not run as a standalone program on NT5,
  633. user won't see buttons like Minimum, Typical, Custom,
  634. AddRemove, Reinstall, RemoveAll, UpgradeOnly, UpgradePlus
  635. any more. Hence, we have a totally different way to decide
  636. what mode the setup is running in.
  637. Arguments:
  638. none
  639. Return Value:
  640. set m_dwSetupMode appropriately.
  641. --*/
  642. {
  643. if (m_fInvokedByNT) {
  644. switch (m_eInstallMode) {
  645. case IM_FRESH:
  646. m_dwSetupMode = SETUPMODE_CUSTOM;
  647. break;
  648. case IM_MAINTENANCE:
  649. if (m_fNTGuiMode) {
  650. // invoked in NT GUI mode setup
  651. // treat minor os upgrade like a reinstall
  652. m_dwSetupMode = SETUPMODE_REINSTALL;
  653. m_bRefreshSettings = TRUE;
  654. } else {
  655. // invoked by ControlPanel\AddRemoveApplet
  656. m_dwSetupMode = SETUPMODE_ADDREMOVE;
  657. }
  658. break;
  659. case IM_UPGRADE:
  660. m_dwSetupMode = SETUPMODE_ADDEXTRACOMPS;
  661. break;
  662. default:
  663. break;
  664. }
  665. }
  666. return;
  667. }
  668. void GetVRootValue( CString strRegPath, CString csName, LPTSTR szRegName, CString &csRegValue)
  669. {
  670. CString csRegName;
  671. strRegPath +=_T("\\Parameters\\Virtual Roots");
  672. CRegKey regVR( HKEY_LOCAL_MACHINE, strRegPath, KEY_READ);
  673. csRegName = szRegName;
  674. if ( (HKEY) regVR )
  675. {
  676. regVR.m_iDisplayWarnings = FALSE;
  677. csRegName = csName;
  678. if ( regVR.QueryValue( csName, csRegValue ) != ERROR_SUCCESS )
  679. {
  680. csName += _T(",");
  681. if ( regVR.QueryValue(csName, csRegValue) != ERROR_SUCCESS )
  682. {
  683. // well, we need to scan all the keys
  684. CRegValueIter regEnum( regVR );
  685. CString strName;
  686. DWORD dwType;
  687. int nLen = csName.GetLength();
  688. while ( regEnum.Next( &strName, &dwType ) == ERROR_SUCCESS )
  689. {
  690. CString strLeft = strName.Left(nLen);
  691. if ( strLeft.CompareNoCase(csName) == 0)
  692. {
  693. csRegName = strName;
  694. regVR.QueryValue( strName, csRegValue );
  695. break;
  696. }
  697. }
  698. }
  699. }
  700. // remove the ending ",,something"
  701. int cPos = csRegValue.Find(_T(','));
  702. if ( cPos != (-1))
  703. {
  704. csRegValue = csRegValue.Left( cPos );
  705. }
  706. }
  707. }
  708. void CInitApp::DeriveInetpubFromWWWRoot(void)
  709. {
  710. TSTR strParentDir( MAX_PATH );
  711. if ( !strParentDir.Resize( _tcslen( m_csPathWWWRoot.GetBuffer(0) ) ) )
  712. {
  713. // String is too long to deal with
  714. return;
  715. }
  716. // Try to figure out InetPub Root
  717. // ------------------------------
  718. // Get inetpub dir from wwwroot
  719. // take the m_csPathWWWRoot and back off one dir to find it.
  720. InetGetFilePath(m_csPathWWWRoot, strParentDir.QueryStr() );
  721. if ((IsFileExist( strParentDir.QueryStr() )))
  722. {
  723. m_csPathInetpub = strParentDir.QueryStr();
  724. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Old InetPub='%1!s!'. Exists. so we'll use it.\n"), m_csPathInetpub));
  725. }
  726. else
  727. {
  728. iisDebugOutSafeParams((LOG_TYPE_WARN, _T("Old InetPub='%1!s!'. Does not exist. we'll use the default. WARNING.\n"), strParentDir.QueryStr()));
  729. }
  730. return;
  731. }
  732. void CInitApp::GetOldInetSrvDir(void)
  733. {
  734. CRegKey regINetStp( HKEY_LOCAL_MACHINE, REG_INETSTP, KEY_READ);
  735. // Get old InetSrv dir
  736. // -------------------
  737. m_csPathOldInetsrv = m_csPathInetsrv;
  738. if ((HKEY)regINetStp)
  739. {
  740. // Get the old inetsrv dir, and check if it's different
  741. regINetStp.m_iDisplayWarnings = FALSE;
  742. regINetStp.QueryValue( _T("InstallPath"), m_csPathOldInetsrv);
  743. if (-1 != m_csPathOldInetsrv.Find(_T('%')) )
  744. {
  745. // there is a '%' in the string
  746. TSTR_PATH strTempDir;
  747. if ( !strTempDir.Copy( m_csPathOldInetsrv.GetBuffer(0) ) ||
  748. !strTempDir.ExpandEnvironmentVariables() )
  749. {
  750. return;
  751. }
  752. m_csPathOldInetsrv = strTempDir.QueryStr();
  753. }
  754. m_fMoveInetsrv = (m_csPathOldInetsrv.CompareNoCase(m_csPathInetsrv) != 0);
  755. }
  756. return;
  757. }
  758. void CInitApp::GetOldWWWRootDir(void)
  759. {
  760. CString csOldWWWRoot;
  761. //
  762. // Try to get it from the old iis2,3,4 setup location if it's there.
  763. //
  764. CRegKey regINetStp( HKEY_LOCAL_MACHINE, REG_INETSTP, KEY_READ);
  765. if ((HKEY) regINetStp)
  766. {
  767. //
  768. // get the old wwwroot from the registry if there.
  769. //
  770. regINetStp.m_iDisplayWarnings = FALSE;
  771. regINetStp.QueryValue(_T("PathWWWRoot"), csOldWWWRoot);
  772. if (-1 != csOldWWWRoot.Find(_T('%')) )
  773. {
  774. TSTR_PATH strTempDir;
  775. if ( !strTempDir.Copy( csOldWWWRoot.GetBuffer(0) ) &&
  776. !strTempDir.ExpandEnvironmentVariables() )
  777. {
  778. return;
  779. }
  780. csOldWWWRoot = strTempDir.QueryStr();
  781. }
  782. // The old wwwRoot may be a network drive.
  783. // what to do then?
  784. // at least check if we can access it!
  785. if ((IsFileExist(csOldWWWRoot)))
  786. {
  787. iisDebugOutSafeParams((LOG_TYPE_TRACE, _T("Old WWWRoot='%1!s!'. Exists. so we'll use it.\n"), csOldWWWRoot));
  788. m_csPathWWWRoot = csOldWWWRoot;
  789. }
  790. else
  791. {
  792. iisDebugOutSafeParams((LOG_TYPE_WARN, _T("OldWWWRoot='%1!s!'. Does not exist. we'll use the default. WARNING.\n"), csOldWWWRoot));
  793. }
  794. }
  795. //
  796. // Try to get it from the old iis2,3,4 Actual W3svc Service location if it's there.
  797. // and overwrite anything that we got from setup -- since w3svc is what is actually used!
  798. //
  799. GetVRootValue(REG_W3SVC, _T("/"), _T("/"), m_csPathWWWRoot);
  800. return;
  801. }
  802. void CInitApp::GetOldIISSamplesLocation(void)
  803. {
  804. //
  805. // Try to get it from the old iis2,3,4 setup location if it's there.
  806. //
  807. CRegKey regINetStp( HKEY_LOCAL_MACHINE, REG_INETSTP, KEY_READ);
  808. if ((HKEY)regINetStp)
  809. {
  810. //
  811. // Get the location of the where the samples were installed.
  812. //
  813. m_csPathIISSamples.Empty();
  814. regINetStp.m_iDisplayWarnings = FALSE;
  815. regINetStp.QueryValue( _T("/IISSamples"), m_csPathIISSamples );
  816. if (-1 != m_csPathIISSamples.Find(_T('%')) )
  817. {
  818. TSTR_PATH strTempDir;
  819. if ( !strTempDir.Copy( m_csPathIISSamples.GetBuffer(0) ) &&
  820. !strTempDir.ExpandEnvironmentVariables() )
  821. {
  822. return;
  823. }
  824. m_csPathIISSamples = strTempDir.QueryStr();
  825. }
  826. if ( m_csPathIISSamples.IsEmpty())
  827. {
  828. //
  829. // if Samples path is empty then this an Upgrade,
  830. // Guess where to put Sample Site
  831. //
  832. TSTR strParentDir( MAX_PATH );
  833. TSTR strDir( MAX_PATH );
  834. if ( !strParentDir.Resize( _tcslen( m_csPathWWWRoot.GetBuffer(0) ) ) ||
  835. !strDir.Resize( _tcslen( m_csPathWWWRoot.GetBuffer(0) ) +
  836. _tcslen( _T("iissamples" ) )
  837. )
  838. )
  839. {
  840. return;
  841. }
  842. //
  843. // Get the parent Dir path
  844. //
  845. InetGetFilePath((LPCTSTR)m_csPathWWWRoot, strParentDir.QueryStr() );
  846. //
  847. // Append the samples dir to parent path
  848. //
  849. AppendDir(strParentDir.QueryStr(), _T("iissamples"), strDir.QueryStr() );
  850. m_csPathIISSamples = strDir.QueryStr();
  851. }
  852. }
  853. if (m_eUpgradeType == UT_10_W95)
  854. {
  855. TSTR strParentDir( MAX_PATH );
  856. TSTR strDir( MAX_PATH );
  857. if ( !strParentDir.Resize( _tcslen( m_csPathWWWRoot.GetBuffer(0) ) + _tcslen( _T("iissamples") ) ) ||
  858. !strDir.Resize( _tcslen( m_csPathWWWRoot.GetBuffer(0) ) + _tcslen( _T("webpub") ) )
  859. )
  860. {
  861. return;
  862. }
  863. InetGetFilePath(m_csPathWWWRoot, strParentDir.QueryStr() );
  864. AppendDir(strParentDir.QueryStr() , _T("iissamples"), strDir.QueryStr() );
  865. m_csPathIISSamples = strDir.QueryStr() ;
  866. AppendDir(strParentDir.QueryStr() , _T("webpub"), strDir.QueryStr() );
  867. m_csPathWebPub = strDir.QueryStr() ;
  868. }
  869. return;
  870. }
  871. void CInitApp::GetOldIISDirs(void)
  872. {
  873. CRegKey regINetStp( HKEY_LOCAL_MACHINE, REG_INETSTP, KEY_READ);
  874. //
  875. // get values from the previous setup for II2/4 upgrade
  876. //
  877. // Try to get old WWW Root from the service itself
  878. // -----------------------
  879. GetOldWWWRootDir();
  880. // Set Inetpub from whatever we got from www root
  881. DeriveInetpubFromWWWRoot();
  882. // Reset Vars relying on Inetpub
  883. // -----------------------------
  884. m_csPathFTPRoot = m_csPathInetpub + _T("\\ftproot");
  885. m_csPathIISSamples = m_csPathInetpub + _T("\\iissamples");
  886. m_csPathScripts = m_csPathInetpub + _T("\\Scripts");
  887. m_csPathWebPub = m_csPathInetpub + _T("\\webpub");
  888. m_csPathASPSamp = m_csPathInetpub + _T("\\ASPSamp");
  889. m_csPathAdvWorks = m_csPathInetpub + _T("\\ASPSamp\\AdvWorks");
  890. // Try to get old FTP Root from the service itself
  891. // -----------------------
  892. GetVRootValue(REG_MSFTPSVC, _T("/"), _T("/"), m_csPathFTPRoot);
  893. // Get old iis samples location
  894. // ----------------------------
  895. GetOldIISSamplesLocation();
  896. // Get iis 3.0 locations.
  897. // ----------------------
  898. GetVRootValue(REG_W3SVC, _T("/Scripts"), _T("/Scripts"), m_csPathScripts);
  899. GetVRootValue(REG_W3SVC, _T("/ASPSamp"), _T("/ASPSamp"), m_csPathASPSamp);
  900. GetVRootValue(REG_W3SVC, _T("/AdvWorks"), _T("/AdvWorks"), m_csPathAdvWorks);
  901. GetVRootValue(REG_W3SVC, _T("/IASDocs"), _T("/IASDocs"), m_csPathIASDocs);
  902. // Get old InetSrv dir
  903. // -------------------
  904. GetOldInetSrvDir();
  905. return;
  906. }
  907. void CInitApp::SetInetpubDerivatives()
  908. {
  909. m_csPathFTPRoot = m_csPathInetpub + _T("\\ftproot");
  910. m_csPathWWWRoot = m_csPathInetpub + _T("\\wwwroot");
  911. m_csPathWebPub = m_csPathInetpub + _T("\\webpub");
  912. m_csPathIISSamples = m_csPathInetpub + _T("\\iissamples");
  913. m_csPathScripts = m_csPathInetpub + _T("\\scripts");
  914. m_csPathASPSamp = m_csPathInetpub + _T("\\ASPSamp");
  915. m_csPathAdvWorks = m_csPathInetpub + _T("\\ASPSamp\\AdvWorks");
  916. switch (m_eInstallMode)
  917. {
  918. case IM_DEGRADE:
  919. case IM_FRESH:
  920. // use the initialized values
  921. break;
  922. case IM_UPGRADE:
  923. case IM_MAINTENANCE:
  924. {
  925. // override, what ever we just set above!
  926. GetOldIISDirs();
  927. break;
  928. }
  929. }
  930. }
  931. void CInitApp::SetInetpubDir()
  932. {
  933. m_csPathInetpub = m_csSysDrive + _T("\\Inetpub");
  934. // Check if the user wants to override this with a unattend setting
  935. Check_Custom_InetPub();
  936. }
  937. void CInitApp::ResetWAMPassword()
  938. {
  939. LPTSTR pszPassword = NULL;
  940. // create a iwam password
  941. pszPassword = CreatePassword(LM20_PWLEN+1);
  942. if (pszPassword)
  943. {
  944. m_csWAMAccountPassword = pszPassword;
  945. GlobalFree(pszPassword);pszPassword = NULL;
  946. }
  947. }
  948. // Init/Set m_csGuestName, m_csGuestPassword, destinations
  949. // -------------------------------------------------------
  950. void CInitApp::SetSetupParams()
  951. {
  952. // check if the debug level is set in the unattend file
  953. // ----------------------------------------------------
  954. Check_For_DebugLevel();
  955. // init m_csGuestName as IUSR_MachineName, init m_csGuestPassword as a random password
  956. TCHAR szGuestName[UNLEN+1];
  957. memset( (PVOID)szGuestName, 0, sizeof(szGuestName));
  958. CString csMachineName;
  959. csMachineName = m_csMachineName;
  960. csMachineName = csMachineName.Right(csMachineName.GetLength() - 2);
  961. LPTSTR pszPassword = NULL;
  962. // create a default guest name
  963. CString strDefGuest;
  964. MyLoadString( IDS_GUEST_NAME, strDefGuest);
  965. strDefGuest += csMachineName;
  966. _tcsncpy( szGuestName, (LPCTSTR) strDefGuest, LM20_UNLEN+1);
  967. m_csGuestName = szGuestName;
  968. // create a default guest password
  969. pszPassword = CreatePassword(LM20_PWLEN+1);
  970. if (pszPassword)
  971. {
  972. m_csGuestPassword = pszPassword;
  973. GlobalFree(pszPassword);pszPassword = NULL;
  974. }
  975. // Set the ftp/www users to use this default specified one...
  976. m_csWWWAnonyName = m_csGuestName;
  977. m_csWWWAnonyPassword = m_csGuestPassword;
  978. m_csFTPAnonyName = m_csGuestName;
  979. m_csFTPAnonyPassword = m_csGuestPassword;
  980. // init all 4 destinations
  981. m_csPathInetsrv = m_csSysDir + _T("\\inetsrv");
  982. m_csPathIASDocs = m_csPathInetsrv + _T("\\Docs");
  983. m_csPathProgramFiles = m_csSysDrive + _T("\\Program Files");
  984. CRegKey regCurrentVersion(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows\\CurrentVersion"), KEY_READ);
  985. if ( (HKEY)regCurrentVersion )
  986. {
  987. if (regCurrentVersion.QueryValue(_T("ProgramFilesDir"), m_csPathProgramFiles) != 0)
  988. {m_csPathProgramFiles = m_csSysDrive + _T("\\Program Files");}
  989. else
  990. {
  991. if (-1 != m_csPathProgramFiles.Find(_T('%')) )
  992. {
  993. // there is a '%' in the string
  994. TCHAR szTempDir[_MAX_PATH];
  995. _tcscpy(szTempDir, m_csPathProgramFiles);
  996. if (ExpandEnvironmentStrings( (LPCTSTR)m_csPathProgramFiles, szTempDir, sizeof(szTempDir)/sizeof(TCHAR)))
  997. {
  998. m_csPathProgramFiles = szTempDir;
  999. }
  1000. }
  1001. }
  1002. }
  1003. CRegKey regCurrentVersionSetup(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Setup"), KEY_READ);
  1004. if ( (HKEY)regCurrentVersionSetup )
  1005. {
  1006. // Get NT installation path
  1007. if (regCurrentVersionSetup.QueryValue(_T("SourcePath"), m_csPathNTSrcDir) != 0)
  1008. {m_csPathNTSrcDir = m_csSysDrive + _T("\\$WIN_NT$.~LS");}
  1009. else
  1010. {
  1011. if (-1 != m_csPathNTSrcDir.Find(_T('%')) )
  1012. {
  1013. // there is a '%' in the string
  1014. TCHAR szTempDir[_MAX_PATH];
  1015. _tcscpy(szTempDir, m_csPathNTSrcDir);
  1016. if (ExpandEnvironmentStrings( (LPCTSTR)m_csPathNTSrcDir, szTempDir, sizeof(szTempDir)/sizeof(TCHAR)))
  1017. {
  1018. m_csPathNTSrcDir = szTempDir;
  1019. }
  1020. }
  1021. }
  1022. }
  1023. //#ifdef _CHICAGO_
  1024. if (m_eUpgradeType == UT_10_W95)
  1025. {
  1026. BOOL bOSR2 = TRUE;
  1027. CRegKey regVersion(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion"), KEY_READ);
  1028. if ((HKEY)regVersion)
  1029. {
  1030. CString csString;
  1031. // VersionNumber for OSR2 is 4.00.1111
  1032. // VersionNumber for the original win95 is 4.00.950
  1033. if (regVersion.QueryValue(_T("VersionNumber"), csString) == ERROR_SUCCESS)
  1034. {
  1035. if (csString.Compare(_T("4.00.950")) == 0)
  1036. bOSR2 = FALSE;
  1037. }
  1038. }
  1039. if (!bOSR2)
  1040. {
  1041. g_pTheApp->m_csPathOldPWSFiles = m_csPathProgramFiles + _T("\\WebSvr");
  1042. g_pTheApp->m_csPathOldPWSSystemFiles = m_csPathProgramFiles + _T("\\WebSvr\\System");
  1043. }
  1044. else
  1045. {
  1046. g_pTheApp->m_csPathOldPWSFiles = m_csPathProgramFiles + _T("\\Personal Web Server");
  1047. g_pTheApp->m_csPathOldPWSSystemFiles = m_csPathProgramFiles + _T("\\Personal Web Server\\WebServer");
  1048. }
  1049. }
  1050. //#endif //_CHICAGO
  1051. return;
  1052. }
  1053. // Get Platform info
  1054. void CInitApp::GetPlatform()
  1055. {
  1056. if ( m_eOS == OS_NT)
  1057. {
  1058. SYSTEM_INFO si;
  1059. GetSystemInfo( &si );
  1060. m_csPlatform = _T("x86");
  1061. if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL) {m_csPlatform = _T("x86");}
  1062. if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_IA64) {m_csPlatform = _T("IA64");}
  1063. if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) {m_csPlatform = _T("AMD64");}
  1064. if (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_UNKNOWN) {m_csPlatform = _T("UNKNOWN");}
  1065. // save the number of processors for this machine.
  1066. m_dwNumberOfProcessors = si.dwNumberOfProcessors;
  1067. /* old
  1068. TCHAR *p = _tgetenv(_T("PROCESSOR_ARCHITECTURE"));
  1069. if ( p )
  1070. {m_csPlatform = p;}
  1071. else
  1072. {m_csPlatform = _T("x86");}
  1073. */
  1074. }
  1075. return;
  1076. }
  1077. BOOL CInitApp::GetMachineStatus()
  1078. {
  1079. if ( ( !GetMachineName() ) || // m_csMachineName
  1080. ( !GetOS() ) || // m_fOSNT
  1081. ( !GetOSVersion() ) || // NT 4.0 (Build 1381) or greater
  1082. ( !GetOSType() ) || // m_eOSType = NT_SRV or NT_WKS
  1083. ( !GetSysDirs() ) || // m_csWinDir. m_csSysDir
  1084. ( !IsTCPIPInstalled()) || // errmsg: if NO TCPIP is installed
  1085. ( !SetInstallMode()) ) // errmsg: if down grade the product
  1086. {
  1087. return FALSE;
  1088. }
  1089. SetSetupParams(); // Guest account, destinations
  1090. ReGetMachineAndAccountNames();
  1091. ResetWAMPassword();
  1092. SetInetpubDir();
  1093. SetInetpubDerivatives();
  1094. UnInstallList_RegRead(); // Get Uninstall information
  1095. UnInstallList_SetVars(); // set member variables for uninstall info
  1096. // check for any unattend file\custom settings.
  1097. Check_Unattend_Settings();
  1098. GetPlatform();
  1099. GetUserDomain();
  1100. return TRUE;
  1101. }
  1102. int CInitApp::MsgBox(HWND hWnd, int iID, UINT nType, BOOL bGlobalTitle)
  1103. {
  1104. if (iID == -1) {return IDOK;}
  1105. CString csMsg, csTitle;
  1106. MyLoadString(iID, csMsg);
  1107. csTitle = m_csAppName;
  1108. iisDebugOutSafeParams((LOG_TYPE_WARN, _T("CInitApp::MsgBox('%1!s!')\n"), csMsg));
  1109. return (::MessageBoxEx(NULL, (LPCTSTR)csMsg, csTitle, nType | MB_SETFOREGROUND, MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT)));
  1110. }
  1111. int CInitApp::MsgBox2(HWND hWnd, int iID,CString csInsertionString,UINT nType)
  1112. {
  1113. if (iID == -1) {return IDOK;}
  1114. CString csFormat, csMsg, csTitle;
  1115. MyLoadString(iID, csFormat);
  1116. csMsg.Format(csFormat, csInsertionString);
  1117. csTitle = m_csAppName;
  1118. iisDebugOutSafeParams((LOG_TYPE_WARN, _T("CInitApp::MsgBox2('%1!s!')\n"), csMsg));
  1119. return (::MessageBoxEx(NULL, (LPCTSTR)csMsg, csTitle, nType | MB_SETFOREGROUND, MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT)));
  1120. }
  1121. BOOL CInitApp::InitApplication()
  1122. // Return Value:
  1123. // TRUE: application is initiliazed correctly, continue processing
  1124. // FALSE: application is missing some required parameters, like the correct OS, TCPIP, etc.
  1125. // setup should be terminated.
  1126. {
  1127. BOOL fReturn = FALSE;
  1128. do {
  1129. // Get Machine Status:
  1130. // m_eInstallMode(Fresh, Maintenance, Upgrade, Degrade),
  1131. // m_eUpgradeType(PROD 2.0, PROD 3.0)
  1132. if ( !GetMachineStatus() )
  1133. {
  1134. CString csMsg;
  1135. MyLoadString(m_err, csMsg);
  1136. ::MessageBoxEx(NULL, (LPCTSTR)csMsg, (LPCTSTR) g_pTheApp->m_csAppName , MB_SETFOREGROUND, MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT));
  1137. iisDebugOutSafeParams((LOG_TYPE_ERROR, _T("GetMachineStatus(); MessageBoxEx('%1!s!') FAILER\n"), csMsg));
  1138. break;
  1139. }
  1140. if ( g_pTheApp->m_eInstallMode == IM_MAINTENANCE )
  1141. {g_pTheApp->m_fEULA = TRUE;}
  1142. fReturn = TRUE;
  1143. } while (0);
  1144. return fReturn;
  1145. }
  1146. // open the tcp/ip registry key
  1147. // if it's there then tcp/ip is installed
  1148. int TCPIP_Check_Temp_Hack(void)
  1149. {
  1150. int TheReturn = FALSE;
  1151. CRegKey regTheKey(HKEY_LOCAL_MACHINE,_T("System\\CurrentControlSet\\Services\\Tcpip"),KEY_READ);
  1152. if ((HKEY) regTheKey)
  1153. {
  1154. TheReturn = TRUE;
  1155. }
  1156. if (FALSE == TheReturn)
  1157. {
  1158. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("DETECT:TCPIP not Installed (yet), but we'll proceed as if it were.")));
  1159. TheReturn = TRUE;
  1160. }
  1161. return TheReturn;
  1162. }
  1163. void GetUserDomain(void)
  1164. {
  1165. HANDLE hProcess, hAccessToken;
  1166. TCHAR InfoBuffer[1000],szAccountName[200], szDomainName[200];
  1167. PTOKEN_USER pTokenUser = (PTOKEN_USER)InfoBuffer;
  1168. DWORD dwInfoBufferSize;
  1169. DWORD dwAccountSize = sizeof(szAccountName)/sizeof(szAccountName[0]);
  1170. DWORD dwDomainSize = sizeof(szDomainName)/sizeof(szDomainName[0]);
  1171. SID_NAME_USE snu;
  1172. hProcess = GetCurrentProcess();
  1173. OpenProcessToken(hProcess,TOKEN_READ,&hAccessToken);
  1174. GetTokenInformation(hAccessToken,TokenUser,InfoBuffer,1000, &dwInfoBufferSize);
  1175. if (LookupAccountSid(NULL, pTokenUser->User.Sid, szAccountName,&dwAccountSize,szDomainName, &dwDomainSize, &snu))
  1176. {
  1177. if (dwDomainSize)
  1178. {
  1179. g_pTheApp->m_csUsersDomain = szDomainName;
  1180. //_tcscpy(g_szUsersDomain, szDomainName);
  1181. }
  1182. else
  1183. {
  1184. g_pTheApp->m_csUsersDomain = _T(" ");
  1185. //_tcscpy(g_szUsersDomain, _T(" "));
  1186. }
  1187. if (dwDomainSize)
  1188. {
  1189. g_pTheApp->m_csUsersAccount = szAccountName;
  1190. //_tcscpy(g_szUsersAccount, szAccountName);
  1191. }
  1192. else
  1193. {
  1194. g_pTheApp->m_csUsersAccount = _T(" ");
  1195. }
  1196. }
  1197. }
  1198. // This function should only be called in FRESH NT5 setup.
  1199. void CInitApp::ReGetMachineAndAccountNames()
  1200. {
  1201. GetMachineName();
  1202. // re-calculate the IUSR_ and IWAM_ account names
  1203. TCHAR szGuestName[UNLEN+1];
  1204. memset( (PVOID)szGuestName, 0, sizeof(szGuestName));
  1205. CString csMachineName;
  1206. csMachineName = m_csMachineName;
  1207. csMachineName = csMachineName.Right(csMachineName.GetLength() - 2);
  1208. CString strDefGuest;
  1209. MyLoadString( IDS_GUEST_NAME, strDefGuest);
  1210. strDefGuest += csMachineName;
  1211. _tcsncpy( szGuestName, (LPCTSTR) strDefGuest, LM20_UNLEN+1);
  1212. m_csGuestName = szGuestName;
  1213. MyLoadString( IDS_WAM_ACCOUNT_NAME, strDefGuest);
  1214. strDefGuest += csMachineName;
  1215. _tcsncpy( szGuestName, (LPCTSTR) strDefGuest, LM20_UNLEN+1);
  1216. m_csWAMAccountName = szGuestName;
  1217. }
  1218. void CInitApp::DumpAppVars(void)
  1219. {
  1220. int iDoOnlyInThisMode = LOG_TYPE_TRACE;
  1221. // only do this if the debug mode is trace.
  1222. if (g_GlobalDebugLevelFlag >= iDoOnlyInThisMode)
  1223. {
  1224. iisDebugOut((iDoOnlyInThisMode, _T("=======================\n")));
  1225. // machine status
  1226. iisDebugOutSafeParams((iDoOnlyInThisMode, _T("m_csMachineName=%1!s!\n"), m_csMachineName));
  1227. iisDebugOutSafeParams((iDoOnlyInThisMode, _T("m_csUsersDomain=%1!s!\n"), m_csUsersDomain));
  1228. iisDebugOutSafeParams((iDoOnlyInThisMode, _T("m_csUsersAccount=%1!s!\n"), m_csUsersAccount));
  1229. iisDebugOutSafeParams((iDoOnlyInThisMode, _T("m_csWinDir=%1!s!\n"), m_csWinDir));;
  1230. iisDebugOutSafeParams((iDoOnlyInThisMode, _T("m_csSysDir=%1!s!\n"), m_csSysDir));;
  1231. iisDebugOutSafeParams((iDoOnlyInThisMode, _T("m_csSysDrive=%1!s!\n"), m_csSysDrive));;
  1232. iisDebugOutSafeParams((iDoOnlyInThisMode, _T("m_csPathNTSrcDir=%1!s!\n"), m_csPathNTSrcDir));;
  1233. iisDebugOutSafeParams((iDoOnlyInThisMode, _T("m_csPathSource=%1!s!\n"), m_csPathSource));;
  1234. iisDebugOutSafeParams((iDoOnlyInThisMode, _T("m_csPathOldInetsrv=%1!s!\n"), m_csPathOldInetsrv));;
  1235. iisDebugOutSafeParams((iDoOnlyInThisMode, _T("m_csPathInetsrv=%1!s!\n"), m_csPathInetsrv));;
  1236. iisDebugOutSafeParams((iDoOnlyInThisMode, _T("m_csPathInetpub=%1!s!\n"), m_csPathInetpub));;
  1237. iisDebugOutSafeParams((iDoOnlyInThisMode, _T("m_csPathFTPRoot=%1!s!\n"), m_csPathFTPRoot));;
  1238. iisDebugOutSafeParams((iDoOnlyInThisMode, _T("m_csPathWWWRoot=%1!s!\n"), m_csPathWWWRoot));;
  1239. iisDebugOutSafeParams((iDoOnlyInThisMode, _T("m_csPathWebPub=%1!s!\n"), m_csPathWebPub));;
  1240. iisDebugOutSafeParams((iDoOnlyInThisMode, _T("m_csPathProgramFiles=%1!s!\n"), m_csPathProgramFiles));;
  1241. iisDebugOutSafeParams((iDoOnlyInThisMode, _T("m_csPathIISSamples=%1!s!\n"), m_csPathIISSamples));;
  1242. iisDebugOutSafeParams((iDoOnlyInThisMode, _T("m_csPathScripts=%1!s!\n"), m_csPathScripts));;
  1243. iisDebugOutSafeParams((iDoOnlyInThisMode, _T("m_csPathASPSamp=%1!s!\n"), m_csPathASPSamp));;
  1244. iisDebugOutSafeParams((iDoOnlyInThisMode, _T("m_csPathAdvWorks=%1!s!\n"), m_csPathAdvWorks));;
  1245. iisDebugOutSafeParams((iDoOnlyInThisMode, _T("m_csPathIASDocs=%1!s!\n"), m_csPathIASDocs));;
  1246. iisDebugOutSafeParams((iDoOnlyInThisMode, _T("m_csPathOldPWSFiles=%1!s!\n"), m_csPathOldPWSFiles));;
  1247. iisDebugOutSafeParams((iDoOnlyInThisMode, _T("m_csPathOldPWSSystemFiles=%1!s!\n"), m_csPathOldPWSSystemFiles));;
  1248. if (m_eOS == OS_NT) {iisDebugOut((iDoOnlyInThisMode, _T("OS=NT\n")));}
  1249. if (m_eOS == OS_W95) {iisDebugOut((iDoOnlyInThisMode, _T("OS=W95\n")));}
  1250. if (m_eOS == OS_OTHERS) {iisDebugOut((iDoOnlyInThisMode, _T("OS=OTHER\n")));}
  1251. if (m_eNTOSType == OT_NTW){iisDebugOut((iDoOnlyInThisMode, _T("m_eNTOSType=OT_NTW (Workstation)\n")));}
  1252. if (m_eNTOSType == OT_NTS){iisDebugOut((iDoOnlyInThisMode, _T("m_eNTOSType=OT_NTS (Server)\n")));}
  1253. if (m_eNTOSType == OT_PDC_OR_BDC){iisDebugOut((iDoOnlyInThisMode, _T("m_eNTOSType=OT_PDC_OR_BDC (Primary/Backup Domain Controller)\n")));}
  1254. iisDebugOutSafeParams((iDoOnlyInThisMode, _T("m_csPlatform=%1!s!\n"), m_csPlatform));;
  1255. iisDebugOutSafeParams((iDoOnlyInThisMode, _T("m_dwNumberOfProcessors=%1!d!\n"), m_dwNumberOfProcessors));;
  1256. if (m_fNT5) {iisDebugOut((iDoOnlyInThisMode, _T("OSVersion=5\n")));}
  1257. if (m_fW95) {iisDebugOut((iDoOnlyInThisMode, _T("OSVersion=Win95\n")));}
  1258. iisDebugOut((iDoOnlyInThisMode, _T("m_dwOSBuild=%d\n"), m_dwOSBuild));
  1259. iisDebugOut((iDoOnlyInThisMode, _T("m_dwOSServicePack=0x%x\n"), m_dwOSServicePack));
  1260. iisDebugOut((iDoOnlyInThisMode, _T("m_fTCPIP Exists=%d\n"), m_fTCPIP));
  1261. if (m_eUpgradeType == UT_NONE){iisDebugOut((iDoOnlyInThisMode, _T("m_eUpgradeType=UT_NONE\n")));}
  1262. if (m_eUpgradeType == UT_10_W95){iisDebugOut((iDoOnlyInThisMode, _T("m_eUpgradeType=UT_10_W95\n")));}
  1263. if (m_eUpgradeType == UT_351){iisDebugOut((iDoOnlyInThisMode, _T("m_eUpgradeType=UT_351\n")));}
  1264. if (m_eUpgradeType == UT_10){iisDebugOut((iDoOnlyInThisMode, _T("m_eUpgradeType=UT_10\n")));}
  1265. if (m_eUpgradeType == UT_20){iisDebugOut((iDoOnlyInThisMode, _T("m_eUpgradeType=UT_20\n")));}
  1266. if (m_eUpgradeType == UT_30){iisDebugOut((iDoOnlyInThisMode, _T("m_eUpgradeType=UT_30\n")));}
  1267. if (m_eUpgradeType == UT_40){iisDebugOut((iDoOnlyInThisMode, _T("m_eUpgradeType=UT_40\n")));}
  1268. if (m_eUpgradeType == UT_50){iisDebugOut((iDoOnlyInThisMode, _T("m_eUpgradeType=UT_50\n")));}
  1269. if (m_eUpgradeType == UT_51){iisDebugOut((iDoOnlyInThisMode, _T("m_eUpgradeType=UT_51\n")));}
  1270. if (m_eUpgradeType == UT_60){iisDebugOut((iDoOnlyInThisMode, _T("m_eUpgradeType=UT_60\n")));}
  1271. if (m_eInstallMode == IM_FRESH){iisDebugOut((iDoOnlyInThisMode, _T("m_eInstallMode=IM_FRESH\n")));}
  1272. if (m_eInstallMode == IM_UPGRADE){iisDebugOut((iDoOnlyInThisMode, _T("m_eInstallMode=IM_UPGRADE\n")));}
  1273. if (m_eInstallMode == IM_MAINTENANCE){iisDebugOut((iDoOnlyInThisMode, _T("m_eInstallMode=IM_MAINTENANCE\n")));}
  1274. if (m_eInstallMode == IM_DEGRADE){iisDebugOut((iDoOnlyInThisMode, _T("m_eInstallMode=IM_DEGRADE\n")));}
  1275. if (m_dwSetupMode & SETUPMODE_UPGRADE){iisDebugOut((iDoOnlyInThisMode, _T("m_dwSetupMode=SETUPMODE_UPGRADE\n")));}
  1276. if (m_dwSetupMode == SETUPMODE_UPGRADEONLY){iisDebugOut((iDoOnlyInThisMode, _T("m_dwSetupMode=SETUPMODE_UPGRADE | SETUPMODE_UPGRADEONLY\n")));}
  1277. if (m_dwSetupMode == SETUPMODE_ADDEXTRACOMPS){iisDebugOut((iDoOnlyInThisMode, _T("m_dwSetupMode=SETUPMODE_UPGRADE | SETUPMODE_ADDEXTRACOMPS\n")));}
  1278. if (m_dwSetupMode & SETUPMODE_UPGRADE){iisDebugOut((iDoOnlyInThisMode, _T("m_bUpgradeTypeHasMetabaseFlag=%d\n"),m_bUpgradeTypeHasMetabaseFlag));}
  1279. if (m_dwSetupMode & SETUPMODE_MAINTENANCE){iisDebugOut((iDoOnlyInThisMode, _T("m_dwSetupMode=SETUPMODE_MAINTENANCE\n")));}
  1280. if (m_dwSetupMode == SETUPMODE_ADDREMOVE){iisDebugOut((iDoOnlyInThisMode, _T("m_dwSetupMode=SETUPMODE_MAINTENANCE | SETUPMODE_ADDREMOVE\n")));}
  1281. if (m_dwSetupMode == SETUPMODE_REINSTALL){iisDebugOut((iDoOnlyInThisMode, _T("m_dwSetupMode=SETUPMODE_MAINTENANCE | SETUPMODE_REINSTALL\n")));}
  1282. if (m_dwSetupMode == SETUPMODE_REMOVEALL){iisDebugOut((iDoOnlyInThisMode, _T("m_dwSetupMode=SETUPMODE_MAINTENANCE | SETUPMODE_REMOVEALL\n")));}
  1283. if (m_dwSetupMode & SETUPMODE_FRESH){iisDebugOut((iDoOnlyInThisMode, _T("m_dwSetupMode=SETUPMODE_FRESH\n")));}
  1284. if (m_dwSetupMode == SETUPMODE_MINIMAL){iisDebugOut((iDoOnlyInThisMode, _T("m_dwSetupMode=SETUPMODE_FRESH | SETUPMODE_MINIMAL\n")));}
  1285. if (m_dwSetupMode == SETUPMODE_TYPICAL){iisDebugOut((iDoOnlyInThisMode, _T("m_dwSetupMode=SETUPMODE_FRESH | SETUPMODE_TYPICAL\n")));}
  1286. if (m_dwSetupMode == SETUPMODE_CUSTOM){iisDebugOut((iDoOnlyInThisMode, _T("m_dwSetupMode=SETUPMODE_FRESH | SETUPMODE_CUSTOM\n")));}
  1287. iisDebugOut((iDoOnlyInThisMode, _T("m_bPleaseDoNotInstallByDefault=%d\n"), m_bPleaseDoNotInstallByDefault));
  1288. //if (m_bRefreshSettings == TRUE){iisDebugOut((iDoOnlyInThisMode, _T("m_bRefreshSettings=refresh files + refresh all settings\n")));}
  1289. //if (m_bRefreshSettings == FALSE){iisDebugOut((iDoOnlyInThisMode, _T("m_bRefreshSettings=refresh files only\n")));}
  1290. if (m_eAction == AT_DO_NOTHING){iisDebugOut((iDoOnlyInThisMode, _T("m_eAction=AT_DO_NOTHING\n")));}
  1291. if (m_eAction == AT_REMOVE){iisDebugOut((iDoOnlyInThisMode, _T("m_eAction=AT_REMOVE\n")));}
  1292. if (m_eAction == AT_INSTALL_FRESH){iisDebugOut((iDoOnlyInThisMode, _T("m_eAction=AT_INSTALL_FRESH\n")));}
  1293. if (m_eAction == AT_INSTALL_UPGRADE){iisDebugOut((iDoOnlyInThisMode, _T("m_eAction=AT_INSTALL_UPGRADE\n")));}
  1294. if (m_eAction == AT_INSTALL_REINSTALL){iisDebugOut((iDoOnlyInThisMode, _T("m_eAction=AT_INSTALL_REINSTALL\n")));}
  1295. iisDebugOut((iDoOnlyInThisMode, _T("m_fNTOperationFlags=0x%x\n"), m_fNTOperationFlags));
  1296. iisDebugOut((iDoOnlyInThisMode, _T("m_fNTGuiMode=%d\n"), m_fNTGuiMode));
  1297. iisDebugOut((iDoOnlyInThisMode, _T("m_fInvokedByNT=%d\n"), m_fInvokedByNT));
  1298. iisDebugOut((iDoOnlyInThisMode, _T("m_fNtWorkstation=%d\n"), m_fNtWorkstation));
  1299. iisDebugOut((iDoOnlyInThisMode, _T("m_fUnattended=%d\n"), m_fUnattended));
  1300. iisDebugOut((iDoOnlyInThisMode, _T("m_csUnattendFile=%s\n"), m_csUnattendFile));;
  1301. iisDebugOutSafeParams((iDoOnlyInThisMode, _T("m_csPathSrcDir=%1!s!\n"), m_csPathSrcDir));;
  1302. iisDebugOut((iDoOnlyInThisMode, _T("=======================\n")));
  1303. }
  1304. return;
  1305. }
  1306. int AreWeCurrentlyInstalled()
  1307. {
  1308. int iReturn = FALSE;
  1309. DWORD dwMajorVersion = 0;
  1310. CRegKey regINetStp( HKEY_LOCAL_MACHINE, REG_INETSTP, KEY_READ);
  1311. if ((HKEY) regINetStp)
  1312. {
  1313. LONG lReturnedErrCode = regINetStp.QueryValue(_T("MajorVersion"), dwMajorVersion);
  1314. if (lReturnedErrCode == ERROR_SUCCESS)
  1315. {
  1316. if (dwMajorVersion == 5)
  1317. {
  1318. iReturn = TRUE;
  1319. }
  1320. }
  1321. }
  1322. return iReturn;
  1323. }
  1324. #define sz_PreviousIISVersion_string _T("PreviousIISVersion")
  1325. int CInitApp::SetUpgradeType(void)
  1326. {
  1327. int iReturn = FALSE;
  1328. DWORD dwMajorVersion = 0;
  1329. DWORD dwMinorVersion = 0;
  1330. CString csFrontPage;
  1331. m_eInstallMode = IM_UPGRADE;
  1332. m_eUpgradeType = UT_NONE;
  1333. m_bUpgradeTypeHasMetabaseFlag = FALSE;
  1334. m_bPleaseDoNotInstallByDefault = TRUE;
  1335. CRegKey regINetStp( HKEY_LOCAL_MACHINE, REG_INETSTP, KEY_READ);
  1336. if ((HKEY) regINetStp)
  1337. {
  1338. LONG lReturnedErrCode = regINetStp.QueryValue(_T("MajorVersion"), dwMajorVersion);
  1339. if (lReturnedErrCode == ERROR_SUCCESS)
  1340. {
  1341. if (dwMajorVersion <= 1)
  1342. {
  1343. m_eUpgradeType = UT_10;
  1344. m_eInstallMode = IM_UPGRADE;
  1345. m_bUpgradeTypeHasMetabaseFlag = FALSE;
  1346. m_bPleaseDoNotInstallByDefault = FALSE;
  1347. iReturn = TRUE;
  1348. iisDebugOut((LOG_TYPE_TRACE, _T("%s=0x%x.\n"),sz_PreviousIISVersion_string, dwMajorVersion));
  1349. goto SetUpgradeType_Exit;
  1350. }
  1351. if (dwMajorVersion == 2)
  1352. {
  1353. m_eUpgradeType = UT_20;
  1354. m_eInstallMode = IM_UPGRADE;
  1355. m_bUpgradeTypeHasMetabaseFlag = FALSE;
  1356. m_bPleaseDoNotInstallByDefault = FALSE;
  1357. iReturn = TRUE;
  1358. iisDebugOut((LOG_TYPE_TRACE, _T("%s=0x%x.\n"),sz_PreviousIISVersion_string, dwMajorVersion));
  1359. goto SetUpgradeType_Exit;
  1360. }
  1361. if (dwMajorVersion == 3)
  1362. {
  1363. m_eUpgradeType = UT_30;
  1364. m_eInstallMode = IM_UPGRADE;
  1365. m_bUpgradeTypeHasMetabaseFlag = FALSE;
  1366. m_bPleaseDoNotInstallByDefault = FALSE;
  1367. iReturn = TRUE;
  1368. iisDebugOut((LOG_TYPE_TRACE, _T("%s=0x%x.\n"),sz_PreviousIISVersion_string, dwMajorVersion));
  1369. goto SetUpgradeType_Exit;
  1370. }
  1371. if (dwMajorVersion == 4)
  1372. {
  1373. CString csSetupString;
  1374. m_eUpgradeType = UT_40;
  1375. m_eInstallMode = IM_UPGRADE;
  1376. m_bUpgradeTypeHasMetabaseFlag = TRUE;
  1377. m_bPleaseDoNotInstallByDefault = FALSE;
  1378. iReturn = TRUE;
  1379. regINetStp.m_iDisplayWarnings = FALSE;
  1380. if (regINetStp.QueryValue(_T("SetupString"), csSetupString) == NERR_Success)
  1381. {
  1382. if (csSetupString.CompareNoCase(_T("K2 RTM")) != 0)
  1383. {
  1384. // Error: upgrade not supported on K2 Beta versions
  1385. // Do a fresh if it's k2 beta2!!!!
  1386. m_eInstallMode = IM_FRESH;
  1387. m_eUpgradeType = UT_NONE;
  1388. m_bUpgradeTypeHasMetabaseFlag = FALSE;
  1389. m_bPleaseDoNotInstallByDefault = FALSE;
  1390. iReturn = FALSE;
  1391. iisDebugOut((LOG_TYPE_TRACE, _T("%s=0x%x.Beta2.\n"),sz_PreviousIISVersion_string, dwMajorVersion));
  1392. goto SetUpgradeType_Exit;
  1393. }
  1394. }
  1395. iisDebugOut((LOG_TYPE_TRACE, _T("%s=0x%x.\n"),sz_PreviousIISVersion_string, dwMajorVersion));
  1396. goto SetUpgradeType_Exit;
  1397. }
  1398. if (dwMajorVersion == 5)
  1399. {
  1400. // There is a previous version of iis5 on the machine...
  1401. // Could be they are upgrading from nt5Workstation to and nt5Server machine!
  1402. // or from and server to a workstation! what a nightmare!!!
  1403. //m_eInstallMode = IM_FRESH;
  1404. m_eUpgradeType = UT_50;
  1405. m_eInstallMode = IM_UPGRADE;
  1406. m_bUpgradeTypeHasMetabaseFlag = TRUE;
  1407. m_bPleaseDoNotInstallByDefault = FALSE;
  1408. regINetStp.m_iDisplayWarnings = FALSE;
  1409. if (regINetStp.QueryValue(_T("MinorVersion"), dwMinorVersion) == NERR_Success)
  1410. {
  1411. if (dwMinorVersion >= 1)
  1412. {
  1413. m_eUpgradeType = UT_51;
  1414. m_eInstallMode = IM_UPGRADE;
  1415. m_bUpgradeTypeHasMetabaseFlag = TRUE;
  1416. m_bPleaseDoNotInstallByDefault = FALSE;
  1417. }
  1418. }
  1419. iReturn = TRUE;
  1420. iisDebugOut((LOG_TYPE_TRACE, _T("%s=0x%x.0x%x\n"),sz_PreviousIISVersion_string, dwMajorVersion,dwMinorVersion));
  1421. goto SetUpgradeType_Exit;
  1422. }
  1423. if (dwMajorVersion == 6)
  1424. {
  1425. // There is a previous version of iis5 on the machine...
  1426. // Could be they are upgrading from nt5Workstation to and nt5Server machine!
  1427. // or from and server to a workstation! what a nightmare!!!
  1428. //m_eInstallMode = IM_FRESH;
  1429. m_eUpgradeType = UT_60;
  1430. m_eInstallMode = IM_UPGRADE;
  1431. m_bUpgradeTypeHasMetabaseFlag = TRUE;
  1432. m_bPleaseDoNotInstallByDefault = FALSE;
  1433. iReturn = TRUE;
  1434. iisDebugOut((LOG_TYPE_TRACE, _T("%s=0x%x.0x%x\n"),sz_PreviousIISVersion_string, dwMajorVersion,dwMinorVersion));
  1435. goto SetUpgradeType_Exit;
  1436. }
  1437. if (dwMajorVersion > 6)
  1438. {
  1439. m_eInstallMode = IM_UPGRADE;
  1440. m_eUpgradeType = UT_60;
  1441. m_bUpgradeTypeHasMetabaseFlag = FALSE;
  1442. m_bPleaseDoNotInstallByDefault = TRUE;
  1443. iReturn = TRUE;
  1444. iisDebugOut((LOG_TYPE_TRACE, _T("%s=0x%x.0x%x\n"),sz_PreviousIISVersion_string, dwMajorVersion,dwMinorVersion));
  1445. goto SetUpgradeType_Exit;
  1446. }
  1447. // if we get here, then that means
  1448. // that we found a version like 7.0 or something
  1449. // which we should not upgrade since it is newer than us.
  1450. // but hey we're in upgrade mode, so we should set something
  1451. m_eInstallMode = IM_UPGRADE;
  1452. m_eUpgradeType = UT_NONE;
  1453. m_bUpgradeTypeHasMetabaseFlag = FALSE;
  1454. m_bPleaseDoNotInstallByDefault = TRUE;
  1455. iReturn = FALSE;
  1456. iisDebugOut((LOG_TYPE_TRACE, _T("%s=some other iis version\n"),sz_PreviousIISVersion_string));
  1457. }
  1458. }
  1459. // -----------------------------------
  1460. //
  1461. // Check for other Rogue versions of IIS
  1462. //
  1463. // win95 pws 1.0
  1464. // win95 fontpage installed pws 1.0 (actually totally different from pws 1.0)
  1465. //
  1466. // on NT5 we are able to upgrade from:
  1467. // Win95 pws 1.0
  1468. // Win95 pws 4.0
  1469. // on win95 pws 1.0, there was no inetstp dir
  1470. // so we must check other things.
  1471. // -----------------------------------
  1472. {
  1473. CRegKey regW3SVC(HKEY_LOCAL_MACHINE, REG_WWWPARAMETERS, KEY_READ);
  1474. if ((HKEY)regW3SVC)
  1475. {
  1476. CByteArray baMajorVersion;
  1477. regW3SVC.m_iDisplayWarnings = FALSE;
  1478. if (regW3SVC.QueryValue(_T("MajorVersion"), baMajorVersion) == NERR_Success)
  1479. {
  1480. // Check if we can read the MajorVersion value should be set to '\0' if pws 1.0
  1481. if (baMajorVersion[0] == '\0')
  1482. {
  1483. m_eUpgradeType = UT_10_W95;
  1484. m_eInstallMode = IM_UPGRADE;
  1485. m_bUpgradeTypeHasMetabaseFlag = FALSE;
  1486. m_bPleaseDoNotInstallByDefault = FALSE;
  1487. iReturn = TRUE;
  1488. iisDebugOut((LOG_TYPE_TRACE, _T("%s=1.\n"),sz_PreviousIISVersion_string));
  1489. goto SetUpgradeType_Exit;
  1490. }
  1491. }
  1492. }
  1493. }
  1494. //
  1495. // on win 95 there could be an
  1496. // installation of frontpg pws version 1.0
  1497. // we don't support upgrading this, so we'll do a fresh if we ever get here.
  1498. //
  1499. csFrontPage = g_pTheApp->m_csSysDir + _T("\\frontpg.ini");
  1500. if (IsFileExist(csFrontPage))
  1501. {
  1502. TCHAR buf[_MAX_PATH];
  1503. GetPrivateProfileString(_T("FrontPage 1.1"), _T("PWSRoot"), _T(""), buf, _MAX_PATH, csFrontPage);
  1504. if (*buf && IsFileExist(buf))
  1505. {
  1506. m_eInstallMode = IM_FRESH;
  1507. m_eUpgradeType = UT_NONE;
  1508. m_bUpgradeTypeHasMetabaseFlag = FALSE;
  1509. m_bPleaseDoNotInstallByDefault = FALSE;
  1510. iReturn = TRUE;
  1511. iisDebugOut((LOG_TYPE_TRACE, _T("%s=1.FrontPage Installation.\n"),sz_PreviousIISVersion_string));
  1512. goto SetUpgradeType_Exit;
  1513. }
  1514. }
  1515. //
  1516. // This could be an upgrade from WinNT 3.51
  1517. // which could have an FTPSVC installed.
  1518. // if it's here then install ftp.
  1519. // Software\Microsoft\FTPSVC
  1520. //
  1521. {
  1522. CRegKey regNT351FTP(HKEY_LOCAL_MACHINE, _T("Software\\Microsoft\\FTPSVC"), KEY_READ);
  1523. if ((HKEY) regNT351FTP)
  1524. {
  1525. m_eUpgradeType = UT_351;
  1526. m_eInstallMode = IM_UPGRADE;
  1527. m_bUpgradeTypeHasMetabaseFlag = FALSE;
  1528. m_bPleaseDoNotInstallByDefault = FALSE;
  1529. iReturn = TRUE;
  1530. iisDebugOut((LOG_TYPE_TRACE, _T("%s=NT351.ftp.\n"),sz_PreviousIISVersion_string));
  1531. goto SetUpgradeType_Exit;
  1532. }
  1533. }
  1534. // if we get here...then
  1535. // 1. we were not able to open the inetsrv reg
  1536. // 2. did not find an old pws 1.0 installation
  1537. // 3. did not find an old frontpg pws installation.
  1538. // 4. did not find nt 3.51 FTPSVC installed.
  1539. // since this is supposed to set the upgrade type, and there is nothing to upgrade...
  1540. // then we will Not install.....
  1541. //iisDebugOut((LOG_TYPE_PROGRAM_FLOW, _T("FRESH FRESH FRESH\n")));
  1542. m_eInstallMode = IM_UPGRADE;
  1543. m_eUpgradeType = UT_NONE;
  1544. m_bUpgradeTypeHasMetabaseFlag = FALSE;
  1545. m_bPleaseDoNotInstallByDefault = TRUE;
  1546. iisDebugOut((LOG_TYPE_TRACE, _T("%s=None.\n"),sz_PreviousIISVersion_string));
  1547. iReturn = FALSE;
  1548. SetUpgradeType_Exit:
  1549. return iReturn;
  1550. }
  1551. int CInitApp::Check_Custom_InetPub(void)
  1552. {
  1553. int iReturn = FALSE;
  1554. INFCONTEXT Context;
  1555. TSTR strSectionName( MAX_PATH );
  1556. TSTR_PATH strCustomInetpub( MAX_PATH );
  1557. // Do this only if unattended install
  1558. if (!g_pTheApp->m_fUnattended)
  1559. {
  1560. return iReturn;
  1561. }
  1562. // The section name to look for in the unattended file
  1563. if ( !strSectionName.Copy( UNATTEND_FILE_SECTION ) )
  1564. {
  1565. return iReturn;
  1566. }
  1567. //
  1568. // InetPub
  1569. //
  1570. if ( SetupFindFirstLine_Wrapped(g_pTheApp->m_hUnattendFile, strSectionName.QueryStr(), _T("PathInetpub"), &Context) &&
  1571. SetupGetStringField(&Context, 1, strCustomInetpub.QueryStr() , strCustomInetpub.QuerySize(), NULL) &&
  1572. strCustomInetpub.ExpandEnvironmentVariables() )
  1573. {
  1574. if (IsValidDirectoryName(strCustomInetpub.QueryStr()))
  1575. {
  1576. iisDebugOut((LOG_TYPE_TRACE, _T("Check_Custom_InetPub:PathInetpub=%s\n"), strCustomInetpub.QueryStr() ));
  1577. m_csPathInetpub = strCustomInetpub.QueryStr();
  1578. iReturn = TRUE;
  1579. g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_PATH_INETPUB;
  1580. }
  1581. else
  1582. {
  1583. iisDebugOut((LOG_TYPE_WARN, _T("Check_Custom_InetPub:PathInetpub=%s.Not Valid.ignoring unattend value. WARNING.\n"),strCustomInetpub.QueryStr()));
  1584. }
  1585. }
  1586. return iReturn;
  1587. }
  1588. void CInitApp::Check_Unattend_Settings(void)
  1589. {
  1590. // if there are unattended values specified for the ftp or www root,
  1591. // then set them here.
  1592. Check_Custom_WWW_or_FTP_Path();
  1593. DeriveInetpubFromWWWRoot();
  1594. // Check if there is an alternate iis.inf specified in the unattend file.
  1595. // this way the user can change sections in the iis.inf file without changing the iis.inf file itself
  1596. Check_Custom_IIS_INF();
  1597. // Check if the user wants to use a specific iusr\iwam name.
  1598. Check_Custom_Users();
  1599. // Check if the user wants to not automatically start WWW and/or FTP services
  1600. Check_SvcManualStart();
  1601. // Check if user wants applications setup in inprocess by default (not pooled out of process)
  1602. return;
  1603. }
  1604. void Check_SvcManualStart()
  1605. {
  1606. // Unattend flag format
  1607. // SvcManualStart=WWW,FTP
  1608. INFCONTEXT Context;
  1609. TCHAR szSectionName[_MAX_PATH];
  1610. TCHAR szValue[_MAX_PATH] = _T("");
  1611. // Do this only if unattended install
  1612. if ( !g_pTheApp->m_fUnattended ) return;
  1613. // The section name to look for in the unattended file
  1614. _tcscpy(szSectionName, UNATTEND_FILE_SECTION);
  1615. if ( !SetupFindFirstLine_Wrapped( g_pTheApp->m_hUnattendFile, szSectionName, _T("SvcManualStart"), &Context) )
  1616. {
  1617. // No such line
  1618. return;
  1619. }
  1620. int i = 1; // This is the specific part of the line ( www, ftp )
  1621. while( SetupGetStringField( &Context, i++, szValue, _MAX_PATH, NULL ) )
  1622. {
  1623. if ( *szValue )
  1624. {
  1625. if ( ::_tcsicmp( szValue, _T("WWW") ) == 0 )
  1626. {
  1627. g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_MANUAL_START_WWW;
  1628. iisDebugOut((LOG_TYPE_TRACE, _T("(unattend) Manual start requested for WWW service\n")));
  1629. }
  1630. else if ( ::_tcsicmp( szValue, _T("FTP") ) == 0 )
  1631. {
  1632. g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_MANUAL_START_FTP;
  1633. iisDebugOut((LOG_TYPE_TRACE, _T("(unattend) Manual start requested for FTP service\n")));
  1634. }
  1635. }
  1636. }
  1637. }
  1638. void Check_Custom_Users(void)
  1639. {
  1640. INFCONTEXT Context;
  1641. TSTR strSectionName( MAX_PATH );
  1642. TSTR_PATH strValue( MAX_PATH );
  1643. // Do this only if unattended install
  1644. if (!g_pTheApp->m_fUnattended)
  1645. {
  1646. return;
  1647. }
  1648. // The section name to look for in the unattended file
  1649. if ( !strSectionName.Copy( UNATTEND_FILE_SECTION ) )
  1650. {
  1651. return;
  1652. }
  1653. //
  1654. // IUSR: BOTH FTP AND WWW
  1655. //
  1656. if ( SetupFindFirstLine_Wrapped(g_pTheApp->m_hUnattendFile, strSectionName.QueryStr(), _T("IUSR"), &Context) &&
  1657. SetupGetStringField(&Context, 1, strValue.QueryStr() , strValue.QuerySize(), NULL) &&
  1658. strValue.ExpandEnvironmentVariables() )
  1659. {
  1660. if (_tcsicmp(strValue.QueryStr(), _T("")) != 0)
  1661. {
  1662. // assign it to the appropriate member variables.
  1663. g_pTheApp->m_csWWWAnonyName_Unattend = strValue.QueryStr();
  1664. g_pTheApp->m_csFTPAnonyName_Unattend = strValue.QueryStr();
  1665. g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_WWW_USER_NAME;
  1666. g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_FTP_USER_NAME;
  1667. iisDebugOut((LOG_TYPE_TRACE, _T("(unattend) Custom iusr specified for ftp/www\n")));
  1668. }
  1669. }
  1670. //
  1671. // IUSR: BOTH FTP AND WWW password
  1672. //
  1673. if ( SetupFindFirstLine_Wrapped(g_pTheApp->m_hUnattendFile, strSectionName.QueryStr(), _T("IUSR_PASS"), &Context) &&
  1674. SetupGetStringField(&Context, 1, strValue.QueryStr() , strValue.QuerySize(), NULL) &&
  1675. strValue.ExpandEnvironmentVariables() )
  1676. {
  1677. // assign it to the appropriate member variables.
  1678. if (_tcsicmp(strValue.QueryStr(), _T("")) != 0)
  1679. {
  1680. g_pTheApp->m_csWWWAnonyPassword_Unattend = strValue.QueryStr();
  1681. g_pTheApp->m_csFTPAnonyPassword_Unattend = strValue.QueryStr();
  1682. g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_WWW_USER_PASS;
  1683. g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_FTP_USER_PASS;
  1684. iisDebugOut((LOG_TYPE_TRACE, _T("(unattend) Custom iusr pass specified for ftp/www\n")));
  1685. }
  1686. }
  1687. //
  1688. // IUSR: FTP
  1689. // If there a value specified here, then it will override the one taken from "IUSR"
  1690. //
  1691. if ( SetupFindFirstLine_Wrapped(g_pTheApp->m_hUnattendFile, strSectionName.QueryStr(), _T("IUSR_FTP"), &Context) &&
  1692. SetupGetStringField(&Context, 1, strValue.QueryStr() , strValue.QuerySize(), NULL) &&
  1693. strValue.ExpandEnvironmentVariables() )
  1694. {
  1695. if (_tcsicmp(strValue.QueryStr(), _T("")) != 0)
  1696. {
  1697. // assign it to the appropriate member variables.
  1698. g_pTheApp->m_csFTPAnonyName_Unattend = strValue.QueryStr();
  1699. g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_FTP_USER_NAME;
  1700. iisDebugOut((LOG_TYPE_TRACE, _T("(unattend) Custom iusr specified for ftp\n")));
  1701. }
  1702. }
  1703. //
  1704. // IUSR: FTP password
  1705. //
  1706. if ( SetupFindFirstLine_Wrapped(g_pTheApp->m_hUnattendFile, strSectionName.QueryStr(), _T("IUSR_FTP_PASS"), &Context) &&
  1707. SetupGetStringField(&Context, 1, strValue.QueryStr() , strValue.QuerySize(), NULL) &&
  1708. strValue.ExpandEnvironmentVariables() )
  1709. {
  1710. if (_tcsicmp(strValue.QueryStr(), _T("")) != 0)
  1711. {
  1712. // assign it to the appropriate member variables.
  1713. g_pTheApp->m_csFTPAnonyPassword_Unattend = strValue.QueryStr();
  1714. g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_FTP_USER_PASS;
  1715. iisDebugOut((LOG_TYPE_TRACE, _T("(unattend) Custom iusr pass specified for ftp\n")));
  1716. }
  1717. }
  1718. //
  1719. // IUSR: WWW
  1720. // If there a value specified here, then it will override the one taken from "IUSR"
  1721. //
  1722. if ( SetupFindFirstLine_Wrapped(g_pTheApp->m_hUnattendFile, strSectionName.QueryStr(), _T("IUSR_WWW"), &Context) &&
  1723. SetupGetStringField(&Context, 1, strValue.QueryStr() , strValue.QuerySize(), NULL) &&
  1724. strValue.ExpandEnvironmentVariables() )
  1725. {
  1726. // assign it to the appropriate member variables.
  1727. g_pTheApp->m_csWWWAnonyName_Unattend = strValue.QueryStr();
  1728. g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_WWW_USER_NAME;
  1729. //g_pTheApp->m_csWWWAnonyPassword_Unattend = _T("");
  1730. iisDebugOut((LOG_TYPE_TRACE, _T("(unattend) Custom iusr specified for www\n")));
  1731. }
  1732. //
  1733. // IUSR: WWW password
  1734. // If there a value specified here, then it will override the one taken from "IUSR"
  1735. //
  1736. if ( SetupFindFirstLine_Wrapped(g_pTheApp->m_hUnattendFile, strSectionName.QueryStr(), _T("IUSR_WWW_PASS"), &Context) &&
  1737. SetupGetStringField(&Context, 1, strValue.QueryStr() , strValue.QuerySize(), NULL) &&
  1738. strValue.ExpandEnvironmentVariables() )
  1739. {
  1740. if (_tcsicmp(strValue.QueryStr(), _T("")) != 0)
  1741. {
  1742. // assign it to the appropriate member variables.
  1743. g_pTheApp->m_csWWWAnonyPassword_Unattend = strValue.QueryStr();
  1744. g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_WWW_USER_PASS;
  1745. iisDebugOut((LOG_TYPE_TRACE, _T("(unattend) Custom iusr pass specified for www\n")));
  1746. }
  1747. }
  1748. //
  1749. // IWAM: WWW
  1750. //
  1751. if ( SetupFindFirstLine_Wrapped(g_pTheApp->m_hUnattendFile, strSectionName.QueryStr(), _T("IWAM"), &Context) &&
  1752. SetupGetStringField(&Context, 1, strValue.QueryStr() , strValue.QuerySize(), NULL) &&
  1753. strValue.ExpandEnvironmentVariables() )
  1754. {
  1755. // assign it to the appropriate member variables.
  1756. g_pTheApp->m_csWAMAccountName_Unattend = strValue.QueryStr();
  1757. g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_WAM_USER_NAME;
  1758. iisDebugOut((LOG_TYPE_TRACE, _T("(unattend) Custom iwam specified\n")));
  1759. }
  1760. //
  1761. // IWAM: WWW password
  1762. //
  1763. if ( SetupFindFirstLine_Wrapped(g_pTheApp->m_hUnattendFile, strSectionName.QueryStr(), _T("IWAM_PASS"), &Context) &&
  1764. SetupGetStringField(&Context, 1, strValue.QueryStr() , strValue.QuerySize(), NULL) &&
  1765. strValue.ExpandEnvironmentVariables() )
  1766. {
  1767. if (_tcsicmp(strValue.QueryStr(), _T("")) != 0)
  1768. {
  1769. // assign it to the appropriate member variables.
  1770. g_pTheApp->m_csWAMAccountPassword_Unattend = strValue.QueryStr();
  1771. g_pTheApp->dwUnattendConfig |= USER_SPECIFIED_INFO_WAM_USER_PASS;
  1772. iisDebugOut((LOG_TYPE_TRACE, _T("(unattend) Custom iwam pass specified\n")));
  1773. }
  1774. }
  1775. return;
  1776. }
  1777. // reads the registry and fills up the list
  1778. void CInitApp::UnInstallList_RegRead()
  1779. {
  1780. int iGetOut = FALSE;
  1781. CString csBoth;
  1782. CString csKey;
  1783. CString csData;
  1784. CRegKey regInetstp( HKEY_LOCAL_MACHINE, REG_INETSTP, KEY_READ);
  1785. if ((HKEY) regInetstp)
  1786. {
  1787. int iPosition1;
  1788. int iLength;
  1789. CString csUninstallInfo;
  1790. LONG lReturnedErrCode = regInetstp.QueryValue( REG_SETUP_UNINSTALLINFO, csUninstallInfo);
  1791. if (lReturnedErrCode == ERROR_SUCCESS)
  1792. {
  1793. // add a "," to the end for parsing...
  1794. iLength = csUninstallInfo.GetLength();
  1795. if (iLength == 0)
  1796. {
  1797. goto UnInstallList_RegRead_Exit;
  1798. }
  1799. csUninstallInfo += _T(",");
  1800. iPosition1 = 0;
  1801. #ifdef _CHICAGO_
  1802. // quick fix so that it compiles under ansi
  1803. // i guess Find(parm1,parm2) under ansi doesn't take 2 parms
  1804. #else
  1805. int iPosition2;
  1806. int iPosition3;
  1807. iPosition1 = 0;
  1808. iPosition2 = csUninstallInfo.Find(_T(','),iPosition1);
  1809. iPosition3 = csUninstallInfo.Find(_T(','),iPosition2+1);
  1810. if (-1 == iPosition3){iPosition3 = iLength + 1;}
  1811. // loop thru and add to our list!
  1812. iGetOut = FALSE;
  1813. while (iGetOut == FALSE)
  1814. {
  1815. csKey = csUninstallInfo.Mid(iPosition1, iPosition2 - iPosition1);
  1816. csData = csUninstallInfo.Mid(iPosition2+1, iPosition3 - (iPosition2 + 1));
  1817. csKey.MakeUpper(); // uppercase the key
  1818. //iisDebugOut((LOG_TYPE_TRACE, _T(" UnInstallList_RegRead: %s=%s\n"),csKey,csData));
  1819. // add to our list
  1820. m_cmssUninstallMapList.SetAt(csKey, csData);
  1821. iPosition1 = iPosition3+1;
  1822. iPosition2 = csUninstallInfo.Find(_T(','),iPosition1);
  1823. if (-1 == iPosition2){iGetOut = TRUE;}
  1824. iPosition3 = csUninstallInfo.Find(_T(','),iPosition2+1);
  1825. if (-1 == iPosition3)
  1826. {
  1827. iPosition3 = iLength + 1;
  1828. iGetOut = TRUE;
  1829. }
  1830. }
  1831. #endif
  1832. }
  1833. }
  1834. UnInstallList_RegRead_Exit:
  1835. m_fUninstallMapList_Dirty = FALSE;
  1836. return;
  1837. }
  1838. void CInitApp::UnInstallList_RegWrite()
  1839. {
  1840. int i = 0;
  1841. POSITION pos;
  1842. CString csKey;
  1843. CString csData;
  1844. CString csAllData;
  1845. csAllData = _T("");
  1846. if (TRUE == m_fUninstallMapList_Dirty)
  1847. {
  1848. // loop thru the list to see if, we already have this entry
  1849. if (m_cmssUninstallMapList.IsEmpty())
  1850. {
  1851. CRegKey regInetstp(REG_INETSTP,HKEY_LOCAL_MACHINE);
  1852. if ((HKEY) regInetstp)
  1853. {regInetstp.DeleteValue(REG_SETUP_UNINSTALLINFO);}
  1854. //iisDebugOut((LOG_TYPE_TRACE, _T(" UnInstallList_RegWrite: empty\n")));
  1855. }
  1856. else
  1857. {
  1858. pos = m_cmssUninstallMapList.GetStartPosition();
  1859. while (pos)
  1860. {
  1861. i++;
  1862. csKey.Empty();
  1863. csData.Empty();
  1864. m_cmssUninstallMapList.GetNextAssoc(pos, csKey, csData);
  1865. if (i > 1)
  1866. {
  1867. csAllData += _T(",");
  1868. }
  1869. csAllData += csKey;
  1870. csAllData += _T(",");
  1871. csAllData += csData;
  1872. }
  1873. // write out csAllData
  1874. CRegKey regInetstp(REG_INETSTP,HKEY_LOCAL_MACHINE);
  1875. if ((HKEY) regInetstp)
  1876. {
  1877. regInetstp.SetValue(REG_SETUP_UNINSTALLINFO,csAllData);
  1878. }
  1879. else
  1880. {
  1881. iisDebugOut((LOG_TYPE_TRACE, _T("UnInstallList_RegWrite: failed! not writen!!!\n")));
  1882. }
  1883. }
  1884. }
  1885. }
  1886. void CInitApp::UnInstallList_Add(CString csItemUniqueKeyName,CString csDataToAdd)
  1887. {
  1888. CString csGottenValue;
  1889. csItemUniqueKeyName.MakeUpper(); // uppercase the key
  1890. if (TRUE == m_cmssUninstallMapList.Lookup(csItemUniqueKeyName, csGottenValue))
  1891. {
  1892. // found the key, replace the value
  1893. m_cmssUninstallMapList.SetAt(csItemUniqueKeyName, csDataToAdd);
  1894. }
  1895. else
  1896. {
  1897. // add the key and value pair
  1898. m_cmssUninstallMapList.SetAt(csItemUniqueKeyName, csDataToAdd);
  1899. }
  1900. iisDebugOut((LOG_TYPE_TRACE, _T("UnInstallList_Add:please addkey=%s,%s\n"),csItemUniqueKeyName,csDataToAdd));
  1901. m_fUninstallMapList_Dirty = TRUE;
  1902. }
  1903. void CInitApp::UnInstallList_DelKey(CString csItemUniqueKeyName)
  1904. {
  1905. iisDebugOut((LOG_TYPE_TRACE, _T("UnInstallList_DelKey:please delkey=%s\n"),csItemUniqueKeyName));
  1906. csItemUniqueKeyName.MakeUpper(); // uppercase the key
  1907. m_cmssUninstallMapList.RemoveKey(csItemUniqueKeyName);
  1908. m_fUninstallMapList_Dirty = TRUE;
  1909. }
  1910. void CInitApp::UnInstallList_DelData(CString csDataValue)
  1911. {
  1912. POSITION pos;
  1913. CString csKey;
  1914. CString csData;
  1915. // loop thru the list to see if, we already have this entry
  1916. if (m_cmssUninstallMapList.IsEmpty())
  1917. {
  1918. }
  1919. else
  1920. {
  1921. pos = m_cmssUninstallMapList.GetStartPosition();
  1922. while (pos)
  1923. {
  1924. csKey.Empty();
  1925. csData.Empty();
  1926. m_cmssUninstallMapList.GetNextAssoc(pos, csKey, csData);
  1927. if ( _tcsicmp(csData, csDataValue) == 0)
  1928. {
  1929. UnInstallList_DelKey(csKey);
  1930. }
  1931. }
  1932. }
  1933. }
  1934. void CInitApp::UnInstallList_Dump()
  1935. {
  1936. POSITION pos;
  1937. CString csKey;
  1938. CString csData;
  1939. // loop thru the list to see if, we already have this entry
  1940. if (m_cmssUninstallMapList.IsEmpty())
  1941. {
  1942. //iisDebugOut((LOG_TYPE_TRACE, _T(" UnInstallList_Dump: empty\n")));
  1943. }
  1944. else
  1945. {
  1946. pos = m_cmssUninstallMapList.GetStartPosition();
  1947. while (pos)
  1948. {
  1949. csKey.Empty();
  1950. csData.Empty();
  1951. m_cmssUninstallMapList.GetNextAssoc(pos, csKey, csData);
  1952. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T(" UnInstallList_Dump: %s=%s\n"), csKey, csData));
  1953. }
  1954. }
  1955. }
  1956. // Get values from list into our Variables!
  1957. void CInitApp::UnInstallList_SetVars()
  1958. {
  1959. POSITION pos;
  1960. CString csKey;
  1961. CString csData;
  1962. // loop thru the list to see if, we already have this entry
  1963. if (m_cmssUninstallMapList.IsEmpty())
  1964. {
  1965. //iisDebugOut((LOG_TYPE_TRACE, _T(" UnInstallList_Dump: empty\n")));
  1966. }
  1967. else
  1968. {
  1969. pos = m_cmssUninstallMapList.GetStartPosition();
  1970. while (pos)
  1971. {
  1972. csKey.Empty();
  1973. csData.Empty();
  1974. m_cmssUninstallMapList.GetNextAssoc(pos, csKey, csData);
  1975. if ( _tcsicmp(csKey, _T("IUSR_WAM")) == 0)
  1976. {
  1977. m_csWAMAccountName_Remove = csData;
  1978. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("UnInstallList_SetVars: m_csWAMAccountName_Remove=%s\n"), m_csWAMAccountName_Remove));
  1979. }
  1980. else if ( _tcsicmp(csKey, _T("IUSR_WWW")) == 0)
  1981. {
  1982. m_csWWWAnonyName_Remove = csData;
  1983. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("UnInstallList_SetVars: m_csWWWAnonyName_Remove=%s\n"), m_csWWWAnonyName_Remove));
  1984. }
  1985. else if ( _tcsicmp(csKey, _T("IUSR_FTP")) == 0)
  1986. {
  1987. m_csFTPAnonyName_Remove = csData;
  1988. iisDebugOut((LOG_TYPE_TRACE_WIN32_API, _T("UnInstallList_SetVars: m_csFTPAnonyName_Remove=%s\n"), m_csFTPAnonyName_Remove));
  1989. }
  1990. }
  1991. }
  1992. }
  1993. CString CInitApp::UnInstallList_QueryKey(CString csItemUniqueKeyName)
  1994. {
  1995. CString csGottenValue;
  1996. csGottenValue.Empty();
  1997. csItemUniqueKeyName.MakeUpper(); // uppercase the key
  1998. m_cmssUninstallMapList.Lookup(csItemUniqueKeyName, csGottenValue);
  1999. return csGottenValue;
  2000. }
  2001. // InitApplicationforSysPrep
  2002. //
  2003. // Do the initialization work necessary for sysprep to work
  2004. //
  2005. BOOL
  2006. CInitApp::InitApplicationforSysPrep()
  2007. {
  2008. if ( !GetSysDirs() )
  2009. {
  2010. return FALSE;
  2011. }
  2012. // Speficy this, so that it thinks it is an upgrade, and
  2013. // we will set the current IUSR_ and IWAM_ correctly
  2014. // later on
  2015. m_eUpgradeType = UT_60;
  2016. SetInetpubDir();
  2017. SetInetpubDerivatives();
  2018. return TRUE;
  2019. }