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

2253 lines
77 KiB

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