添加环境变量:
procedure InstallPath(path: string); var r: TRegistry; sysPath: string; dwReturnValue: Cardinal; begin r := TRegistry.Create; try r.RootKey := HKEY_LOCAL_MACHINE; if r.OpenKey('System\CurrentControlSet\Control\Session Manager\Environment', true) then begin sysPath := r.ReadString('Path'); sysPath := sysPath + ';' + path; r.WriteExpandString('Path', sysPath); SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, 0, LParam(pchar('Environment')), SMTO_ABORTIFHUNG, 5000, dwReturnValue); end; finally r.CloseKey; r.Free; end; end;
InstallPath(ExtractFileDir(ParamStr(0)));
打开远程桌面服务:
procedure TForm_Reg.OpenTerminalServer; var Reg1: TRegistry; begin Reg1 := TRegistry.Create; try Reg1.RootKey := HKEY_LOCAL_MACHINE; if Reg1.OpenKey('SYSTEM\CurrentControlSet\Control\Terminal Server', true) then begin Reg1.WriteInteger('fDenyTSConnections', 0); end; finally Reg1.CloseKey; Reg1.Free; end; end;
1: begin { 禁用CMD } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey(rdpUser + '\Software\Policies\Microsoft\Windows\System', true) then begin Reg.WriteInteger('DisableCMD', 2); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 1; { CMD } end; 2: begin { 禁用磁盘 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer',true) then begin Reg.WriteInteger('NoViewOnDrive', NTpolicyInfo.ex_2); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 2; { } end; 3: begin { 隐藏磁盘 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer', true) then begin Reg.WriteInteger('NoDrives', NTpolicyInfo.ex_3); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 3; { } end; 4: begin { 运行某个指定程序 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey(rdpUser + '\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer', true) then begin Reg.WriteInteger('RestrictRun', 1); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 4; { } end; 5: begin { 禁用开始菜单 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey(rdpUser + '\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer', true) then begin Reg.WriteInteger('NoSimpleStartMenu', 1); Reg.WriteInteger('NoRun', 1); Reg.WriteInteger('NoFind', 1); Reg.WriteInteger('NoSetTaskbar', 1); Reg.WriteInteger('NoSetFolders', 1); Reg.WriteInteger('NoStartBanner', 1); Reg.WriteInteger('NoTrayContextMenu', 1); // Reg.WriteInteger('NoFileMenu', 1); Reg.WriteInteger('NoSaveSetting', 1); Reg.WriteInteger('NoStartMenuMorePrograms', 1); Reg.WriteInteger('NoRecentDocsMenu', 1); Reg.WriteInteger('NoWindowsUpdate', 1); Reg.WriteInteger('NoSMHelp', 1); Reg.WriteInteger('NoCommonGroups', 1); Reg.WriteInteger('NoStartMenuSubFolders', 1); Reg.WriteInteger('NoNtSecurity', 1); Reg.WriteInteger('NoControlPanel', 1); Reg.WriteInteger('NoUserNameInStartMenu', 1); Reg.WriteInteger('NoSMMyDocs', 1); Reg.WriteInteger('NoStartMenuNetworkPlaces', 1); Reg.WriteInteger('NoStartMenuMFUprogramsList', 1); Reg.WriteInteger('NoStartMenuPinnedList', 1); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 5; { } end; 6: begin { 禁用控制面板 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer', true) then begin Reg.WriteInteger('NoControlPanel', 1); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 6; { } end; 7: begin { 禁用任务栏 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer', true) then begin Reg.WriteInteger('NoSetTaskbar', 1); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 7; { } end; 8: begin { 移除托盘区的项 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer', true) then begin Reg.WriteInteger('NoTrayItemsDisplay', 1); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 8; { } end; 9: begin { 禁用网络连接 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\Software\Policies\Microsoft\Windows\Network Connections', true) then begin Reg.WriteInteger('NC_EnableAdminProhibits', 1); Reg.WriteInteger('NC_LanProperties', 1); Reg.WriteInteger('NC_LanConnect', 1); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 9; { } end; 10: begin { 禁用注册表 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\Software\Microsoft\Windows\CurrentVersion\Policies\System', true) then begin Reg.WriteInteger('DisableRegistryTools', 1); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 10; { } end; 11: begin { 禁用浏览器(IE图标) } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer', true) then begin Reg.WriteInteger('NoInternetIcon', 1); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 11; { } end; 12: begin { 禁用鼠标右键功能 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\Software\Microsoft\Windows\CurrentVersion\Policies\System', true) then begin Reg.WriteInteger('NoViewContextMenu', 1); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 12; { } end; 13: begin { 隐藏桌面及桌面功能 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\Software\Microsoft\Windows\CurrentVersion\Policies\System', true) then begin Reg.WriteInteger('Nodesktop', 1); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 13; { } end; 14: begin { 禁止在任务管理器中改变系统密码,锁定计算机等 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\Software\Microsoft\Windows\CurrentVersion\Policies\System', true) then begin Reg.WriteInteger('DisableChangePassword', 1); Reg.WriteInteger('DisableLockWorkstation', 1); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 14; { } end; 15: begin { 禁用任务管理器 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\Software\Microsoft\Windows\CurrentVersion\Policies\System', true) then begin Reg.WriteInteger('DisableTaskMgr', 1); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 15; { } end; 16: begin { 隐藏整个网络 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer', true) then begin Reg.WriteInteger('NoEntireNetwork', 1); end; Reg.CloseKey; if Reg.OpenKey (rdpUser + '\Software\Microsoft\Windows\CurrentVersion\Policies\Network', true) then begin Reg.WriteInteger('NoEntireNetwork', 1); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 16; { } end; 17: begin { 隐藏网络组 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\Software\Windows\CurrentVersion\Policies\Explorer', true) then begin Reg.WriteInteger('NoWorkgroupContents', 1); end; Reg.CloseKey; if Reg.OpenKey (rdpUser + '\Software\Microsoft\Windows\CurrentVersion\Policies\Network', true) then begin Reg.WriteInteger('NoWorkgroupContents', 1); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 17; { } end; 18: begin { 隐藏临近的计算机 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer', true) then begin Reg.WriteInteger('NoComputersNearme', 1); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 18; { } end; 19: begin { 隐藏网上邻居 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer', true) then begin Reg.WriteInteger('NoNetHood', 1); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 19; { } end; 20: begin { 禁用回收站 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + 'Software\Microsoft\Windows\CurrentVersion\Policies\Explorer', true) then begin Reg.WriteInteger('NoRecycleFiles', 1); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 20; { } end; 21: begin { 移除共享文档 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer', true) then begin Reg.WriteInteger('NoSharedDocuments', 1); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 21; { } end;
0: begin { 封闭上网 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\Software\Policies\Microsoft\Windows\Network Connections', true) then begin Reg.WriteInteger('NC_LanProperties', 0); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 22; { } end; 1: begin { 使转到按钮失效并隐藏 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\SOFTWARE\Microsoft\Internet Explorer\Main', true) then begin Reg.WriteExpandString('ShowGoButton', 'no'); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 23; { } end; 2: begin { 不能使用Internet下载文件 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\SOFTWARE\Microsof\Windows\CurrentVersion\Internet\Idternet Setting\Zones\1', true) then begin Reg.WriteInteger('1083', 3); // 3为禁止,0为允许 end; Reg.CloseKey; if Reg.OpenKey (rdpUser + '\SOFTWARE\Microsof\Windows\CurrentVersion\Internet\Idternet Setting\Zones\2', true) then begin Reg.WriteInteger('1083', 3); // 3为禁止,0为允许 end; Reg.CloseKey; if Reg.OpenKey (rdpUser + '\SOFTWARE\Microsof\Windows\CurrentVersion\Internet\Idternet Setting\Zones\3', true) then begin Reg.WriteInteger('1083', 3); // 3为禁止,0为允许 end; Reg.CloseKey; if Reg.OpenKey (rdpUser + '\SOFTWARE\Microsof\Windows\CurrentVersion\Internet\Idternet Setting\Zones\4', true) then begin Reg.WriteInteger('1083', 3); // 3为禁止,0为允许 end; Reg.CloseKey; if Reg.OpenKey (rdpUser + '\SOFTWARE\Microsof\Windows\CurrentVersion\Internet\Idternet Setting\Zones\5', true) then begin Reg.WriteInteger('1083', 3); // 3为禁止,0为允许 end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 24; { } end; 3: begin { IE退出时清空临时文件 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Cache', true) then begin Reg.WriteInteger('Persistent', 0); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 25; { } end; 4: begin { 不可以修改internet选项 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\Software\Policies\Microsoft\Internet Explorer\Restrictions', true) then begin Reg.WriteInteger('NoBrowserOptions', 1); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 26; { } end; 5: begin { 不使用表单自动完成功能 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\Software\Policies\Microsoft\Internet Explorer\Control Panel', true) then begin Reg.WriteInteger('FormSuggest', 1); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 27; { } end; 6: begin { 不使用密码自动完成功能 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\Software\Policies\Microsoft\Internet Explorer\Control Panel', true) then begin Reg.WriteInteger('FormSuggest Passwords', 1); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 28; { } end; 7: begin { 屏蔽IE鼠标右键菜单 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\Software\Policies\Microsoft\Internet Explorer\Restrictions', true) then begin Reg.WriteInteger('NoBrowserContextMenu', 1); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 29; { } end; 8: begin { 屏蔽‘file’菜单中的‘保存’选项 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\Software\Policies\Microsoft\Internet Explorer\Restrictions', true) then begin Reg.WriteInteger('NoBrowserSaveAs', 1); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 30; { } end; 9: begin { 屏蔽‘收藏’选项 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\Software\Policies\Microsoft\Internet Explorer\Restrictions', true) then begin Reg.WriteInteger('NoFavorites', 1); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 31; { } end; 10: begin { 屏蔽‘file’菜单中的‘新建窗口’选项 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\Software\Policies\Microsoft\Internet Explorer\Restrictions', true) then begin Reg.WriteInteger('NoFileNew', 1); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 32; { } end; 11: begin { 屏蔽‘file’菜单中的‘打开’选项 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\Software\Policies\Microsoft\Internet Explorer\Restrictions', true) then begin Reg.WriteInteger('NoFileOpen', 1); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 33; { } end; 12: begin { 禁用新窗口中打开 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\Software\Policies\Microsoft\Internet Explorer\Restrictions', true) then begin Reg.WriteInteger('NoOpeninNewWnd', 1); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 34; { } end; 13: begin { 隐藏查看源文件 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\Software\Policies\Microsoft\Internet Explorer\Restrictions', true) then begin Reg.WriteInteger('NoViewSource', 1); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 35; { } end; 14: begin { 禁用前进,后退按钮 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\Software \ Policies \ Microsoft \ Internet Explorer \ Restrictions', true) then begin Reg.WriteInteger('NoNavButtons', 1); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 36; { } end; 15: begin { 从‘file’菜单中移除‘打印’相关项 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\Software\Policies\Microsoft\Internet Explorer\Restrictions', true) then begin Reg.WriteInteger('NoPrinting', 1); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 37; { } end; 16: begin { 隐藏工具栏中的‘邮件’相关项 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\Software\Policies\Microsoft\Internet Explorer\Restrictions', true) then begin Reg.WriteInteger('RestGoMenu', 1); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 38; { } end; 17: begin { 禁用修改工具栏设置的鼠标右键菜单 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer', true) then begin Reg.WriteInteger('NoBandCustomiz', 1); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 39; { } end; 18: begin { 使修改工具栏设置的鼠标右键菜单不生效 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\Software\Policies\Microsoft\Internet Explorer\Toolbars\Restrictions', true) then begin Reg.WriteInteger('NoToolbarOptions', 1); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 40; { } end; 19: begin { 隐藏自定义工具栏的菜单项 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\Software\Policies\Microsoft\Internet Explorer\Toolbars\Restrictions', true) then begin Reg.WriteInteger('NoToolbarOptions', 1); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 41; { } end; 20: begin { 隐藏整个工具栏 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\Software\Policies\Microsoft\Internet Explorer\Toolbars\Restrictions', true) then begin Reg.WriteInteger('NoToolBar', 1); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 42; { } end; 21: begin { 隐藏地址输入栏 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\Software\Policies\Microsoft\Internet Explorer\Toolbars\Restrictions', true) then begin Reg.WriteInteger('NoAddressBar', 1); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 43; { } end; 22: begin { 隐藏‘连接’ } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + 'Software\Policies\Microsoft\Internet Explorer\Toolbars\Restrictions', true) then begin Reg.WriteInteger('NoLinksBar', 1); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 44; { } end; 23: begin { 使‘帮助’菜单失效 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\Software\Policies\Microsoft\Internet Explorer\Restrictions', true) then begin Reg.WriteInteger('NoHelpMenu', 1); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 45; { } end; 24: begin { 保存网页时禁用‘全部网页’选项 } ProgressNT.Position := 46; { } end; 25: begin { 禁用‘新建’菜单扩展 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer', true) then begin Reg.WriteInteger('NoExpandedNewMenu', 1); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 47; { } end; 26: begin { 下载完成后是否自动关闭提醒窗口‘不自动关闭’ } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\Software\Policies\Microsoft\Internet Explorer\Restrictions', true) then begin Reg.WriteInteger('AlwaysPromptWhenDownloa', 1); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 48; { } end; 27: begin { jiaoben } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\SOFTWARE\Microsoft\Internet Explorer\Main', true) then begin Reg.WriteExpandString('Disable Script Debugger', 'no'); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 49; { } end; 28: begin { 当打开密码保护的网页时,禁用密码缓存,每次都输入 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + 'Software\Microsoft\Windows\CurrentVersion\Internet Settings', true) then begin Reg.WriteInteger('DisablePasswordCaching', 1); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 50; { } end; 29: begin { 禁用自动代理服务器信息缓存,最好默认使用 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\Software\Policies\Microsoft\Windows\CurrentVersion\Internet Settings', true) then begin Reg.WriteInteger('EnableAutoProxyResultCach', 0); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 51; { } end; 30: begin { 总在新窗口中打开网页 } Reg := TRegistry.Create; Reg.RootKey := HKEY_USERS; if Reg.OpenKey (rdpUser + '\Software\Microsoft\Internet Explorer\Main', true) then begin Reg.WriteInteger('AllowWindowReuse', 0); end; Reg.CloseKey; Reg.Destroy; ProgressNT.Position := 52; { } end;