Tải bản đầy đủ (.pdf) (8 trang)

Một số điều cần biết về quá trình Sysprep trên Windows 7 – P.2 pdf

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (135.19 KB, 8 trang )


Một số điều cần biết về quá trình Sysprep
trên Windows 7 – P.2
Bên cạnh đó, chúng ta còn có thể sử dụng 1 cách thức khác để thực hiện quá trình này, tuy không
được trình bày cụ thể nhưng đem lại hiệu quả khá cao. Cụ thể, trên máy tính chúng ta thực hiện
quá trình tạo file image, các bạn hãy mở thư mục C:\Windows\Steup, tạo mới 1 thư mục khác
đặt tên là Scripts tại đây. Bên trong đó, chúng ta tạo tiếp 1 file SetupComplete.cmd – có chức
năng tự khởi động trước lúc màn hình đăng nhập của Windows bắt đầu. Và đây cũng chính là
bước tài khoản TempUser bị xóa.
Để xóa tài khoản TempUser này, các bạn hãy thêm lệnh sau vào SetupComplete.cmd:
net user TempUser /delete
Và kích hoạt tài khoản Administrator bằng lệnh:
net user Administrator /active:yes
Mặc dù có thể bạn đã kích hoạt tài khoản Administrator trên máy tính được dùng để tạo image
trước khi sử dụng sysprep, thì tài khoản đó vẫn bị tắt. Để xóa file unattend.xml file, các bạn thêm
dòng mã sau vào file SetupComplete.cmd:
del C:\Windows\System32\Sysprep\unattend.xml
Mặt khác, mật khẩu của người sử dụng sau khi khai báo trong file xml đã được mã hóa, nhưng về
bản chất thì file đó không tồn tại trong quá trình này. Mặt khác, người sử dụng có thể điều chỉnh
file answer dựa theo nhu cầu. Sau khi hoàn tất file unattend.xml, hãy copy tới thư mục
C:\Windows\System32\Sysprep, và chúng ta đã sẵn sàng để chạy sysprep trên máy tính. Bên
trong phần profile vừa được khởi tạo, các bạn hãy sử dụng Command Prompt, trỏ tới thư mục
C:\Windows\System32\Sysprep và gõ lệnh dưới đây:
mysysprep.exe \generalize \oobe \shutdown
\unattend:unattend.xml
Máy tính sẽ tự tắt sau khi sysprep hoàn tất. Và đây cũng là thời điểm tạo image của ổ cứng, mỗi
người đều có cách riêng để hoàn thiện việc này. Tại bài thử nghiệm này, chúng tôi dùng tiện ích
Norton Ghost, và kết quả là có 2 phân vùng, C của hệ điều hành và D là phần chứa dữ liệu của
người dùng. Quá trình tiếp theo, áp dụng file image ngược trở lại vào máy tính, chúng ta sẽ được
thông báo khởi tạo tên máy tính và domain. Phần Domain Name sẽ tự động hiển thị sau khi hoàn
tất:


