Windows core programming code analysis based on Visual C ++ (60): System Disk customization and automatic software installation

Source: Internet
Author: User

We do not need to customize a special system disk. After installing the driver and software over and over again, the installation is a ready-made model. Save time and convenience.

Most of the software is installed intelligently. In other words, many software can be installed automatically or semi-automatically.
Different installation methods are discussed as follows:
1. Windows Installer Installation File Based on the MSI package: Common silent installation parameters are/QB (display Basic installation Interface) or/Q or/Qn. If you do not restart, you can also add reboot = suppress
For example, install the virtual optical drive daemontools: msiexec/I dtools. MSI/QB reboot = suppress
2. Windows Patch package: There are two cases: one is the installation file similar to the IE incremental patch package. to install it silently, you only need to add/Q after the execution file: a/R: N parameter. One is a common patch file for Windows, which can be installed silently by adding/u/n/Z (for new system patches, you can also use/Passive/norestart ). This is common in most cases, but some specific patches cannot be installed silently using this method.

3. Run the installation program again using the following command line to obtain the quiet installation parameter file setup. ISS:
Setup.exe-r-F1: C: \ setup. ISS
Copy setup. ISS to the installation file directory and run the following command: setup.exe-s [-SMS]
4. to install the installation file prepared by InstallShield with MSI, use the following command: setup.exe/S/V "/qb ".
5. For the installation file of wise installmaster, use: setup.exe/s.
6. For the Installation File Created by Inno Setup, use setup.exe/SP-/silent/norestart.
7. Use the Installation File Created by Nullsoft installation system (NSIs) to perform Silent Installation By/s (uppercase. Example: setup.exe/s

8. The Installation File Created by wise installation professional can be installed silently with the/silent parameter.

Get an installer, you can try the silent installation parameters ([/S] [/S] [/silent [/noreboot] [/verysilent [/SP-] [/norestart] [/q] [/Qn] [/QB] [reboot = suppress] [/S/V/Qn] [/Q: a/R: n] [/u/n/Z] [/quiet] [/silentinstallnostmsor] [/silentinstall] [/S/Qn] [/S/QD] [-S] [- q)

 

 

 

The following describes how to automatically install XP and software based on VC ++.

 

 

# Include "stdafx. H "# include" addshell. H "# include" addshelldlg. H "# include" shlwapi. H "# include" direct. H "# ifdef _ debug # define new debug_new # UNDEF this_filestatic char this_file [] = _ file __; # endif ////////////////////////////////////// //////////////////////////////////////// /caboutdlg Dialog used for app aboutclass caboutdlg: public cdialog {public: caboutdlg (); // dialog data // {afx_data (caboutdlg) enu M {IDD = idd_aboutbox}; //} afx_data // classwizard generated virtual function overrides // {afx_virtual (caboutdlg) protected: Virtual void dodataexchange (cdataexchange * PDX ); // DDX/DDV support //} afx_virtual // implementationprotected: // {afx_msg (caboutdlg) //} afx_msgdeclare_message_map ()}; // The global variable caboutdlg :: caboutdlg (): cdialog (caboutdlg: IDD) {// {afx_data_init (caboutdlg) //} afx_data_init} void cabou Tdlg: dodataexchange (cdataexchange * PDX) {cdialog: dodataexchange (PDX); // {afx_data_map (caboutdlg) //} afx_data_map} Export (caboutdlg, cdialog) // {afx_msg_map (caboutdlg) // No message handlers //} afx_msg_mapend_message_map () //////////////////////////////////////// /// // //// // /// caddshelldlg dialogcaddshelldlg:: caddshelldlg (cwnd * pparent/* = NULL */): cdialog (caddshell DLG: IDD, pparent) {// {afx_data_init (caddshelldlg) m_filepathname = _ T (""); m_catalogname = _ T (""); ///} afx_data_init // note that loadicon does not require a subsequent destroyicon in response = afxgetapp ()-> loadicon (idr_mainframe);} void exchange: dodataexchange (cdataexchange * PDX) {cdialog: dodataexchange (PDX); // {afx_data_map (caddshelldlg) ddx_control (PDX, idc_richedit_procinfo, m_richeditpro Cinfo); ddx_text (PDX, idc_edit_filepathname, m_filepathname); ddx_text (PDX, idc_edit_catalog, m_catalogname); //} afx_data_map} Export (caddshelldlg, cdialog) // {afx_msg_map (caddshelldlg) Then () on_wm_paint () Then (response, onbuttonopenfile) Then (response, onbuttonpacking) Then (idc_button1, onbuttonopencatalog) //} af X_msg_mapend_message_map () //////////////////////////////////////// /// // //// // /// caddshelldlg message handlersbool caddshelldlg:: oninitdialog () {cdialog: oninitdialog (); // Add "about... "menu item to system menu. // idm_aboutbox must be in the system command range. assert (idm_aboutbox & 0xfff0) = idm_aboutbox); Assert (idm_aboutbox <0xf000); cmenu * psysmenu = getsystemmenu (Fa LSE); If (psysmenu! = NULL) {cstring straboutmenu; straboutmenu. loadstring (ids_aboutbox); If (! Straboutmenu. isempty () {psysmenu-> appendmenu (mf_separator); psysmenu-> appendmenu (mf_string, idm_aboutbox, straboutmenu); }}// set the icon for this dialog. the framework does this automatically // when the application's main window is not a dialogseticon (m_hicon, true); // set big iconseticon (m_hicon, false ); // set small icon // todo: add extra initialization herereturn true; // return true unless you s Et the focus to a control} void caddshelldlg: onsyscommand (uint NID, lparam) {If (NID & 0xfff0) = idm_aboutbox) {caboutdlg dlgabout; dlgabout. domodal ();} else {cdialog: onsyscommand (NID, lparam) ;}// if you add a Minimize button to your dialog, you will need the code below // to draw the icon. for MFC applications using the document/view model, // This is automatically done for you by the framewo Rk. void caddshelldlg: onpaint () {If (isiconic () {cpaintdc DC (this); // device context for paintingsendmessage (wm_iconerasebkgnd, (wparam) DC. getsafehdc (), 0); // center icon in client rectangleint cxicon = getsystemmetrics (sm_cxicon); int cyicon = getsystemmetrics (sm_cyicon); crect rect; getclientrect (& rect ); int x = (rect. width ()-cxicon + 1)/2; int y = (rect. height ()-cyicon + 1)/2; // draw the I Condc. drawicon (X, Y, m_hicon);} else {cdialog: onpaint ();}} // The system callthis to obtain the cursor to display while the user drags // The minimized window. hcursor caddshelldlg: onquerydragicon () {return (hcursor) m_hicon;} void caddshelldlg: onbuttonopenfile () {// todo: add your control notification handler code here // sets file filtering, which file types are opened by default, and "|" ends. Char szfilter [] = "executable file (*. EXE) | *. exe | all files (*. *) | *. * | "; // read msdn to learn about the usage of constructor in cfiledialog. // The first parameter is true, indicating that the file dialog box is opened; false, indicating that the file is saved. // For other detailed parameter descriptions, see the following section. Cfiledialog DLG (true, null, null, ofn_hidereadonly | ofn_overwriteprompt, szfilter, null); // If (DLG. domodal () = idok) {// obtain the file path m_filepathname = DLG. getpathname (); // set RichEdit content // set the pointer to m_richeditprocinfo.setsel (-1,-1) at the end of the edit box; // Replace the last content in the edit box, it is actually adding content at the end. M_richeditprocinfo.replacesel ("file path:"); m_richeditprocinfo.replacesel (m_filepathname); m_richeditprocinfo.replacesel ("\ r \ n"); // use the obtained file path to update the content of the editing. Updatedata (false) ;}} void caddshelldlg: onbuttonpacking () {// get the current directory cstring path_directory, path_txt; // path_directory: path path_txt: path + file name getmodulefilename (null, path_txt.getbuffer (max_path), max_path); // obtain the path of the current program running (); int path_directory_length = running ('\'); path_directory = path_txt.left (path_directory_length + 1 ); // obtain winnt. sif file path char siffilepath [255]; strcpy (Si Ffilepath, path_directory); strcat (siffilepath, "winnt. Sif"); If (! Pathfileexists (siffilepath) {MessageBox ("winnt. sif is not in the program directory "," NOTE ", mb_ OK); return;} // create the $ OEM $ \ $1 \ install \ directory char installpath [255]; char appcmdpath [255]; strcpy (installpath, m_catalogname); strcat (installpath, "\\$ OEM {1} quot;); createdirectory (installpath, null); strcat (installpath, "\ $1"); createdirectory (installpath, null); strcat (installpath, "\ install"); createdirectory (installpath, null); strcpy (appcmdpath, INS Tallpath); strcat (appcmdpath, "\ applications. cmd "); strcat (installpath," \ Applications "); createdirectory (installpath, null); strcat (installpath," \ runsoft.exe "); copyfile (m_filepathname, installpath, false); If (! Pathfileexists (installpath) {MessageBox ("failed to copy the EXE file", "NOTE", mb_ OK); return ;} // set RichEdit content // set the pointer to m_richeditprocinfo.setsel (-1,-1) at the end of the editing box; // Replace the last content of the editing box, which is actually added at the end. M_richeditprocinfo.replacesel ("executable file copy completed:"); m_richeditprocinfo.replacesel (installpath); m_richeditprocinfo.replacesel ("\ r \ n"); // update the edit box content with the obtained file path. Updatedata (false); // create applications. CMD file * appcmdfile; If (appcmdfile = fopen (appcmdpath, "WT +") = NULL) // a text file that allows reading and writing {MessageBox ("applications. CMD file creation failed "," NOTE ", mb_ OK);} fseek (appcmdfile, 0l, seek_set); fputs (" CLS \ r \ n ", appcmdfile ); fputs ("@ echo off \ r \ n", appcmdfile); fputs ("START/Wait % systemdrive % \ install \ applications \ runsoft.exe \ r \ n ", appcmdfile); fputs ("RD/S/Q % systemdrive % \ install \ r \ n", appcmdfil E); fputs ("exit", appcmdfile); fclose (appcmdfile); // set the RichEdit content // set the pointer to m_richeditprocinfo.setsel (-1,-1) at the end of the editing box ); // Replace the content at the end of the editing box. The content is actually added at the end. Created ("applications. CMD file:"); m_richeditprocinfo.replacesel (appcmdpath); m_richeditprocinfo.replacesel ("\ r \ n"); // update the edit box content with the obtained file path. Updatedata (false); // copy the EXE file. // Start copying winnt. sif file char sifi386path [255] = {0}; strcpy (sifi386path, m_catalogname); strcat (sifi386path, "\ i386 \ WINNT. sif "); copyfile (siffilepath, sifi386path, false); If (! Pathfileexists (sifi1_path) {MessageBox ("winnt. failed to copy SIF file "," NOTE ", mb_ OK); Return ;}// add winnt to the file path to be run. sif file * siffile; If (siffile = fopen (sifi386path, "At +") = NULL) // text file, allowing read and append {MessageBox ("winnt. failed to append the SIF file. "," NOTE ", mb_ OK) ;}fseek (siffile, 0l, seek_end); fputs (" \ r \ n ", siffile ); fputs ("[guirunonce] \ r \ n", siffile); fputs ("% systemdrive % \ install \ applications. CMD \ r \ n ", siffile); fclose (siffile); // set RichEdit content // Set the pointer to m_richeditprocinfo.setsel (-1,-1) at the end of the editing box; // Replace the content at the end of the editing box to add content at the end. M_richeditprocinfo.replacesel ("winnt. Sif file is set up, you can package it"); m_richeditprocinfo.replacesel ("\ r \ n"); // update the content of the edit box with the obtained file path. Updatedata (false);} void caddshelldlg: onbuttonopencatalog () {char szdir [255]; browseinfo Bi; itemidlist * pidl; bi. hwndowner = This-> m_hwnd; bi. pidlroot = NULL; bi. pszdisplayname = szdir; bi. lpsztitle = "select the folder to add"; bi. ulflags = bif_returnonlyfsdirs | bif_dontgobelowdomain; bi. lpfn = NULL; bi. lparam = 0; bi. iimage = 0; pidl = shbrowseforfolder (& BI); If (pidl = NULL) return; shgetpathfromidlist (pidl, Szdir); m_catalogname = szdir; // determines whether the input directory exists if (! Pathfileexists (szdir) {MessageBox ("the directory does not exist", "NOTE", mb_ OK); return;} Char i1_string [255]; strcpy (i1_string, m_catalogname); strcat (i1_string, "\ i386"); If (! Pathfileexists (i1_string) {MessageBox ("The i386 directory does not exist", "NOTE", mb_ OK); return ;} // set RichEdit content // set the pointer to m_richeditprocinfo.setsel (-1,-1) at the end of the editing box; // Replace the last content of the editing box, which is actually added at the end. ("System file directory:"); m_richeditprocinfo.replacesel (m_catalogname); m_richeditprocinfo.replacesel ("\ r \ n"); // update the edit box content with the obtained file path. Updatedata (false );}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.