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.

237 lines
7.5 KiB

  1. /****************************************************************************
  2. Copyright (c) Microsoft Corporation 1998
  3. All rights reserved
  4. File: SETUP.CPP
  5. ***************************************************************************/
  6. #include "pch.h"
  7. #include "utils.h"
  8. #include "logging.h"
  9. #include "errorlog.h"
  10. #include "tasks.h"
  11. DEFINE_MODULE("RIPREP")
  12. //
  13. // EndProcess( )
  14. //
  15. HRESULT
  16. EndProcess(
  17. HWND hDlg )
  18. {
  19. TraceFunc( "EndProcess( )\n" );
  20. HRESULT hr = S_OK;
  21. WCHAR szSrcPath[ MAX_PATH ];
  22. WCHAR szDestPath[ MAX_PATH ];
  23. WCHAR szMajor[ 10 ];
  24. WCHAR szMinor[ 10 ];
  25. WCHAR szBuild[ 10 ];
  26. OSVERSIONINFO osver;
  27. BOOL b;
  28. DWORD dw;
  29. wsprintf( szDestPath,
  30. L"\\\\%s\\REMINST\\Setup\\%s\\%s\\%s\\%s\\Templates",
  31. g_ServerName,
  32. g_Language,
  33. REMOTE_INSTALL_IMAGE_DIR_W,
  34. g_MirrorDir,
  35. g_Architecture );
  36. CreateDirectory( szDestPath, NULL );
  37. wsprintf( szSrcPath, L"%s\\templates\\startrom.com", g_ImageName );
  38. wsprintf( szDestPath,
  39. L"\\\\%s\\REMINST\\Setup\\%s\\%s\\%s\\%s\\Templates\\startrom.com",
  40. g_ServerName,
  41. g_Language,
  42. REMOTE_INSTALL_IMAGE_DIR_W,
  43. g_MirrorDir,
  44. g_Architecture );
  45. b = CopyFile( szSrcPath, szDestPath, FALSE );
  46. if ( !b )
  47. {
  48. LBITEMDATA item;
  49. // Error will be logged in TASKS.CPP
  50. item.fSeen = FALSE;
  51. item.pszText = L"STARTROM.COM";
  52. item.uState = GetLastError( );
  53. item.todo = RebootSystem;
  54. SendMessage( hDlg, WM_ERROR_OK, 0, (LPARAM) &item );
  55. }
  56. wsprintf( szSrcPath, L"%s\\templates\\ntdetect.com", g_ImageName );
  57. wsprintf( szDestPath,
  58. L"\\\\%s\\REMINST\\Setup\\%s\\%s\\%s\\%s\\Templates\\ntdetect.com",
  59. g_ServerName,
  60. g_Language,
  61. REMOTE_INSTALL_IMAGE_DIR_W,
  62. g_MirrorDir,
  63. g_Architecture );
  64. b = CopyFile( szSrcPath, szDestPath, FALSE );
  65. if ( !b )
  66. {
  67. LBITEMDATA item;
  68. // Error will be logged in TASKS.CPP
  69. item.fSeen = FALSE;
  70. item.pszText = L"NTDETECT.COM";
  71. item.uState = GetLastError( );
  72. item.todo = RebootSystem;
  73. SendMessage( hDlg, WM_ERROR_OK, 0, (LPARAM) &item );
  74. }
  75. wsprintf( szSrcPath, L"%s\\templates\\ntldr", g_ImageName );
  76. wsprintf( szDestPath,
  77. L"\\\\%s\\REMINST\\Setup\\%s\\%s\\%s\\%s\\Templates\\ntldr",
  78. g_ServerName,
  79. g_Language,
  80. REMOTE_INSTALL_IMAGE_DIR_W,
  81. g_MirrorDir,
  82. g_Architecture );
  83. b = CopyFile( szSrcPath, szDestPath, FALSE );
  84. if ( !b )
  85. {
  86. LBITEMDATA item;
  87. // Error will be logged in TASKS.CPP
  88. item.fSeen = FALSE;
  89. item.pszText = L"NTLDR";
  90. item.uState = GetLastError( );
  91. item.todo = RebootSystem;
  92. SendMessage( hDlg, WM_ERROR_OK, 0, (LPARAM) &item );
  93. }
  94. wsprintf( szMajor, L"%u", OsVersion.dwMajorVersion );
  95. wsprintf( szMinor, L"%u", OsVersion.dwMinorVersion );
  96. wsprintf( szBuild, L"%u", OsVersion.dwBuildNumber );
  97. //
  98. // Need to add "Quotes" around the text
  99. //
  100. WCHAR szDescription[ REMOTE_INSTALL_MAX_DESCRIPTION_CHAR_COUNT + 2 ];
  101. WCHAR szHelpText[ REMOTE_INSTALL_MAX_HELPTEXT_CHAR_COUNT + 2 ];
  102. WCHAR szOSVersion[ 30 ];
  103. WCHAR szSystemRoot[ MAX_PATH ];
  104. wsprintf( szDescription, L"\"%s\"", g_Description );
  105. wsprintf( szHelpText, L"\"%s\"", g_HelpText );
  106. wsprintf( szOSVersion, L"\"%s.%s (%s)\"", szMajor, szMinor, szBuild );
  107. wsprintf( szSystemRoot, L"\"%s\"", g_SystemRoot );
  108. wsprintf( szDestPath,
  109. L"\\\\%s\\REMINST\\Setup\\%s\\%s\\%s\\%s\\Templates\\riprep.sif",
  110. g_ServerName,
  111. g_Language,
  112. REMOTE_INSTALL_IMAGE_DIR_W,
  113. g_MirrorDir,
  114. g_Architecture );
  115. wsprintf( szSrcPath, L"%s\\ristndrd.sif", g_ImageName );
  116. b = CopyFile( szSrcPath, szDestPath, FALSE );
  117. if ( !b )
  118. {
  119. LBITEMDATA item;
  120. // Error will be logged in TASKS.CPP
  121. item.fSeen = FALSE;
  122. item.pszText = L"RISTNDRD.SIF";
  123. item.uState = GetLastError( );
  124. item.todo = RebootSystem;
  125. SendMessage( hDlg, WM_ERROR_OK, 0, (LPARAM) &item );
  126. }
  127. WritePrivateProfileString( L"OSChooser",
  128. L"Description",
  129. szDescription,
  130. szDestPath );
  131. WritePrivateProfileString( L"OSChooser",
  132. L"Help",
  133. szHelpText,
  134. szDestPath );
  135. WritePrivateProfileString( L"OSChooser",
  136. L"ImageType",
  137. L"SYSPREP",
  138. szDestPath );
  139. WritePrivateProfileString( L"OSChooser",
  140. L"Version",
  141. szOSVersion,
  142. szDestPath );
  143. WritePrivateProfileString( L"OSChooser",
  144. L"SysPrepSystemRoot",
  145. szSystemRoot,
  146. szDestPath );
  147. WritePrivateProfileString( L"SetupData",
  148. L"SysPrepDevice",
  149. L"\"\\Device\\LanmanRedirector\\%SERVERNAME%\\RemInst\\%SYSPREPPATH%\"",
  150. szDestPath );
  151. WritePrivateProfileString( L"SetupData",
  152. L"SysPrepDriversDevice",
  153. L"\"\\Device\\LanmanRedirector\\%SERVERNAME%\\RemInst\\%SYSPREPDRIVERS%\"",
  154. szDestPath );
  155. WritePrivateProfileString( L"OSChooser",
  156. L"LaunchFile",
  157. L"\"%INSTALLPATH%\\%MACHINETYPE%\\templates\\startrom.com\"",
  158. szDestPath );
  159. // WritePrivateProfileString( L"SetupData",
  160. // L"OsLoadOptions",
  161. // L"\"/noguiboot /fastdetect\"",
  162. // szDestPath );
  163. WritePrivateProfileString( L"SetupData",
  164. L"SetupSourceDevice",
  165. L"\"\\Device\\LanmanRedirector\\%SERVERNAME%\\RemInst\\%INSTALLPATH%\"",
  166. szDestPath );
  167. WritePrivateProfileString( L"UserData",
  168. L"ComputerName",
  169. L"\"%MACHINENAME%\"",
  170. szDestPath );
  171. WritePrivateProfileString( L"OSChooser",
  172. L"HalName",
  173. g_HalName,
  174. szDestPath );
  175. WritePrivateProfileString( L"OSChooser",
  176. L"ProductType",
  177. g_ProductId,
  178. szDestPath );
  179. // End the log
  180. dw = LoadString( g_hinstance, IDS_END_LOG, szSrcPath, ARRAYSIZE( szSrcPath ));
  181. Assert( dw );
  182. LogMsg( szSrcPath );
  183. // Display any errors recorded in the log
  184. if ( g_fErrorOccurred )
  185. {
  186. HINSTANCE hRichedDLL;
  187. // Make sure the RichEdit control has been initialized.
  188. // Simply LoadLibbing it does this for us.
  189. hRichedDLL = LoadLibrary( L"RICHED32.DLL" );
  190. if ( hRichedDLL != NULL )
  191. {
  192. DialogBox( g_hinstance, MAKEINTRESOURCE( IDD_VIEWERRORS ), hDlg, ErrorsDlgProc );
  193. FreeLibrary (hRichedDLL);
  194. }
  195. }
  196. RETURN(hr);
  197. }