<JoinDomain>%Please select a domain to
join{your.domain.com}%</JoinDomain>
Còn trong trường hợp hệ thống có nhiều domain, thì chúng ta sẽ sử dụng cấu trúc menu
dropdown tại bước này:
<JoinDomain>%Please select a domain to
join{domain1;domain2;domain3}%</JoinDomain>
Máy tính sẽ hoàn tất quá trình cài đặt và có thể tiếp tục với màn hình boot Welcome quen thuộc.
Khi tất cả các bước thành công, chúng ta có thể đăng nhập bằng tài khoản domain.
Một số vấn đề thường gặp và cách giải quyết:
Sau khi hoàn tất bước xóa file unattend.xml, chúng ta cần đảm bảo rằng toàn bộ phần cứng của
hệ thống vẫn hoạt động ổn định khi sử dụng sysprep:
<PersistAllDeviceInstalls>true</PersistAllDeviceInstalls>
Khi chúng ta thiết lập giá trị True tại bước này, các thiết bị Plug and Play sẽ được cài đặt đầy đủ
driver trên máy tính áp dụng file image. Và các thiết bị phần cứng này không cần thiết phải cài
đặt lại trong quá trình tự tạo và cấu hình, những thông tin này sẽ được lưu trữ vào phần:
x86_Microsoft-Windows-PnpSysprep.
Tự tạo thông số sử dụng mức năng lượng trong file image và khởi tạo phần thông số này trong
file unattend.xml, cụ thể trong phần Control Panel > Power Options. Khi muốn thực hiện quá
trình này, chúng ta sẽ cần đến thông số GUID, và để tìm được phần thông số này thì phải dùng
lệnh sau trong Command Prompt:
PowerCfg -List
và tìm trong đó phần plan vừa tạo. Việc cuối cùng là gán tham số GUID này vào file
unattend.xml để trở thành mức sử dụng và tiêu thụ năng lượng mặc định trong hệ thống, các
thông tin này sẽ được lưu trữ trong phần x86_Microsoft-Windows-powercpl__neutral.
Phân chia ổ đĩa thành DriverStore trong file image, chúng ta có thể sử dụng tiện ích pnputil.exe.
Cụ thể, trong trường hợp hệ thống đã có sẵn driver của 1 thiết bị ngoại vi nào đó như máy in
hoặc scan, chúng ta không muốn các tài khoản người dùng khác nhận thông báo mỗi khi cài đặt
driver, chúng ta sẽ gán các thông số này vào DriverStore trong file image của Windows. Ví dụ:
pnputil.exe -a HP0001.inf. Để tìm hiểu rõ hơn về cú pháp này, các bạn hãy tham khảo bài
hướng dẫn trực tiếp từ Microsoft tại đây.

Để tắt bỏ chức năng thông báo của Action Center: Set backup, chúng ta sẽ tạo mới 1 file
DisableBackupMonitoring.reg bằng Notepad và sử dụng đoạn mã bên dưới đây:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersio
n\WindowsBackup]
"DisableMonitoring"=dword:00000001
Dưới đây là 1 đoạn mã được dùng để xóa bỏ các shortcut mặc định trên thanh taskbar khi người
dùng đăng nhập vào hệ thống lần đầu tiên. Các bạn có thể tham khảo thêm về đoạn mã này tại
đây, về mặt kỹ thuật thì file script này sẽ được copy tới thư mục
C:\Windows\System32\Sysprep\Custom qua 1 file batch được thay thế trong phần startup của
profile người sử dụng. Sau đó, file batch sẽ tự động xóa bỏ và quá trình trên chỉ xảy ra trong lần
đăng nhập đầu tiên của người dùng:
1 Option Explicit
2
3 Const CSIDL_STARTMENU = &HB
4 Const CSIDL_COMMON_PROGRAMS = &H17
5
6 Dim objShell, objFSO
7 Dim objCurrentUserStartFolder
8 Dim strCurrentUserStartFolderPath
9 Dim objAllUsersProgramsFolder
10 Dim strAllUsersProgramsPath
11 Dim objFolder
12 Dim objFolderItem
13 Dim colVerbs
14 Dim objVerb
15
16 Set objShell = CreateObject("Shell.Application")
17 Set objFSO = CreateObject("Scripting.FileSystemObject")
18

