If @OSArch = 'X64' And @OSVersion = 'WIN_10' Then
;默认禁止自动排列图标并将图标与网格对齐(桌面状态下导入生效针对系统优化程序在登录段导入无效)
RegWrite('HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Bags\1\Desktop', 'FFlags', 'REG_DWORD', '0x40200224')
;禁止图标锁定在任务栏
RegWrite('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband', 'Favorites', 'REG_BINARY', '0xff')
Local $iPid = ProcessExists('explorer.exe')
If $iPid Then ProcessClose($iPid)
If Not ProcessExists('explorer.exe') Then Run(@WindowsDir & '\explorer.exe')
;-----------------------------------------------
;若已移除Edge封包则删除桌面Microsoft Edge快捷方式残留(奇怪@Desktop会删除导航窗格主文件夹下的桌面)
;If Not FileExists(@WindowsDir & '\SystemApps\Microsoft.MicrosoftEdgeDevToolsClient_8wekyb3d8bbwe') Then FileDelete(@Desktopdir & '\Microsoft Edge.lnk')
;---------------------------------------------------------
;启用Aero主题
If FileExists(@WindowsDir & '\Resources\Themes\Win7 Aero.theme') Then
ShellExecute(@WindowsDir & '\Resources\Themes\Win7 Aero.theme', '', @SW_HIDE)
Dim $i
While 1
If WinWaitActive('设置','',1) Then
ProcessClose('SystemSettings.exe')
ExitLoop
EndIf
$i+=1
If $i > 10 Then ExitLoop
sleep(1000)
WEnd
EndIf
;---------------------------------------------------------
Send ("{F5}");==>桌面右键刷新(刷新处理后的桌面图标排列)
;---------------------------------------------------------
;删除首次进桌面后调用的程序
RegDelete('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run')
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run')
;-------------------------------------------------------------------------------------------------------
;判断计算机类型并打开数字小键盘
$strComputer = "."
$objWMIService = ObjGet('winmgmts:{impersonationLevel=impersonate}!\\' & $strComputer & "\root\cimv2")
$colChassis = $objWMIService.ExecQuery("Select * from Win32_SystemEnclosure")
For $objChassis in $colChassis
For $strChassisType in $objChassis.ChassisTypes
if $strChassisType = 8 or $strChassisType = 9 or $strChassisType = 10 then Send('{NUMLOCK OFF}') ;笔记本
if $strChassisType = 3 or $strChassisType = 4 or $strChassisType = 5 or $strChassisType = 6 or $strChassisType = 7 then Send('{NUMLOCK ON}') ;台式机
Next
next
;-------------------------------------------------------------------------------------------------------
;OneDrive卸载程序
If FileExists(@WindowsDir & '\SysWOW64\OneDriveSetup.exe') Then
ProgressOn('OneDrive卸载程序','')
ProgressSet(30,'卸载进行中请稍后.......','')
ProcessClose('OneDrive.exe')
RunWait(@ComSpec & ' /c ' & '"%SYSTEMROOT%\SysWOW64\OneDriveSetup.exe" /uninstall', '', @SW_HIDE)
RunWait(@ComSpec & ' /c ' & '@echo y|takeown /f "%SYSTEMROOT%\SysWOW64\OneDriveSetup.exe" & @echo y|icacls "%SYSTEMROOT%\SysWOW64\OneDriveSetup.exe" /grant administrators:F','',@SW_HIDE)
RunWait(@ComSpec & ' /c ' & 'ren "%SYSTEMROOT%\SysWOW64\OneDriveSetup.exe" "OneDriveSetup.bak"& del /q/a/s/f "%SYSTEMROOT%\SysWOW64\OneDriveSetup.bak"','',@SW_HIDE)
RunWait(@ComSpec & ' /c ' & 'del /q/a/s/f "%SYSTEMROOT%\SysWOW64\OneDriveSettingSyncProvider.dll"&del /q/a/s/f "%SYSTEMROOT%\System32\OneDriveSettingSyncProvider.dll"','',@SW_HIDE)
RunWait(@ComSpec & ' /c ' & '@echo y|takeown /f "%USERPROFILE%\AppData\Local\Microsoft\OneDrive\*.*" /r &@echo y|icacls "%USERPROFILE%\AppData\Local\Microsoft\OneDrive\*.*" /T /grant administrators:F','',@SW_HIDE)
RunWait(@ComSpec & ' /c ' & 'rd /q/s "%USERPROFILE%\AppData\Local\Microsoft\OneDrive" ','',@SW_HIDE)
RunWait(@ComSpec & ' /c ' & 'rd /q/s "%USERPROFILE%\OneDrive" & rd /q/s "%ProgramData%\Microsoft OneDrive"','',@SW_HIDE)
RunWait(@ComSpec & ' /c ' & 'del /q/a/s/f "%USERPROFILE%\Links\OneDrive.lnk"', '', @SW_HIDE)
RunWait(@ComSpec & ' /c ' & 'del /q/a/s/f "%AppData%\Microsoft\Windows\Start Menu\Programs\OneDrive.lnk"','',@SW_HIDE)
RegDelete('HKEY_CLASSES_ROOT\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}')
RegDelete('HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}')
RegDelete('HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Run', 'OneDrive')
ProgressSet(70,'')
Sleep (500)
ProgressSet(100,'卸载完毕')
Sleep (500)
ProgressOff()
EndIf
;--------------------------------------------------------------------------------------------------------------------
If FileExists ('D:\') Then
$Flag = MsgBox(1+64,'我的文档转移程序','是否转移我的文档到D盘?'&@CRLF&@CRLF&'默认5秒之后自动转移',5)
If $Flag > 1 Then
MsgBox(0,'退出提示:','你没有转移我的文档',1)
Else
ProgressOn('','')
ProgressSet(30,'文件处理中请稍后.......','')
;注入注册表路径
RegWrite('HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders')
RegWrite('HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders', '{374DE290-123F-4565-9164-39C4925E467B}', 'REG_SZ', 'D:\Downloads')
RegWrite('HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders', 'Desktop', 'REG_SZ', 'D:\Documents\Desktop')
RegWrite('HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders', 'Favorites', 'REG_SZ', 'D:\Documents\Favorites')
RegWrite('HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders', 'Personal', 'REG_SZ', 'D:\Documents')
RegWrite('HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders', 'My Music', 'REG_SZ', 'D:\Documents\Music')
RegWrite('HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders', 'My Pictures', 'REG_SZ', 'D:\Documents\Pictures')
RegWrite('HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders', 'My Video', 'REG_SZ', 'D:\Documents\Videos')
RegWrite('HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders')
RegWrite('HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders', '{0DDD015D-B06C-45D5-8C4C-F59713854639}', 'REG_SZ', 'D:\Documents\Pictures')
RegWrite('HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders', '{35286A68-3C57-41A1-BBB1-0EAE73D76C95}', 'REG_SZ', 'D:\Documents\Videos')
RegWrite('HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders', '{374DE290-123F-4565-9164-39C4925E467B}', 'REG_SZ', 'D:\Downloads')
RegWrite('HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders', '{754AC886-DF64-4CBA-86B5-F7FBF4FBCEF5}', 'REG_SZ', 'D:\Documents\Desktop')
RegWrite('HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders', '{7D83EE9B-2244-4E70-B1F5-5393042AF1E4}', 'REG_SZ', 'D:\Downloads')
RegWrite('HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders', '{A0C69A99-21C8-4671-8703-7934162FCF1D}', 'REG_SZ', 'D:\Documents\Music')
RegWrite('HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders', '{F42EE2D3-909F-4907-8871-4C22FC0BF756}', 'REG_SZ', 'D:\Documents')
RegWrite('HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders', 'Desktop', 'REG_SZ', 'D:\Documents\Desktop')
RegWrite('HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders', 'Favorites', 'REG_SZ', 'D:\Documents\Favorites')
RegWrite('HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders', 'Personal', 'REG_SZ', 'D:\Documents')
RegWrite('HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders', 'My Music', 'REG_SZ', 'D:\Documents\Music')
RegWrite('HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders', 'My Pictures', 'REG_SZ', 'D:\Documents\Pictures')
RegWrite('HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders', 'My Video', 'REG_SZ', 'D:\Documents\Videos')
Local $iPid = ProcessExists('explorer.exe');刷新资源管理器使注册表生效防止接下调用程序释放快捷方式到桌面出现找不到系统默认桌面-针对XP
If $iPid Then ProcessClose($iPid)
If Not ProcessExists('explorer.exe') Then Run(@WindowsDir & '\explorer.exe')
;移动文件夹到D盘(由于和复制进度条冲突,首次安装系统进入桌面就用最简化)
DirMove(@UserProfileDir & '\Downloads','D:\',1)
DirMove(@UserProfileDir & '\Documents','D:\',1)
;DirMove(@UserProfileDir & '\Desktop','D:\Documents\',1)用两批处理代替防止出现此命令运行后导致快速访问里面桌面消失
RunWait(@ComSpec & ' /c ' & '@echo y|takeown /f "%USERPROFILE%\Desktop" /r>nul ', '', @SW_HIDE)
RunWait(@ComSpec & ' /c ' & '@echo y|icacls "%USERPROFILE%\Desktop" /q /c /t /grant administrators:f>nul', '', @SW_HIDE)
RunWait(@ComSpec & ' /c ' & 'xcopy /e/i/y "%USERPROFILE%\Desktop" "D:\Documents\Desktop" ', '', @SW_HIDE)
RunWait(@ComSpec & ' /c ' & 'rd /q/s "%USERPROFILE%\Desktop"', '', @SW_HIDE)
DirMove(@UserProfileDir & '\Music','D:\Documents\',1)
DirMove(@UserProfileDir & '\Favorites','D:\Documents\',1)
DirMove(@UserProfileDir & '\Videos','D:\Documents\',1)
DirMove(@UserProfileDir & '\Pictures','D:\Documents\',1)
;运行我的文档自解压包覆盖防止图标异常
FileInstall('相关调用\10Documents.exe',@TempDir&'\', 1)
Runwait(@TempDir&'\10Documents.exe','', @SW_HIDE)
FileDelete(@TempDir&'\10Documents.exe')
;删除移动到D盘产生的收藏夹栏
DirRemove(@FavoritesDir & '\Links',1)
DirRemove(@UserProfileDir & '\3D Objects',1)
ProgressSet(100,'处理完毕')
ProgressOff();全体工作注销后生效
EndIf
EndIf
;--------------------------------------------------------------------------------------------------------------------
;安装装机软件
If FileExists (@HomeDrive & '\SoftWareFiles') Then
RunWait(@HomeDrive & '\SoftWareFiles\AutoInstall_x64.exe')
RunWait(@ComSpec & ' /c ' & 'for /d %i in ("%HomeDrive%\SoftWareFiles") do rd /q/s %i>nul', '', @SW_HIDE)
EndIf
;--------------------------------------------------------------------------------------------------------------------
;关闭输入指示解决Win10右下角图标乱动乱跳
Local $ver = RegRead('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion','ProductName')
Switch $ver
Case 'Windows 10 Enterprise 2016 LTSB'
;Ltsb默认关闭
Case Else
MSgbox(0,'关闭输入指示解决右下角图标乱动乱跳','点击 任务栏设置 - 通知区域 - 打开或关闭系统图标 - 输入指示'&@CRLF&@CRLF&'按确定后关闭输入指示!');注销生效 (重启无效)
Run(@ComSpec & ' /c ' & 'control.exe /name Microsoft.TaskbarAndStartMenu', '', @SW_HIDE)
sleep(3000)
Dim $i
While 1
If Not ProcessExists('SystemSettings.exe') Then ExitLoop
$i+=1
If $i > 120 Then ExitLoop
sleep(1000)
WEnd
EndSwitch
;--------------------------------------------------------------------------------------------------------------------
;关闭防火墙但不关闭MpsSvc服务去掉Windows安全中心警告提示(防止首次部署系统优化后重启加载某些原因导致失效)
RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\SharedAccess\Parameters\FirewallPolicy\PublicProfile', 'EnableFirewall', 'REG_DWORD', '0x00000000')
RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\services\SharedAccess\Parameters\FirewallPolicy\StandardProfile', 'EnableFirewall', 'REG_DWORD', '0x00000000')
;--------------------------------------------------------------------------------------------------------------------
;解决21h2-22h2AeroTheme每次登录需要右键刷新一下桌面
Local $ver = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion","CurrentBuild")
Switch $ver
Case '19044','19045'
RegWrite('HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run', 'Start', 'REG_SZ', '' & @SystemDir & '\AutoRefresh.exe')
FileInstall('相关调用\AutoRefresh.exe',@SystemDir & '\', 1 )
Case Else
MsgBox(0,'','当前系统版本非21h2或22h2',1)
EndSwitch
;--------------------------------------------------------------------------------------------------------------------
ProgressOn('提示:即将注销计算机以使设置生效!','')
ProgressSet(50,'','')
RunWait('cmd.exe /c rd /q/s %Temp%&md %Temp%','',@SW_HIDE) ;清空临时文件夹
ProgressSet(100,'正在注销!')
Sleep(500)
ProgressOff()
Run(@ComSpec&' /c ping 127.0.0.1 -n 5&del /q "'&@AutoItExe&'"&shutdown -f -l',@ScriptDir,@SW_HIDE);==>注销并自删除防止我的文档转移后注册表异常
;--------------------------------------------------------------------------------------------------------------------
Else
MsgBox('','注意:','请在Windows 10 x64下运行')
EndIf
代码是部署系统首次进入桌面调用、一下单独Run(@ComSpec&' /c ping 127.0.0.1 -n 5&del /q "'&@AutoItExe&'"&shutdown -f -l',@ScriptDir,@SW_HIDE)编译运行是正常的。总感觉莫名其妙