将 MS SQL Server 2005 SP2 整合到安装文件--【脚本修正】
刚入手新本本,一阵忙活,装好系统。小黑的驱动真不少,七七八八也有二三十个文件要下载、安装。轮到安装开发软件更是崩溃,一堆堆的sp等着我们打!微软留给我们的噩梦啊,所以,开始下载整合了SP补丁的软件,唯独没有找到SQL Server2005的整合版下载,只能自己动手,做个整合版了。网上一阵Google,见到园子里面这篇文章:将 MS SQL Server 2005 SP2 整合到安装文件,写的很不错,方法都有了,一看还有个脚本集成,很不错,可惜一执行下来,一堆错误,自己手动稍微调整了下,已经测试通过,放出来给大家共享一下,整合了开发版和企业版的32位安装包(带SP2)的大小855MB,isz压缩格式。修正的脚本如下:
1 /////////////////////////////////////////////////
2 // Slipsteaming MSSQL Server 2005 SP2
3 // Author : Zealic
4 // Date : 2007-03-19
5 // Version : 1.01
6 //
7 // Author : Hollis Yao
8 // Date : 2008-01-15
9 // Version : 2.00
10 /////////////////////////////////////////////////
11 var swap = "D:\\SWAP";
12 var sqldir = "D:\\MSSQL";
13 var sp2 = "D:\\SP2";
14 var server = sqldir + "\\Servers\\Setup";
15 var tools = sqldir + "\\Tools\\Setup";
16 var log = "D:\\install.log";
17
18 install();
19
20 function install()
21 {
22 WScript.Echo("Slipsteaming MSSQL Server 2005 SP2 By Zealic, Playse wait processing");
23 try
24 {
25 installServers();
26 //exec("RD /Q /S " + swap );
27 installTools();
28 sucess();
29 }
30 catch(e)
31 {
32 WScript.Echo(e.name + " : " + e.message);
33 fail();
34 }
35 }
36
37 function installServers()
38 {
39 testRun("XCOPY /Y /H " + sp2 + "\\*.msi " + server);
40 testRun("msiexec /quiet /a" + server + "\\sqlrun_as.msi TARGETDIR=" + swap + " /L*vx " + log);
41 testRun("msiexec /quiet /a" + server + "\\sqlrun_dts.msi TARGETDIR=" + swap + " /L*vx " + log);
42 testRun("msiexec /quiet /a" + server + "\\sqlrun_ns.msi TARGETDIR=" + swap + " /L*vx " + log);
43 testRun("msiexec /quiet /a" + server + "\\sqlrun_rs.msi TARGETDIR=" + swap + " /L*vx " + log);
44 testRun("msiexec /quiet /a" + server + "\\sqlrun_sql.msi TARGETDIR=" + swap + " /L*vx " + log);
45 testRun("msiexec /quiet /a " + swap + "\\sqlrun_as.msi /p " + sp2 + "\\sqlrun_as.msp" + " /L*vx " + log);
46 testRun("msiexec /quiet /a " + swap + "\\sqlrun_dts.msi /p " + sp2 + "\\sqlrun_dts.msp" + " /L*vx " + log);
47 testRun("msiexec /quiet /a " + swap + "\\sqlrun_ns.msi /p " + sp2 + "\\sqlrun_ns.msp" + " /L*vx " + log);
48 testRun("msiexec /quiet /a " + swap + "\\sqlrun_rs.msi /p " + sp2 + "\\sqlrun_rs.msp" + " /L*vx " + log);
49 testRun("msiexec /quiet /a " + swap + "\\sqlrun_sql.msi /p " + sp2 + "\\sqlrun_sql.msp" + " /L*vx " + log);
50 testRun("XCOPY /Y /E " + swap + " " + server);
51 }
52
53 function installTools()
54 {
55 testRun("XCOPY /Y /H " + sp2 + "\\*.msi " + tools);
56 testRun("msiexec /quiet /a" + tools + "\\sqlrun_tools.msi TARGETDIR=" + swap + "2 /L*vx " + log);
57 testRun("msiexec /quiet /a " + swap + "2\\sqlrun_tools.msi /p " + sp2 + "\\sqlrun_tools.msp" + " /L*vx " + log);
58 testRun("XCOPY /Y /E " + swap + "2 " + tools);
59 }
60
61 function testRun(runStr)
62 {
63 var wsh = new ActiveXObject("Wscript.Shell");
64 var sys32 = wsh.ExpandEnvironmentStrings("%WINDIR%\\System32");
65
66 wsh.CurrentDirectory = sys32;
67 var ret = wsh.Run(runStr,0,true);
68 if(ret != 0)fail();
69 return ret;
70 }
71
72 function exec(runStr)
73 {
74 var wsh = new ActiveXObject("Wscript.Shell");
75 var shell = wsh.ExpandEnvironmentStrings("%COMSPEC%");
76 var ret = wsh.Run(shell + " /K " + runStr,0,true);
77 if(ret != 0)fail();
78 wsh.Run(shell + " /K exit",0,true);
79 return ret;
80 }
81
82 function fail()
83 {
84 WScript.Echo("Process fail! Please retry execute this script, Press 'Enter' to exit.");
85 //WScript.StdIn.ReadLine();
86 WScript.Quit();
87 }
88
89 function sucess()
90 {
91 WScript.Echo("Process OK! Press 'Enter' to exit.");
92 //WScript.StdIn.ReadLine();
93 WScript.Quit();
94 }
2 // Slipsteaming MSSQL Server 2005 SP2
3 // Author : Zealic
4 // Date : 2007-03-19
5 // Version : 1.01
6 //
7 // Author : Hollis Yao
8 // Date : 2008-01-15
9 // Version : 2.00
10 /////////////////////////////////////////////////
11 var swap = "D:\\SWAP";
12 var sqldir = "D:\\MSSQL";
13 var sp2 = "D:\\SP2";
14 var server = sqldir + "\\Servers\\Setup";
15 var tools = sqldir + "\\Tools\\Setup";
16 var log = "D:\\install.log";
17
18 install();
19
20 function install()
21 {
22 WScript.Echo("Slipsteaming MSSQL Server 2005 SP2 By Zealic, Playse wait processing");
23 try
24 {
25 installServers();
26 //exec("RD /Q /S " + swap );
27 installTools();
28 sucess();
29 }
30 catch(e)
31 {
32 WScript.Echo(e.name + " : " + e.message);
33 fail();
34 }
35 }
36
37 function installServers()
38 {
39 testRun("XCOPY /Y /H " + sp2 + "\\*.msi " + server);
40 testRun("msiexec /quiet /a" + server + "\\sqlrun_as.msi TARGETDIR=" + swap + " /L*vx " + log);
41 testRun("msiexec /quiet /a" + server + "\\sqlrun_dts.msi TARGETDIR=" + swap + " /L*vx " + log);
42 testRun("msiexec /quiet /a" + server + "\\sqlrun_ns.msi TARGETDIR=" + swap + " /L*vx " + log);
43 testRun("msiexec /quiet /a" + server + "\\sqlrun_rs.msi TARGETDIR=" + swap + " /L*vx " + log);
44 testRun("msiexec /quiet /a" + server + "\\sqlrun_sql.msi TARGETDIR=" + swap + " /L*vx " + log);
45 testRun("msiexec /quiet /a " + swap + "\\sqlrun_as.msi /p " + sp2 + "\\sqlrun_as.msp" + " /L*vx " + log);
46 testRun("msiexec /quiet /a " + swap + "\\sqlrun_dts.msi /p " + sp2 + "\\sqlrun_dts.msp" + " /L*vx " + log);
47 testRun("msiexec /quiet /a " + swap + "\\sqlrun_ns.msi /p " + sp2 + "\\sqlrun_ns.msp" + " /L*vx " + log);
48 testRun("msiexec /quiet /a " + swap + "\\sqlrun_rs.msi /p " + sp2 + "\\sqlrun_rs.msp" + " /L*vx " + log);
49 testRun("msiexec /quiet /a " + swap + "\\sqlrun_sql.msi /p " + sp2 + "\\sqlrun_sql.msp" + " /L*vx " + log);
50 testRun("XCOPY /Y /E " + swap + " " + server);
51 }
52
53 function installTools()
54 {
55 testRun("XCOPY /Y /H " + sp2 + "\\*.msi " + tools);
56 testRun("msiexec /quiet /a" + tools + "\\sqlrun_tools.msi TARGETDIR=" + swap + "2 /L*vx " + log);
57 testRun("msiexec /quiet /a " + swap + "2\\sqlrun_tools.msi /p " + sp2 + "\\sqlrun_tools.msp" + " /L*vx " + log);
58 testRun("XCOPY /Y /E " + swap + "2 " + tools);
59 }
60
61 function testRun(runStr)
62 {
63 var wsh = new ActiveXObject("Wscript.Shell");
64 var sys32 = wsh.ExpandEnvironmentStrings("%WINDIR%\\System32");
65
66 wsh.CurrentDirectory = sys32;
67 var ret = wsh.Run(runStr,0,true);
68 if(ret != 0)fail();
69 return ret;
70 }
71
72 function exec(runStr)
73 {
74 var wsh = new ActiveXObject("Wscript.Shell");
75 var shell = wsh.ExpandEnvironmentStrings("%COMSPEC%");
76 var ret = wsh.Run(shell + " /K " + runStr,0,true);
77 if(ret != 0)fail();
78 wsh.Run(shell + " /K exit",0,true);
79 return ret;
80 }
81
82 function fail()
83 {
84 WScript.Echo("Process fail! Please retry execute this script, Press 'Enter' to exit.");
85 //WScript.StdIn.ReadLine();
86 WScript.Quit();
87 }
88
89 function sucess()
90 {
91 WScript.Echo("Process OK! Press 'Enter' to exit.");
92 //WScript.StdIn.ReadLine();
93 WScript.Quit();
94 }