19 Set objCurrentUserStartFolder = objShell.NameSpace
(CSIDL_STARTMENU)
20 strCurrentUserStartFolderPath =
objCurrentUserStartFolder.Self.Path
21
22 Set objAllUsersProgramsFolder =
objShell.NameSpace(CSIDL_COMMON_PROGRAMS)
23 strAllUsersProgramsPath =
objAllUsersProgramsFolder.Self.Path
24
25 '''''''''''''''''''''''''''''''''''''''Unpin
Shortcuts'''''''''''''''''''''''''''''''''''''''
26
27 '*** All Users Shortcuts ****
28
29 'Internet Explorer
30 If objFSO.FileExists(strAllUsersProgramsPath & "\Network
& Internet\Microsoft\Internet Explorer.lnk") Then
31 Set objFolder =
objShell.Namespace(strAllUsersProgramsPath & "\Network &
Internet\Microsoft")
32 Set objFolderItem = objFolder.ParseName("Internet
Explorer.lnk")
33 Set colVerbs = objFolderItem.Verbs
34 For Each objVerb In colVerbs
35 If Replace(objVerb.name, "&", "") =
"Unpin from Taskbar" Then objVerb.DoIt
36 Next
37 End If
38

39 'Mozilla Firefox
40 If objFSO.FileExists(strAllUsersProgramsPath & "\Network
& Internet\Mozilla Firefox\Mozilla Firefox.lnk") Then
41 Set objFolder =
objShell.Namespace(strAllUsersProgramsPath & "\Network &
Internet\Mozilla Firefox")
42 Set objFolderItem = objFolder.ParseName("Mozilla
Firefox.lnk")
43 Set colVerbs = objFolderItem.Verbs
44 For Each objVerb In colVerbs
45 If Replace(objVerb.name, "&", "") =
"Unpin from Taskbar" Then objVerb.DoIt
46 Next
47 End If
48
49 'Windows Explorer
50 If objFSO.FileExists(strAllUsersProgramsPath &
"\Accessories\Windows Explorer.lnk") Then
51 Set objFolder =
objShell.Namespace(strAllUsersProgramsPath & "\Accessories")
52 Set objFolderItem = objFolder.ParseName("Windows
Explorer.lnk")
53 Set colVerbs = objFolderItem.Verbs
54 For Each objVerb In colVerbs
55 If Replace(objVerb.name, "&", "") =
"Unpin from Taskbar" Then objVerb.DoIt
56 Next
57 End If
58
59 'Windows Media Player

60 If objFSO.FileExists(strAllUsersProgramsPath & "\Network
& Internet\Microsoft\Windows Media Player.lnk") Then
61 Set objFolder =
objShell.Namespace(strAllUsersProgramsPath & "\Network &
Internet\Microsoft")
62 Set objFolderItem = objFolder.ParseName("Windows
Media Player.lnk")
63 Set colVerbs = objFolderItem.Verbs
64 For Each objVerb In colVerbs
65 If Replace(objVerb.name, "&", "") =
"Unpin from Taskbar" Then objVerb.DoIt
66 Next
67 End If
68
69 '*** Current Users Shortcuts ****
70
71 'Internet Explorer
72 If objFSO.FileExists(strCurrentUserStartFolderPath &
"\Programs\Internet Explorer.lnk") Then
73 Set objFolder =
objShell.Namespace(strCurrentUserStartFolderPath &
"\Programs")
74 Set objFolderItem = objFolder.ParseName("Internet
Explorer.lnk")
75 Set colVerbs = objFolderItem.Verbs
76 For Each objVerb In colVerbs
77 If Replace(objVerb.name, "&", "") =
"Unpin from Taskbar" Then objVerb.DoIt
78 Next
79 End If

80
81 'Mozilla Firefox
82 If objFSO.FileExists(strCurrentUserStartFolderPath &
"\Programs\Mozilla Firefox\Mozilla Firefox.lnk") Then
83 Set objFolder =
objShell.Namespace(strCurrentUserStartFolderPath &
"\Programs\Mozilla Firefox")
84 Set objFolderItem = objFolder.ParseName("Mozilla
Firefox.lnk")
85 Set colVerbs = objFolderItem.Verbs
86 For Each objVerb In colVerbs
87 If Replace(objVerb.name, "&", "") =
"Unpin from Taskbar" Then objVerb.DoIt
88 Next
89 End If
90
91 'Windows Explorer
92 If objFSO.FileExists(strCurrentUserStartFolderPath &
"\Programs\Accessories\Windows Explorer.lnk") Then
93 Set objFolder =
objShell.Namespace(strCurrentUserStartFolderPath &
"\Programs\Accessories")
94 Set objFolderItem = objFolder.ParseName("Windows
Explorer.lnk")
95 Set colVerbs = objFolderItem.Verbs
96 For Each objVerb In colVerbs
97 If Replace(objVerb.name, "&", "") =
"Unpin from Taskbar" Then objVerb.DoIt
98 Next
99 End If

100
101 'Windows Media Player
102 If objFSO.FileExists(strCurrentUserStartFolderPath &
"\Programs\Windows Media Player.lnk") Then
103 Set objFolder =
objShell.Namespace(strCurrentUserStartFolderPath &
"\Programs")
104 Set objFolderItem = objFolder.ParseName("Windows
Media Player.lnk")
105 Set colVerbs = objFolderItem.Verbs
106 For Each objVerb In colVerbs
107 If Replace(objVerb.name, "&", "") =
"Unpin from Taskbar" Then objVerb.DoIt
108 Next
109 End If
110
111
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''
112
113 ''''''''''''''''''''''''''''''''''''''''Pin
Shortcuts''''''''''''''''''''''''''''''''''''''''
114
115 'Internet Explorer - All Users
116 If objFSO.FileExists(strAllUsersProgramsPath & "\Network
& Internet\Microsoft\Internet Explorer.lnk") Then
117 Set objFolder =
objShell.Namespace(strAllUsersProgramsPath & "\Network &
Internet\Microsoft")
118 Set objFolderItem =

objFolder.ParseName("Internet Explorer.lnk")
119 Set colVerbs = objFolderItem.Verbs
120 For Each objVerb In colVerbs
121 If Replace(objVerb.name, "&", "") = "Pin
to Taskbar" Then objVerb.DoIt
122 Next
123 End If
124
125 'Mozilla Firefox - All Users
126 If objFSO.FileExists(strAllUsersProgramsPath & "\Network
& Internet\Mozilla Firefox\Mozilla Firefox.lnk") Then
127 Set objFolder =
objShell.Namespace(strAllUsersProgramsPath & "\Network &
Internet\Mozilla Firefox")
128 Set objFolderItem = objFolder.ParseName("Mozilla
Firefox.lnk")
129 Set colVerbs = objFolderItem.Verbs
130 For Each objVerb In colVerbs
131 If Replace(objVerb.name, "&", "") = "Pin
to Taskbar" Then objVerb.DoIt
132 Next
133 End If
134
135 'Windows Explorer - Current User
136 If objFSO.FileExists(strCurrentUserStartFolderPath &
"\Programs\Accessories\Windows Explorer.lnk") Then
137 Set objFolder =
objShell.Namespace(strCurrentUserStartFolderPath &
"\Programs\Accessories")
138 Set objFolderItem = objFolder.ParseName("Windows

Explorer.lnk")
139 Set colVerbs = objFolderItem.Verbs
140 For Each objVerb In colVerbs
141 If Replace(objVerb.name, "&", "") = "Pin
to Taskbar" Then objVerb.DoIt
142 Next
143 End If
144
145
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''
Sau khi thiết lập phần Network Location trong file unattend.xml, nhưng người dùng vẫn nhận
được thông tin cảnh báo trong lần đăng nhập đầu tiên, hãy cài đặt bản hotfix sau trên máy tính sử
dụng để làm image:
Địa chỉ homepage của IE bị reset sau khi sử dụng sysprep: khắc phục bằng cách gán thiết lập
riêng của IE vào file unattend.xml trong phần x86_Microsoft-Windows-IE-
InternetExplorer__neutral_31bf3856ad364e35_nonSxS.
Người sử dụng bị mất phần theme Aero sau khi dùng sysprep: sử dụng lệnh sau trong phần
Command Prompt:
WinSAT prepop
Quá trình trên sẽ tạo file WinSAT prepop .xml và lưu trữ trong thu mục
%WINDIR%\performance\winsat\datastore, đồng thời cho phép người sử dụng giữ nguyên
các thiết lập về theme sau khi dùng sysprep.
Chúc các bạn thành công!


×