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.

814 lines
22 KiB

  1. // Copyright (c) 2001 Microsoft Corporation
  2. //
  3. // File: ADInstallationUnit.cpp
  4. //
  5. // Synopsis: Defines a ADInstallationUnit
  6. // This object has the knowledge for installing
  7. // Active Directory
  8. //
  9. // History: 02/08/2001 JeffJon Created
  10. #include "pch.h"
  11. #include "resource.h"
  12. #include "InstallationUnitProvider.h"
  13. extern PCWSTR CYS_DCPROMO_COMMAND_LINE = L"dcpromo.exe";
  14. // Exit codes borrowed from DCPromo.cpp
  15. enum DCPromoExitCodes
  16. {
  17. // the operation failed.
  18. EXIT_CODE_UNSUCCESSFUL = 0,
  19. // the operation succeeded
  20. EXIT_CODE_SUCCESSFUL = 1,
  21. // the operation succeeded, and the user opted not to have the wizard
  22. // restart the machine, either manually or by specifying
  23. // RebootOnSuccess=NoAndNoPromptEither in the answerfile
  24. EXIT_CODE_SUCCESSFUL_NO_REBOOT = 2,
  25. // the operation failed, but the machine needs to be rebooted anyway
  26. EXIT_CODE_UNSUCCESSFUL_NEEDS_REBOOT = 3
  27. };
  28. // Finish page help
  29. static PCWSTR CYS_AD_FINISH_PAGE_HELP = L"cys.chm::/ad_server_role.htm";
  30. static PCWSTR CYS_AD_MILESTONE_HELP = L"cys.chm::/ad_server_role.htm#adsrvsummary";
  31. static PCWSTR CYS_AD_AFTER_FINISH_HELP = L"cys.chm::/ad_server_role.htm#adsrvcompletion";
  32. ADInstallationUnit::ADInstallationUnit() :
  33. syncRestoreModePassword(true),
  34. ExpressPathInstallationUnitBase(
  35. IDS_DOMAIN_CONTROLLER_TYPE,
  36. IDS_DOMAIN_CONTROLLER_DESCRIPTION,
  37. IDS_AD_FINISH_TITLE,
  38. IDS_AD_FINISH_UNINSTALL_TITLE,
  39. IDS_AD_FINISH_MESSAGE,
  40. IDS_AD_INSTALL_FAILED,
  41. IDS_AD_UNINSTALL_MESSAGE,
  42. IDS_AD_UNINSTALL_FAILED,
  43. IDS_AD_UNINSTALL_WARNING,
  44. IDS_AD_UNINSTALL_CHECKBOX,
  45. CYS_AD_FINISH_PAGE_HELP,
  46. CYS_AD_MILESTONE_HELP,
  47. CYS_AD_AFTER_FINISH_HELP,
  48. DC_SERVER)
  49. {
  50. LOG_CTOR(ADInstallationUnit);
  51. }
  52. ADInstallationUnit::~ADInstallationUnit()
  53. {
  54. LOG_DTOR(ADInstallationUnit);
  55. }
  56. InstallationReturnType
  57. ADInstallationUnit::InstallService(HANDLE logfileHandle, HWND hwnd)
  58. {
  59. LOG_FUNCTION(ADInstallationUnit::InstallService);
  60. InstallationReturnType result = INSTALL_SUCCESS_REBOOT;
  61. do
  62. {
  63. if (IsExpressPathInstall())
  64. {
  65. result = ExpressPathInstall(logfileHandle, hwnd);
  66. break;
  67. }
  68. // Write the heading to the log file
  69. CYS_APPEND_LOG(String::load(IDS_LOG_DOMAIN_CONTROLLER_HEADING));
  70. UpdateInstallationProgressText(hwnd, IDS_AD_PROGRESS);
  71. // Set the home regkey so that we go through post boot operations
  72. bool regkeyResult = SetRegKeyValue(
  73. CYS_HOME_REGKEY,
  74. CYS_HOME_VALUE,
  75. CYS_HOME_REGKEY_DCPROMO_VALUE,
  76. HKEY_LOCAL_MACHINE,
  77. true);
  78. ASSERT(regkeyResult);
  79. // set the key so CYS has to run again
  80. regkeyResult = SetRegKeyValue(
  81. CYS_HOME_REGKEY,
  82. CYS_HOME_REGKEY_MUST_RUN,
  83. CYS_HOME_RUN_KEY_RUN_AGAIN,
  84. HKEY_LOCAL_MACHINE,
  85. true);
  86. ASSERT(regkeyResult);
  87. // Run dcpromo.exe
  88. DWORD exitCode = 0;
  89. HRESULT hr = CreateAndWaitForProcess(
  90. GetDCPromoPath(),
  91. String(),
  92. exitCode);
  93. if (FAILED(hr) ||
  94. exitCode == EXIT_CODE_UNSUCCESSFUL ||
  95. exitCode == EXIT_CODE_UNSUCCESSFUL_NEEDS_REBOOT)
  96. {
  97. CYS_APPEND_LOG(String::load(IDS_LOG_DOMAIN_CONTROLLER_SERVER));
  98. CYS_APPEND_LOG(String::load(IDS_LOG_WIZARD_CANCELLED));
  99. if (exitCode == EXIT_CODE_UNSUCCESSFUL_NEEDS_REBOOT)
  100. {
  101. result = INSTALL_FAILURE_NEEDS_REBOOT;
  102. }
  103. else
  104. {
  105. result = INSTALL_FAILURE;
  106. }
  107. break;
  108. }
  109. if (exitCode == EXIT_CODE_SUCCESSFUL_NO_REBOOT)
  110. {
  111. result = INSTALL_SUCCESS_NEEDS_REBOOT;
  112. break;
  113. }
  114. } while (false);
  115. if (result == INSTALL_FAILURE)
  116. {
  117. // Reset the regkeys so that the post reboot status page does not
  118. // run after reboot or logoff-logon
  119. bool regkeyResult = SetRegKeyValue(
  120. CYS_HOME_REGKEY,
  121. CYS_HOME_VALUE,
  122. CYS_HOME_REGKEY_DEFAULT_VALUE,
  123. HKEY_LOCAL_MACHINE,
  124. true);
  125. ASSERT(regkeyResult);
  126. // Set the the first DC regkey
  127. regkeyResult = SetRegKeyValue(
  128. CYS_HOME_REGKEY,
  129. CYS_FIRST_DC_VALUE,
  130. CYS_FIRST_DC_VALUE_UNSET,
  131. HKEY_LOCAL_MACHINE,
  132. true);
  133. ASSERT(regkeyResult);
  134. // set the key so CYS does not run after reboot
  135. regkeyResult = SetRegKeyValue(
  136. CYS_HOME_REGKEY,
  137. CYS_HOME_REGKEY_MUST_RUN,
  138. CYS_HOME_RUN_KEY_DONT_RUN,
  139. HKEY_LOCAL_MACHINE,
  140. true);
  141. ASSERT(regkeyResult);
  142. }
  143. LOG_INSTALL_RETURN(result);
  144. return result;
  145. }
  146. UnInstallReturnType
  147. ADInstallationUnit::UnInstallService(HANDLE logfileHandle, HWND hwnd)
  148. {
  149. LOG_FUNCTION(ADInstallationUnit::UnInstallService);
  150. UnInstallReturnType result = UNINSTALL_SUCCESS_REBOOT;
  151. do
  152. {
  153. // Write the heading to the log file
  154. CYS_APPEND_LOG(String::load(IDS_LOG_UNINSTALL_DOMAIN_CONTROLLER_HEADING));
  155. UpdateInstallationProgressText(hwnd, IDS_AD_UNINSTALL_PROGRESS);
  156. // Set the home regkey so that we go through post boot operations
  157. bool regkeyResult = SetRegKeyValue(
  158. CYS_HOME_REGKEY,
  159. CYS_HOME_VALUE,
  160. CYS_HOME_REGKEY_DCDEMOTE_VALUE,
  161. HKEY_LOCAL_MACHINE,
  162. true);
  163. ASSERT(regkeyResult);
  164. // set the key so CYS has to run again
  165. regkeyResult = SetRegKeyValue(
  166. CYS_HOME_REGKEY,
  167. CYS_HOME_REGKEY_MUST_RUN,
  168. CYS_HOME_RUN_KEY_RUN_AGAIN,
  169. HKEY_LOCAL_MACHINE,
  170. true);
  171. ASSERT(regkeyResult);
  172. // Run dcpromo.exe
  173. DWORD exitCode = 0;
  174. HRESULT hr = CreateAndWaitForProcess(
  175. GetDCPromoPath(),
  176. String(),
  177. exitCode);
  178. if (FAILED(hr) ||
  179. exitCode == EXIT_CODE_UNSUCCESSFUL ||
  180. exitCode == EXIT_CODE_UNSUCCESSFUL_NEEDS_REBOOT)
  181. {
  182. CYS_APPEND_LOG(String::load(IDS_LOG_UNINSTALL_DOMAIN_CONTROLLER_SERVER));
  183. CYS_APPEND_LOG(String::load(IDS_LOG_WIZARD_CANCELLED));
  184. if (exitCode == EXIT_CODE_UNSUCCESSFUL_NEEDS_REBOOT)
  185. {
  186. result = UNINSTALL_FAILURE_NEEDS_REBOOT;
  187. }
  188. else
  189. {
  190. result = UNINSTALL_FAILURE;
  191. }
  192. break;
  193. }
  194. if (exitCode == EXIT_CODE_SUCCESSFUL_NO_REBOOT)
  195. {
  196. result = UNINSTALL_SUCCESS_NEEDS_REBOOT;
  197. }
  198. } while (false);
  199. if (result == UNINSTALL_FAILURE)
  200. {
  201. // Reset the regkeys so that the post reboot status page does not
  202. // run after reboot or logoff-logon
  203. bool regkeyResult = SetRegKeyValue(
  204. CYS_HOME_REGKEY,
  205. CYS_HOME_VALUE,
  206. CYS_HOME_REGKEY_DEFAULT_VALUE,
  207. HKEY_LOCAL_MACHINE,
  208. true);
  209. ASSERT(regkeyResult);
  210. // Set the the first DC regkey
  211. regkeyResult = SetRegKeyValue(
  212. CYS_HOME_REGKEY,
  213. CYS_FIRST_DC_VALUE,
  214. CYS_FIRST_DC_VALUE_UNSET,
  215. HKEY_LOCAL_MACHINE,
  216. true);
  217. ASSERT(regkeyResult);
  218. }
  219. LOG_UNINSTALL_RETURN(result);
  220. return result;
  221. }
  222. InstallationReturnType
  223. ADInstallationUnit::ExpressPathInstall(HANDLE logfileHandle, HWND hwnd)
  224. {
  225. LOG_FUNCTION(ADInstallationUnit::ExpressPathInstall);
  226. InstallationReturnType result = INSTALL_SUCCESS_REBOOT;
  227. // Set the rerun state to false since DCPromo requires a reboot
  228. // State::GetInstance().SetRerunWizard(false);
  229. UpdateInstallationProgressText(hwnd, IDS_AD_PROGRESS_EXPRESS);
  230. // All these regkeys need to be set before we launch DCPromo because DCPromo
  231. // will reboot the machine
  232. // First set the home regkey to FirstServer so that we finish up the installation
  233. // after reboot
  234. bool regkeyResult = SetRegKeyValue(
  235. CYS_HOME_REGKEY,
  236. CYS_HOME_VALUE,
  237. CYS_HOME_REGKEY_FIRST_SERVER_VALUE,
  238. HKEY_LOCAL_MACHINE,
  239. true);
  240. ASSERT(regkeyResult);
  241. // Set the the first DC regkey
  242. regkeyResult = SetRegKeyValue(
  243. CYS_HOME_REGKEY,
  244. CYS_FIRST_DC_VALUE,
  245. CYS_FIRST_DC_VALUE_SET,
  246. HKEY_LOCAL_MACHINE,
  247. true);
  248. ASSERT(regkeyResult);
  249. // set the key so CYS has to run again
  250. regkeyResult = SetRegKeyValue(
  251. CYS_HOME_REGKEY,
  252. CYS_HOME_REGKEY_MUST_RUN,
  253. CYS_HOME_RUN_KEY_RUN_AGAIN,
  254. HKEY_LOCAL_MACHINE,
  255. true);
  256. ASSERT(regkeyResult);
  257. // set the key to let the reboot know what the domain DNS name is
  258. regkeyResult = SetRegKeyValue(
  259. CYS_HOME_REGKEY,
  260. CYS_HOME_REGKEY_DOMAINDNS,
  261. GetNewDomainDNSName(),
  262. HKEY_LOCAL_MACHINE,
  263. true);
  264. ASSERT(regkeyResult);
  265. // set the key to let the reboot know what the IP address is
  266. regkeyResult = SetRegKeyValue(
  267. CYS_HOME_REGKEY,
  268. CYS_HOME_REGKEY_DOMAINIP,
  269. InstallationUnitProvider::GetInstance().GetDNSInstallationUnit().GetStaticIPAddressString(),
  270. HKEY_LOCAL_MACHINE,
  271. true);
  272. ASSERT(regkeyResult);
  273. do
  274. {
  275. // Register the dsrestore.dll which will sync the restore mode
  276. // password and the admin password
  277. if (SyncRestoreModePassword())
  278. {
  279. if (!RegisterPasswordSyncDLL())
  280. {
  281. // REVIEW_JEFFJON : ignore failures for now
  282. // result = INSTALL_FAILURE;
  283. // break;
  284. }
  285. }
  286. // Create answer file for DCPromo
  287. String answerFilePath;
  288. bool answerFileResult = CreateAnswerFileForDCPromo(answerFilePath);
  289. if (!answerFileResult)
  290. {
  291. ASSERT(answerFileResult);
  292. result = INSTALL_FAILURE;
  293. InstallationUnitProvider::GetInstance().
  294. GetExpressInstallationUnit().SetExpressRoleResult(
  295. ExpressInstallationUnit::EXPRESS_AD_FAILURE);
  296. CYS_APPEND_LOG(String::load(IDS_AD_EXPRESS_LOG_FAILURE));
  297. break;
  298. }
  299. // construct the command line and then call DCPromo
  300. String commandline = String::format(
  301. L"/answer:%1",
  302. answerFilePath.c_str());
  303. DWORD exitCode = 0;
  304. HRESULT hr = CreateAndWaitForProcess(
  305. GetDCPromoPath(),
  306. commandline,
  307. exitCode);
  308. if (FAILED(hr))
  309. {
  310. LOG(String::format(
  311. L"Failed to launch DCPromo: hr = %1!x!",
  312. hr));
  313. result = INSTALL_FAILURE;
  314. InstallationUnitProvider::GetInstance().
  315. GetExpressInstallationUnit().SetExpressRoleResult(
  316. ExpressInstallationUnit::EXPRESS_AD_FAILURE);
  317. CYS_APPEND_LOG(String::load(IDS_AD_EXPRESS_LOG_FAILURE));
  318. break;
  319. }
  320. if (exitCode == EXIT_CODE_UNSUCCESSFUL ||
  321. exitCode == EXIT_CODE_UNSUCCESSFUL_NEEDS_REBOOT)
  322. {
  323. LOG(String::format(
  324. L"DCPromo failed: exitCode = %1!x!",
  325. exitCode));
  326. result = INSTALL_FAILURE;
  327. InstallationUnitProvider::GetInstance().
  328. GetExpressInstallationUnit().SetExpressRoleResult(
  329. ExpressInstallationUnit::EXPRESS_AD_FAILURE);
  330. CYS_APPEND_LOG(String::load(IDS_AD_EXPRESS_LOG_FAILURE));
  331. break;
  332. }
  333. // We can't do anything else here because DCPromo will reboot
  334. } while (false);
  335. if (result == INSTALL_FAILURE)
  336. {
  337. // Reset the regkeys so that the post reboot status page does not
  338. // run after reboot or logoff-logon
  339. regkeyResult = SetRegKeyValue(
  340. CYS_HOME_REGKEY,
  341. CYS_HOME_VALUE,
  342. CYS_HOME_REGKEY_DEFAULT_VALUE,
  343. HKEY_LOCAL_MACHINE,
  344. true);
  345. ASSERT(regkeyResult);
  346. // Set the the first DC regkey
  347. regkeyResult = SetRegKeyValue(
  348. CYS_HOME_REGKEY,
  349. CYS_FIRST_DC_VALUE,
  350. CYS_FIRST_DC_VALUE_UNSET,
  351. HKEY_LOCAL_MACHINE,
  352. true);
  353. ASSERT(regkeyResult);
  354. // set the key so CYS doesn't have to run again
  355. regkeyResult = SetRegKeyValue(
  356. CYS_HOME_REGKEY,
  357. CYS_HOME_REGKEY_MUST_RUN,
  358. CYS_HOME_RUN_KEY_DONT_RUN,
  359. HKEY_LOCAL_MACHINE,
  360. true);
  361. ASSERT(regkeyResult);
  362. }
  363. LOG_INSTALL_RETURN(result);
  364. return result;
  365. }
  366. bool
  367. ADInstallationUnit::RegisterPasswordSyncDLL()
  368. {
  369. LOG_FUNCTION(ADInstallationUnit::RegisterPasswordSyncDLL);
  370. bool result = true;
  371. HINSTANCE dsrestore = 0;
  372. do
  373. {
  374. HRESULT hr = Win::LoadLibrary(L"dsrestor.dll", dsrestore);
  375. if (FAILED(hr))
  376. {
  377. LOG(String::format(
  378. L"LoadLibrary failed: hr = 0x%1!x!",
  379. hr));
  380. result = false;
  381. break;
  382. }
  383. FARPROC proc = 0;
  384. hr = Win::GetProcAddress(dsrestore, L"RegisterFilter", proc);
  385. if (FAILED(hr))
  386. {
  387. LOG(String::format(
  388. L"GetProcAddress Failed: hr = 0x%1!x!",
  389. hr));
  390. result = false;
  391. break;
  392. }
  393. typedef HRESULT (*REGISTERFILTER)(void);
  394. REGISTERFILTER regFilter = reinterpret_cast<REGISTERFILTER>(proc);
  395. hr = regFilter();
  396. if (FAILED(hr))
  397. {
  398. LOG(String::format(
  399. L"RegisterFilter failed: hr = 0x%1!x!",
  400. hr));
  401. result = false;
  402. break;
  403. }
  404. } while (false);
  405. LOG_BOOL(result);
  406. return result;
  407. }
  408. bool
  409. ADInstallationUnit::CreateAnswerFileForDCPromo(String& answerFilePath)
  410. {
  411. LOG_FUNCTION(ADInstallationUnit::CreateAnswerFileForDCPromo);
  412. bool result = true;
  413. String answerFileText = L"[DCInstall]\r\n";
  414. answerFileText += L"ReplicaOrNewDomain=Domain\r\n";
  415. answerFileText += L"TreeOrChild=Tree\r\n";
  416. answerFileText += L"CreateOrJoin=Create\r\n";
  417. answerFileText += L"DomainNetbiosName=";
  418. answerFileText += GetNewDomainNetbiosName();
  419. answerFileText += L"\r\n";
  420. answerFileText += L"NewDomainDNSName=";
  421. answerFileText += GetNewDomainDNSName();
  422. answerFileText += L"\r\n";
  423. answerFileText += L"DNSOnNetwork=No\r\n";
  424. answerFileText += L"DatabasePath=%systemroot%\\ntds\r\n";
  425. answerFileText += L"LogPath=%systemroot%\\ntds\r\n";
  426. answerFileText += L"SYSVOLPath=%systemroot%\\sysvol\r\n";
  427. answerFileText += L"SiteName=Default-First-Site\r\n";
  428. answerFileText += L"RebootOnSuccess=Yes\r\n";
  429. answerFileText += L"AutoConfigDNS=Yes\r\n";
  430. answerFileText += L"AllowAnonymousAccess=No\r\n";
  431. answerFileText += L"DisableCancelForDnsInstall=YES\r\n";
  432. String sysFolder = Win::GetSystemDirectory();
  433. answerFilePath = sysFolder + L"\\dcpromo.inf";
  434. // create the answer file for DCPromo
  435. LOG(String::format(
  436. L"Creating answer file at: %1",
  437. answerFilePath.c_str()));
  438. HRESULT hr = CreateTempFile(answerFilePath, answerFileText);
  439. if (FAILED(hr))
  440. {
  441. LOG(String::format(
  442. L"Failed to create answer file for DCPromo: hr = %1!x!",
  443. hr));
  444. result = false;
  445. }
  446. LOG_BOOL(result);
  447. return result;
  448. }
  449. String
  450. ADInstallationUnit::GetServiceDescription()
  451. {
  452. LOG_FUNCTION(ADInstallationUnit::GetServiceDescription);
  453. unsigned int resourceID = static_cast<unsigned int>(-1);
  454. if (IsServiceInstalled())
  455. {
  456. resourceID = IDS_DOMAIN_CONTROLLER_DESCRIPTION_INSTALLED;
  457. }
  458. else
  459. {
  460. resourceID = descriptionID;
  461. }
  462. ASSERT(resourceID != static_cast<unsigned int>(-1));
  463. return String::load(resourceID);
  464. }
  465. bool
  466. ADInstallationUnit::GetMilestoneText(String& message)
  467. {
  468. LOG_FUNCTION(ADInstallationUnit::GetMilestoneText);
  469. message = String::load(IDS_DC_FINISH_TEXT);
  470. LOG_BOOL(true);
  471. return true;
  472. }
  473. bool
  474. ADInstallationUnit::GetUninstallMilestoneText(String& message)
  475. {
  476. LOG_FUNCTION(ADInstallationUnit::GetUninstallMilestoneText);
  477. message = String::load(IDS_AD_UNINSTALL_TEXT);
  478. LOG_BOOL(true);
  479. return true;
  480. }
  481. void
  482. ADInstallationUnit::SetNewDomainDNSName(const String& newDomain)
  483. {
  484. LOG_FUNCTION2(
  485. ADInstallationUnit::SetNewDomainDNSName,
  486. newDomain);
  487. domain = newDomain;
  488. }
  489. void
  490. ADInstallationUnit::SetNewDomainNetbiosName(const String& newNetbios)
  491. {
  492. LOG_FUNCTION2(
  493. ADInstallationUnit::SetNewDomainNetbiosName,
  494. newNetbios);
  495. netbios = newNetbios;
  496. }
  497. void
  498. ADInstallationUnit::SetSafeModeAdminPassword(const String& newPassword)
  499. {
  500. LOG_FUNCTION(ADInstallationUnit::SetSafeModeAdminPassword);
  501. password = newPassword;
  502. }
  503. bool
  504. ADInstallationUnit::SyncRestoreModePassword() const
  505. {
  506. LOG_FUNCTION(ADInstallationUnit::SyncRestoreModePassword);
  507. LOG_BOOL(syncRestoreModePassword);
  508. return syncRestoreModePassword;
  509. }
  510. void
  511. ADInstallationUnit::ServerRoleLinkSelected(int linkIndex, HWND /*hwnd*/)
  512. {
  513. LOG_FUNCTION2(
  514. ADInstallationUnit::ServerRoleLinkSelected,
  515. String::format(
  516. L"linkIndex = %1!d!",
  517. linkIndex));
  518. if (IsServiceInstalled())
  519. {
  520. ASSERT(linkIndex == 0);
  521. LaunchMYS();
  522. }
  523. else
  524. {
  525. ASSERT(linkIndex == 0);
  526. LOG(L"Showing configuration help");
  527. ShowHelp(CYS_AD_FINISH_PAGE_HELP);
  528. }
  529. }
  530. void
  531. ADInstallationUnit::FinishLinkSelected(int linkIndex, HWND /*hwnd*/)
  532. {
  533. LOG_FUNCTION2(
  534. ADInstallationUnit::FinishLinkSelected,
  535. String::format(
  536. L"linkIndex = %1!d!",
  537. linkIndex));
  538. if (installing)
  539. {
  540. if (IsServiceInstalled())
  541. {
  542. if (linkIndex == 0)
  543. {
  544. LOG("Showing after checklist");
  545. ShowHelp(CYS_AD_AFTER_FINISH_HELP);
  546. }
  547. }
  548. else
  549. {
  550. ASSERT(linkIndex == 0);
  551. HRESULT hr = MyCreateProcess(GetDCPromoPath(), String());
  552. ASSERT(SUCCEEDED(hr));
  553. }
  554. }
  555. else
  556. {
  557. ASSERT(linkIndex == 0);
  558. // launch DCPROMO
  559. HRESULT hr = MyCreateProcess(GetDCPromoPath(), String());
  560. ASSERT(SUCCEEDED(hr));
  561. }
  562. }
  563. String
  564. ADInstallationUnit::GetFinishText()
  565. {
  566. LOG_FUNCTION(ADInstallationUnit::GetFinishText);
  567. unsigned int messageID = finishMessageID;
  568. if (installing)
  569. {
  570. InstallationReturnType result = GetInstallResult();
  571. if (result == INSTALL_FAILURE ||
  572. result == INSTALL_NO_CHANGES ||
  573. result == INSTALL_CANCELLED)
  574. {
  575. messageID = finishInstallFailedMessageID;
  576. }
  577. else if (result == INSTALL_SUCCESS_NEEDS_REBOOT)
  578. {
  579. messageID = IDS_AD_FINISH_MESSAGE_NEEDS_REBOOT;
  580. }
  581. else if (result == INSTALL_FAILURE_NEEDS_REBOOT)
  582. {
  583. messageID = IDS_AD_INSTALL_FAILED_NEEDS_REBOOT;
  584. }
  585. }
  586. else
  587. {
  588. messageID = finishUninstallMessageID;
  589. UnInstallReturnType result = GetUnInstallResult();
  590. if (result == UNINSTALL_FAILURE ||
  591. result == UNINSTALL_NO_CHANGES ||
  592. result == UNINSTALL_CANCELLED)
  593. {
  594. messageID = finishUninstallFailedMessageID;
  595. }
  596. else if (result == UNINSTALL_SUCCESS_NEEDS_REBOOT)
  597. {
  598. messageID = IDS_AD_UNINSTALL_MESSAGE_NEEDS_REBOOT;
  599. }
  600. else if (result == UNINSTALL_FAILURE_NEEDS_REBOOT)
  601. {
  602. messageID = IDS_AD_UNINSTALL_FAILED_NEEDS_REBOOT;
  603. }
  604. }
  605. return String::load(messageID);
  606. }
  607. String
  608. ADInstallationUnit::GetDCPromoPath() const
  609. {
  610. LOG_FUNCTION(ADInstallationUnit::GetDCPromoPath);
  611. String result = Win::GetSystemDirectory();
  612. result = FS::AppendPath(result, CYS_DCPROMO_COMMAND_LINE);
  613. LOG(result);
  614. return result;
  615. }
  616. bool
  617. ADInstallationUnit::DoInstallerCheck(HWND hwnd) const
  618. {
  619. LOG_FUNCTION(ADInstallationUnit::DoInstallerCheck);
  620. bool result = State::GetInstance().IsDCPromoRunning();
  621. if (result)
  622. {
  623. LOG(L"DCPromo is running");
  624. popup.MessageBox(
  625. Win::GetParent(hwnd),
  626. IDS_DCPROMO_RUNNING2,
  627. MB_OK);
  628. }
  629. LOG_BOOL(result);
  630. return result;
  631. }