SolidWorks2022sp5元旦特供绿色版
SolidWorks的安装特别麻烦,我在几个精简版的系统里居然装不出来,比如在有.NET4.8的环境下会出现安装错误等。所以制作了这个绿色版,做完过后才得到提醒,网上已经有人做出了2023的绿色版,早知道我就不做了,真的很花时间。以前也制作过绿色版2019和2020,感觉现在已经落后。在朋友提醒下抽时间来制作了这个SolidWorks2022sp5绿色版。
安装时除了主程序和语言,只选择simulation和motion这两个选项,在不忘初心的深度精简WIN10x64系统下制作,在坏坏小生LTSB2016WIN10x64下未安装.net4.8测试可以正常进入,测试其他精简版WIN11、原版WIN11也能正常安装和进入。
绿化前必须先安装VC库和.net4.8环境,虽然我在没有net4.8环境也可以正常进入,但软件自身要求了必须安装net4.8环境,以免一些功能无法使用。压缩包解压在任意位置,进入文件夹,运行最后一个VBS:双击静默安装.vbs,在I5 9400电脑上接近30秒完成绿化出现桌面图标。第一次进系统时会有一个许可提示,再次进入后不会再出现。如需更改位置,可卸载重启后移动或更名文件夹重新再次运行安装程序。在火绒下安装没什么问题,但如果是360还是建议关闭掉再安装。
针对程序连网的情况,使用防火墙安全策略,把所有程序EXE可执行程序都禁止连网,不确定是否会影响一些功能,需要的自行把以下内容复制粘贴到安装的VBS中替换以前内容:
Dim WshShell,objFSO,ver,ie,reg,windir,srv_dict,firewall_dict,objWMIService,Shell,obj(),objRegistry
Set WshShell=WScript.CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWMIService = GetObject("winmgmts:\\.")
Set Shell=CreateObject("Shell.Application")
Set srv_dict=CreateObject("Scripting.Dictionary") '需调整的服务
Set firewall_dict=CreateObject("Scripting.Dictionary")'需禁止接连网络的程序
Set objRegistry=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
Set objWMI = GetObject("Winmgmts:\\.\Root\Cimv2")
Set firewall_dict=CreateObject("Scripting.Dictionary")
Set colOperatingSystems = objWMIService.InstancesOf("Win32_OperatingSystem")
If WScript.Arguments.length = 0 Then
Shell.ShellExecute "wscript.exe", Chr(34) & WScript.ScriptFullName & Chr(34) & " uac", "", "runas", 1
WScript.quit
End If
my_dir=left(wscript.scriptfullname,instrrev(wscript.scriptfullname,"")-1) '& "" '找到程序所在目录
For Each objOperatingSystem In colOperatingSystems
windir=objOperatingSystem.WindowsDirectory
Next
prog_dir=WshShell.ExpandEnvironmentStrings("%ProgramFiles%")
prog86_dir=WshShell.ExpandEnvironmentStrings("%ProgramFiles(x86)%")
user_dir=WshShell.ExpandEnvironmentStrings("%USERPROFILE%")
pub_dir=WshShell.ExpandEnvironmentStrings("%PUBLIC%")
data_dir=WshShell.ExpandEnvironmentStrings("%ProgramData%")
Set tmp1 = objFSO.OpenTextFile(my_dir & "\setup.reg", 1) '读入旧的文件
tmp2=tmp1.ReadAll:tmp1.close
del my_dir & "\安装修改.reg"
if my_dir<>"D:\Program Files\SOLIDWORKS Corp" then
tmp2=replace(tmp2,"D:\Program Files\SOLIDWORKS Corp\SOLIDWORKS",my_dir)
bingpath=replace(my_dir,"","\")
tmp2=replace(tmp2,"D:\\Program Files\\SOLIDWORKS Corp\\SOLIDWORKS",bingpath)
bingpath=replace(my_dir,"","/")
tmp2=replace(tmp2,"D:/Program Files/SOLIDWORKS Corp/SOLIDWORKS",bingpath)
end if
'"Toolbox Data Location"="d:\\Program Files\\SOLIDWORKS Corp\\SOLIDWORKS Data\"
'bingpath="""Toolbox Data Location""=""D:\\Program Files\\SOLIDWORKS Corp\\SOLIDWORKS Data"""
'tmp3="""Toolbox Data Location""=" & chr(34) & replace(my_dir,"","\") & chr(34)
'tmp2=replace(tmp2,bingpath,tmp3)'单独替换ToolBox路径
if windir<>"C:\\Windows" then
tmp2=replace(tmp2,"C:\\Windows",replace(windir,"","\"))
tmp2=replace(tmp2,"C:/Windows",replace(windir,"","/"))
end if
move_dir my_dir & "\Windows", windir
bingpath=replace(prog_dir,"","\")
if bingpath<>"C:\\Program Files" then
tmp2=replace(tmp2,"C:\\Program Files",bingpath)
tmp3=UCase(left(bingpath,2))
if tmp3<>"C:" then tmp2=replace(tmp2,"C:\\PROGRA",tmp3 & "\\PROGRA")
end if
move_dir my_dir & "\Program Files", prog_dir
move_dir my_dir & "\Program Files (x86)", prog86_dir
move_dir my_dir & "\AppData", user_dir
if user_dir<>"C:\Users\AppData" then
tmp2=replace(tmp2,"C:\\Users\\AppData",replace(user_dir,"","\"))
end if
bingpath=replace(pub_dir,"","\")
if bingpath<>"C:\Users\Public" then
tmp2=replace(tmp2,"C:\\Users\\Public",bingpath)
end if
bingpath=replace(data_dir,"","\")
if bingpath<>"C:\\ProgramData" then tmp2=replace(tmp2,"C:\\ProgramData",bingpath)
move_dir my_dir & "\ProgramData", bingpath'"C:\\ProgramData"
Set tmp1=objFSO.OpenTextFile(my_dir & "\安装修改.reg",8,True,0)
tmp1.Write tmp2:tmp1.close:set tmp1=nothing
ins= "regedit /s " & chr(34) & my_dir & "\安装修改.reg" & chr(34)
WshShell.Run ins,1,true ' 调入注册表
'为保证成功,正在尝试停止以前安装错误的服务...
Close_Process("net.exe") '关闭程序
Close_Process("sc.exe") '关闭程序
'尝试删除之前装错的服务...
WshShell.Run "net.exe stop " & chr(34) & "SolidWorks Flexnet Server" & chr(34),0,true
Wait("net.exe")
WshShell.Run "sc.exe delete " & chr(34) & "SolidWorks Flexnet Server" & chr(34),0,true
Wait("sc.exe")
WshShell.Run "net.exe stop " & chr(34) & "WFlexNet Licensing Service 64" & chr(34),0,true
Wait("net.exe")
WshShell.Run "sc.exe delete " & chr(34) & "WFlexNet Licensing Service 64" & chr(34),0,true
Wait("sc.exe")
WshShell.Run "net.exe stop " & chr(34) & "SolidWorks Licensing Service" & chr(34),0,true
Wait("net.exe")
WshShell.Run "sc.exe delete " & chr(34) & "SolidWorks Licensing Service" & chr(34),0,true
Wait("sc.exe")
'重新安装服务
ins=my_dir & "\SolidWorks_Flexnet_Server"
ins=chr(34) & ins & "installs.exe" & chr(34) & " -c " & chr(34) & ins & "sw_d_SSQ.lic" & chr(34) & " -e " & chr(34) & ins & "lmgrd.exe" & chr(34) & " -l " & chr(34) & ins & "sw_d_SSQ.log" & chr(34) & " -n " & chr(34) & "SolidWorks Flexnet Server" & chr(34)
WshShell.Run ins,0,true
'启动服务
WshShell.Run "net.exe start " & chr(34) & "SolidWorks Flexnet Server" & chr(34),0,true
'第2个服务
bingpath=WshShell.ExpandEnvironmentStrings("%CommonProgramFiles(x86)%\SolidWorks Shared\Service\SolidWorksLicensing.exe")
ins="sc create " & """SolidWorks Licensing Service"" binpath=" & chr(34) & bingpath & chr(34) & " start=auto displayname=""SolidWorks Licensing Service"""
WshShell.Run ins,0,true
ins="sc description " & """SolidWorks Licensing Service"" ""Provides authentication services for SolidWorks applications"""
WshShell.Run ins,0,true
WshShell.Run "net.exe start " & chr(34) & "SolidWorks Licensing Service" & chr(34),0,true
'第3个服务
bingpath=WshShell.ExpandEnvironmentStrings("%CommonProgramFiles%\Macrovision Shared\FlexNet Publisher\FNPLicensingService64.exe")
ins="sc create " & """WFlexNet Licensing Service 64"" binpath=" & chr(34) & bingpath & chr(34) & " start=auto displayname=""WFlexNet Licensing Service 64"""
WshShell.Run ins,0,true
ins="sc description " & """WFlexNet Licensing Service 64"" ""This service performs licensing functions on behalf of FlexNet enabled products."""
WshShell.Run ins,0,true
WshShell.Run "net.exe start " & chr(34) & "WFlexNet Licensing Service 64" & chr(34),0,true
'改配置文件:sldIM_installed.xml
WshShell.Run chr(34) & my_dir & "\sldProcMon.exe" & chr(34),1,true'初使化程序
'WshShell.Run chr(34) & my_dir & "\fontinst" & chr(34),0,true'安装字体
Shortcut "SLDWORKS2022", my_dir & "\SLDWORKS.exe"'创建桌面图标
bingpath=chr(34) & prog_dir & "\Common Files\SOLIDWORKS Shared"
WshShell.Run "regsvr32.exe /s /u " & bingpath & "sldwinshellextu.dll" & chr(34),0,true
WshShell.Run "regsvr32.exe /s /u " & bingpath & "sldthumbnailprovider.dll" & chr(34),0,true
WshShell.Run "regsvr32.exe /s " & chr(34) & my_dir & "\swhtmlcontrol.dll" & chr(34),0,true
del my_dir & "\安装修改.reg"
WshShell.Run "regsvr32.exe /s " & bingpath & "sldwinshellextu.dll" & chr(34),0,true
WshShell.Run "regsvr32.exe /s " & bingpath & "sldthumbnailprovider.dll" & chr(34),0,true
firewall_dict.add "SW2022_01",my_dir & "" & "DsgnChkRptView.exe"
firewall_dict.add "SW2022_02",my_dir & "" & "gabiswengine.exe"
firewall_dict.add "SW2022_03",my_dir & "" & "LocalSldService.exe"
firewall_dict.add "SW2022_04",my_dir & "" & "mg-tetra.exe"
firewall_dict.add "SW2022_05",my_dir & "" & "propertyManagerUpload.exe"
firewall_dict.add "SW2022_06",my_dir & "" & "RTLibraryManager.exe"
firewall_dict.add "SW2022_07",my_dir & "" & "SldBatchUploadPreprocessor.exe"
firewall_dict.add "SW2022_08",my_dir & "" & "sldbgproc.exe"
firewall_dict.add "SW2022_09",my_dir & "" & "sldCostingTemplateEditorAppU.exe"
firewall_dict.add "SW2022_10",my_dir & "" & "SLDEXITAPP.exe"
firewall_dict.add "SW2022_11",my_dir & "" & "sldphotoshopcon.exe"
firewall_dict.add "SW2022_12",my_dir & "" & "sldProcMon.exe"
firewall_dict.add "SW2022_13",my_dir & "" & "sldSettingsAdmin.exe"
firewall_dict.add "SW2022_14",my_dir & "" & "SldToolboxConfigure.exe"
firewall_dict.add "SW2022_15",my_dir & "" & "sldtoolboxupdater.exe"
firewall_dict.add "SW2022_16",my_dir & "" & "SLDWORKS.exe"
firewall_dict.add "SW2022_17",my_dir & "" & "sldworks_fs.exe"
firewall_dict.add "SW2022_18",my_dir & "" & "swShellFileLauncher.exe"
firewall_dict.add "SW2022_19",my_dir & "" & "swspmanager.exe"
firewall_dict.add "SW2022_20",my_dir & "" & "testconsole.exe"
firewall_dict.add "SW2022_21",my_dir & "" & "UtlReportViewer.exe"
firewall_dict.add "SW2022_22",my_dir & "" & "x264.exe"
firewall_dict.add "SW2022_23",my_dir & "" & "api\pidcollector.exe"
firewall_dict.add "SW2022_24",my_dir & "" & "api\HTMLHelp2x\innovahxreg.exe"
firewall_dict.add "SW2022_25",my_dir & "" & "cef\swCefSubProc.exe"
firewall_dict.add "SW2022_26",my_dir & "" & "CircuitWorksFull\circuitworks.exe"
firewall_dict.add "SW2022_27",my_dir & "" & "DriveWorksXpress\driveworksxpressdt.exe"
firewall_dict.add "SW2022_28",my_dir & "" & "dsgnchk\Dsgnchkbldu.exe"
firewall_dict.add "SW2022_29",my_dir & "" & "dsgnchk\DsgnChkDesignBinderu.exe"
firewall_dict.add "SW2022_30",my_dir & "" & "FloXpress\bin\efdsolver.exe"
firewall_dict.add "SW2022_31",my_dir & "" & "FloXpress\bin\ffmpeg.exe"
firewall_dict.add "SW2022_32",my_dir & "" & "myproducts\myproducts.exe"
firewall_dict.add "SW2022_33",my_dir & "" & "photoview\foundrycrashhandler.exe"
firewall_dict.add "SW2022_34",my_dir & "" & "photoview\photoview360.exe"
firewall_dict.add "SW2022_35",my_dir & "" & "photoview\photoview360_cl.exe"
firewall_dict.add "SW2022_36",my_dir & "" & "photoview\QtWebEngineProcess.exe"
firewall_dict.add "SW2022_37",prog_dir & "\Common Files\SOLIDWORKS Shared\sldShellExtServer.exe"
firewall_dict.add "SW2022_38",prog_dir & "\Common Files\SOLIDWORKS Shared\2022\lmutil.exe"
firewall_dict.add "SW2022_39",prog_dir & "\Common Files\SOLIDWORKS Shared\2022\swlmutil.exe"
firewall_dict.add "SW2022_40",prog_dir & "\Common Files\SOLIDWORKS Shared\2022\swlmwiz.exe"
firewall_dict.add "SW2022_41",prog_dir & "\Common Files\SOLIDWORKS Shared\2022\sldrx\sldrx.exe"
firewall_dict.add "SW2022_42",prog_dir & "\Common Files\SOLIDWORKS Shared\2022\sldrx\sldrxET.exe"
firewall_dict.add "SW2022_43",prog_dir & "\Common Files\SOLIDWORKS Shared\2022\sldrx\sldrxmm.exe"
firewall_dict.add "SW2022_45",progx86_dir & "\Common Files\SOLIDWORKS Shared\Service\Service\SolidWorksLicensing.exe"
firewall_dict.add "SW2022_46",progx86_dir & "\Common Files\SOLIDWORKS 安装管理程序\30.0\sldimdownloader.exe"
firewall_dict.add "SW2022_47",progx86_dir & "\Common Files\SOLIDWORKS 安装管理程序\BackgroundDownloading\sldBgDwld.exe"
firewall_dict.add "SW2022_48",progx86_dir & "\Common Files\SOLIDWORKS 安装管理程序\CheckForUpdates\sldCheckForUpdates.exe"
firewall_dict.add "SW2022_49",my_dir & "" & "setup\i386\copyoptwiz.exe"
firewall_dict.add "SW2022_50",my_dir & "" & "setup\i386\swactwiz.exe"
firewall_dict.add "SW2022_51",my_dir & "" & "setup\i386\swactwizhelpersc.exe"
firewall_dict.add "SW2022_52",my_dir & "" & "setup\i386\swactwiz_s.exe"
firewall_dict.add "SW2022_53",my_dir & "" & "setup\i386\swinstactsvc.exe"
firewall_dict.add "SW2022_54",my_dir & "" & "setup\i386\swlicservinst.exe"
firewall_dict.add "SW2022_55",my_dir & "" & "setup\i386\x86\swlicservinst.exe"
firewall_dict.add "SW2022_56",my_dir & "" & "Simulation\check.exe"
firewall_dict.add "SW2022_57",my_dir & "" & "Simulation\check_net.exe"
firewall_dict.add "SW2022_58",my_dir & "" & "Simulation\cos2abq.exe"
firewall_dict.add "SW2022_59",my_dir & "" & "Simulation\cos2ans.exe"
firewall_dict.add "SW2022_60",my_dir & "" & "Simulation\cos2nas.exe"
firewall_dict.add "SW2022_61",my_dir & "" & "Simulation\cos2pat.exe"
firewall_dict.add "SW2022_62",my_dir & "" & "Simulation\cos2xds.exe"
firewall_dict.add "SW2022_63",my_dir & "" & "Simulation\cwanalysisproc.exe"
firewall_dict.add "SW2022_64",my_dir & "" & "Simulation\cwbcbfmesh.exe"
firewall_dict.add "SW2022_65",my_dir & "" & "Simulation\cwmeshproc.exe"
firewall_dict.add "SW2022_66",my_dir & "" & "Simulation\dpost.exe"
firewall_dict.add "SW2022_67",my_dir & "" & "Simulation\dstar.exe"
firewall_dict.add "SW2022_68",my_dir & "" & "Simulation\fat.exe"
firewall_dict.add "SW2022_69",my_dir & "" & "Simulation\ghs3d.exe"
firewall_dict.add "SW2022_70",my_dir & "" & "Simulation\ghs3dv3.exe"
firewall_dict.add "SW2022_71",my_dir & "" & "Simulation\hstar.exe"
firewall_dict.add "SW2022_72",my_dir & "" & "Simulation\ids2cos.exe"
firewall_dict.add "SW2022_73",my_dir & "" & "Simulation\nstar.exe"
firewall_dict.add "SW2022_74",my_dir & "" & "Simulation\pre1.exe"
firewall_dict.add "SW2022_75",my_dir & "" & "Simulation\renum.exe"
firewall_dict.add "SW2022_76",my_dir & "" & "Simulation\SOLIDWORKS Simulation Network Share.exe"
firewall_dict.add "SW2022_77",my_dir & "" & "Simulation\star.exe"
firewall_dict.add "SW2022_78",my_dir & "" & "Simulation\stopt.exe"
firewall_dict.add "SW2022_79",my_dir & "" & "Simulation\stres.exe"
firewall_dict.add "SW2022_80",my_dir & "" & "Simulation\sysinf.exe"
firewall_dict.add "SW2022_81",my_dir & "" & "Simulation\License\setup\i386\swlicservinst.exe"
firewall_dict.add "SW2022_82",my_dir & "" & "Simulation\setup\i386\swactwiz.exe"
firewall_dict.add "SW2022_83",my_dir & "" & "Simulation\setup\i386\swlicservinst.exe"
firewall_dict.add "SW2022_84",my_dir & "" & "Simulation\Topology\code\bin\smatoctoscaservermain.exe"
firewall_dict.add "SW2022_85",my_dir & "" & "Simulation\Topology\code\bin\SMATrtOptResExportTool.exe"
firewall_dict.add "SW2022_86",my_dir & "" & "Simulation\Topology\code\bin\SMATrtOptResImportTool.exe"
firewall_dict.add "SW2022_87",my_dir & "" & "Simulation\Topology\code\bin\SMATrtOptResInfo.exe"
firewall_dict.add "SW2022_88",my_dir & "" & "Simulation\Topology\code\bin\smatrttstructsmoothmain.exe"
firewall_dict.add "SW2022_89",my_dir & "" & "Simulation\Topology\code\bin\smatsocosmosjobchecker.exe"
firewall_dict.add "SW2022_90",my_dir & "" & "Simulation\Topology\code\bin\smatsocosmossetlc.exe"
firewall_dict.add "SW2022_91",my_dir & "" & "Simulation\Topology\code\bin\smatsofeminclude.exe"
firewall_dict.add "SW2022_92",my_dir & "" & "Simulation\Topology\code\bin\smatsofemmodif.exe"
firewall_dict.add "SW2022_93",my_dir & "" & "Simulation\Topology\code\bin\smatsofemtoonf.exe"
firewall_dict.add "SW2022_94",my_dir & "" & "Simulation\Topology\code\bin\smatsorestovtm.exe"
firewall_dict.add "SW2022_95",my_dir & "" & "Simulation\Topology\code\bin\smatsotoscaopt.exe"
firewall_dict.add "SW2022_96",my_dir & "" & "Simulation\Topology\code\bin\smatsotoscaprep.exe"
firewall_dict.add "SW2022_97",my_dir & "" & "Simulation\Topology\code\bin\smatsotoscapython.exe"
firewall_dict.add "SW2022_98",my_dir & "" & "Simulation\Topology\tools\smapy\python\python.exe"
firewall_dict.add "SW2022_99",my_dir & "" & "Simulation\Topology\tools\smapy\python\pythonw.exe"
firewall_dict.add "SW2022_100",my_dir & "" & "Simulation\Utilities\cosmossupporttool.exe"
firewall_dict.add "SW2022_101",my_dir & "" & "Simulation\Utilities\material.exe"
firewall_dict.add "SW2022_102",my_dir & "" & "Simulation\Utilities\simulation cleaning utility.exe"
firewall_dict.add "SW2022_103",my_dir & "" & "sldBenchmarking\sldBenchmark.exe"
firewall_dict.add "SW2022_104",my_dir & "" & "sldPropertyTabBuilder\PropertyTabBuilder.exe"
firewall_dict.add "SW2022_105",my_dir & "" & "sldutils\GtReportManager.exe"
firewall_dict.add "SW2022_106",my_dir & "" & "SolidWorks_Flexnet_Server\installs.exe"
firewall_dict.add "SW2022_107",my_dir & "" & "SolidWorks_Flexnet_Server\lmgrd.exe"
firewall_dict.add "SW2022_108",my_dir & "" & "SolidWorks_Flexnet_Server\lmtools.exe"
firewall_dict.add "SW2022_109",my_dir & "" & "SolidWorks_Flexnet_Server\lmutil.exe"
firewall_dict.add "SW2022_110",my_dir & "" & "SolidWorks_Flexnet_Server\sw_d.exe"
firewall_dict.add "SW2022_111",my_dir & "" & "spiop\sldimport.exe"
firewall_dict.add "SW2022_112",my_dir & "" & "spiop\files\code\bin\cnextmproc.exe"
firewall_dict.add "SW2022_113",my_dir & "" & "spiop\files\code\bin\spaxchildconnect.exe"
firewall_dict.add "SW2022_114",my_dir & "" & "spiop\files\code\bin\spaxchildprocess.exe"
firewall_dict.add "SW2022_115",my_dir & "" & "spiop\files\code\bin\spaxchilduconnectacis.exe"
firewall_dict.add "SW2022_116",my_dir & "" & "spiop\files\code\bin\spaxchilduconnectcgm.exe"
firewall_dict.add "SW2022_117",my_dir & "" & "spiop\files\code\bin\spaxchilduconnectps.exe"
firewall_dict.add "SW2022_118",my_dir & "" & "swScheduler\DTSCoordinatorService.exe"
firewall_dict.add "SW2022_119",my_dir & "" & "swScheduler\DTSMonitor.exe"
firewall_dict.add "SW2022_120",my_dir & "" & "swScheduler\DTSServiceManager.exe"
firewall_dict.add "SW2022_121",my_dir & "" & "swScheduler\swboengine.exe"
firewall_dict.add "SW2022_122",my_dir & "" & "swScheduler\swScheduler.exe"
firewall_dict.add "SW2022_123",my_dir & "" & "swVBAServer\drawcompare.exe"
firewall_dict.add "SW2022_124",my_dir & "" & "ThemeEditor\PresentationStudioThemeEditor.exe"
firewall_dict.add "SW2022_125",my_dir & "" & "Toolbox\data utilities\DatabaseConverter.exe"
firewall_dict.add "SW2022_126",my_dir & "" & "Toolbox\data utilities\sldsetdocprop.exe"
firewall_dict.add "SW2022_127",my_dir & "" & "Toolbox\data utilities\UpdateBrowserDatabase.exe"
firewall_dict.add "SW2022_128",my_dir & "" & "Treehouse\Treehouse.exe"
firewall_dict.add "SW2022_129",windir & "" & "SolidWorks\IM_20220-40500-1100-100\setup.exe"
firewall_dict.add "SW2022_130",windir & "" & "SolidWorks\IM_20220-40500-1100-100\sldim\sldadminoptioneditor.exe"
firewall_dict.add "SW2022_131",windir & "" & "SolidWorks\IM_20220-40500-1100-100\sldim\sldIM.exe"
For Each i in firewall_dict'禁止程序连网
firewall_dict(i)=WshShell.ExpandEnvironmentStrings(firewall_dict(i))
'netsh advfirewall firewall del rule name=i
tmp1=" del rule name=" & chr(34) & i & chr(34)
'netsh advfirewall firewall add rule name=i program=i action=block dir=out
tmp2=" add rule name=" & chr(34) & i & chr(34) & " program=" & chr(34) & firewall_dict(i) & chr(34) & " action=block dir=out"
'netsh advfirewall firewall add rule name=i service=%%j action=block dir=out program="%svchost_exe%"
tmp3=" add rule name=" & chr(34) & i & chr(34) & " service=" & chr(34) & firewall_dict(i) & chr(34) & " action=block dir=out program=" & chr(34) & windir & "\system32\svchost.exe" & chr(34)
WshShell.Run "netsh advfirewall firewall " & tmp1 ,0,true '删除之前规则
WshShell.Run "netsh advfirewall firewall " & tmp2 ,0,true '建立新规则
if i="Windows Update" then WshShell.Run "netsh advfirewall firewall " & tmp3 ,0,true '添加阻止服务出站规则
next
i=WshShell.popup("工作完成,确认或无操作5秒后运行SW2022,如不需要请及时取消",5,"SolidWorks安装程序",VbOKCancel)
if i=vbOK or i=-1 then WshShell.Run my_dir & "\SLDWORKS.exe",1,true
Wscript.Quit
Function move_dir(dir0,dir1)'dir0:原目录;dir1:移动过去的新目录
dim file,fs,items,objdir
dir1=UCase(trim(dir1)):if right(dir1,1)="" then dir1=left(dir1,len(dir1)-1) '容错去空格和后\
dir0=UCase(trim(dir0)):if right(dir0,1)="" then dir0=left(dir0,len(dir0)-1) '容错去空格和后\
fs = Split(dir1, "")
for each file in fs
if not file=nul then items=items&file&""
if not objFSO.FileExists(items&"\nul") then Set objdir = objFSO.CreateFolder(items)
next
objdir=left(dir1,instrrev(dir1,"")-1) '& ""
fs=right(dir1,len(dir1)-len(objdir))
if fs=right(dir0,len(fs)) then
dir1=objdir
if right(dir1,1)=":" then dir1=dir1 & ""
end if
'CreateObject("Shell.Application").NameSpace(dir1).MoveHere dir0,&H0&'FOF_CREATEPROGRESSDLG
'上述方法不能直接覆盖,所以只能用复制和删除
on error resume next
objFSO.CopyFolder dir0,dir1,True '复制目录里的文件到新的地方
'del(dir0)'暂时不忙删除,万一需要重复安装?
on error goto 0
End Function
Function NetWork(val) '因未设置延迟,所以不要重复调用或在短时内操作网络
'接收参数:0:关闭“本地连接” 1:打开“本地连接” 2:自动(关闭则打开;打开则关闭)
dim w,i
Set w=objWMI.ExecQuery("select * from WIN32_NetworkAdapter")
For Each i In w
If instr(i.NetConnectionID,"本地连接")>0 or instr(i.NetConnectionID,"以太网")>0 Then
if val=0 then i.Disable
if val=1 then i.Enable
if val=2 then
If i.NetConnectionStatus<>0 then
i.Disable
Else
i.Enable
end if
end if
End If
next
set w=nothing
'wscript.sleep 400
End Function
Function Wait(proc) '等待程序完成,十秒还没完成则退出
dim mark,obj,proce,data,x
do
mark=0
Set obj = getobject("winmgmts:\\.\root\cimv2")
Set proce = obj.execquery("select * from win32_process")
For each x in proce
if lcase(x.name)=proc then mark=1
data=data+1
next
if mark=0 or data>100 then exit do
wscript.sleep 100
Set obj = nothing
Set proce = nothing
loop
End Function
'关闭程序
Function Close_Process(ProcessName) '关闭程序
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colProcessList = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = '" & ProcessName & "'")
For Each objProcess in colProcessList
objProcess.Terminate()
Next
End Function
Function Shortcut(Short_name,path_and_name) '为在桌面创建一个快捷方式
strDesktop = WshShell.SpecialFolders("AllUsersDesktop") '在桌面创建一个快捷方式
set oShellLink = WshShell.CreateShortcut(strDesktop & "" & Short_name & ".lnk") '名称
oShellLink.TargetPath = path_and_name '目标
oShellLink.WindowStyle = 1 '窗口样式 1默认窗口激活,参数3最大化激活,参数7最小化
oShellLink.Hotkey = "" '快捷键
oShellLink.IconLocation = path_and_name & ",0" '第几个图标
oShellLink.Description = Short_name '备注
oShellLink.WorkingDirectory = left(path_and_name,InStrRev(path_and_name,"")-1) '起始位置
oShellLink.Arguments = "" '参数
oShellLink.Save '保存
End Function
Function del(del_file) '删除文件或者文件夹,之所以最后一种可能实现前两种功能还要分开成三种,是因为效率
dim file_path,str2,str3,pattern,tmp1,tmp2,tmp3
tmp2="":tmp3="" '初使化临时变量
del_file=WshShell.ExpandEnvironmentStrings(trim(del_file))'还原带环境变量,去掉空格,下面这句设置解属性参数,其中SID在上文已定义
file_path = lcase(objFSO.GetParentFolderName(del_file)) '取父目录方法
if del_file="" then del="调用时没写被删除的文件":exit Function
if not objFSO.FolderExists(file_path) then del="没找到父文件夹:" & del_file :exit Function
on error resume next
WshShell.Run "takeown.exe /f " & chr(34) & windir & del_file & chr(34),0,true
WshShell.Run "icacls.exe /f " & chr(34) & windir & del_file & chr(34) & " /grant administrators:F",0,true
objFSO.deletefile del_file,true '用通配符删除文件
objFSO.deletefolder del_file,true '直接删除文件夹
on error goto 0
End Function
Function SRV_ADD(Service_Name,mode)
'Set tmp=GetObject("winmgmts:\\.\root\cimv2").get("win32_service")
'uu=tmp.create("WFlexNet Licensing Service 64","FlexNet Licensing Service 64","C:\Program Files\Common Files\Macrovision Shared\FlexNet 'Publisher\FNPLicensingService64.exe",16,2,"Manual",True,Null,null)
'Set tmp=nothing
End Function
'例:Call SRV("RemoteAccess","del")
Function SRV(Service_Name,mode)'设置系统服务,stop:停,Start:启,del:删,Disabled:禁,Automatic:自动,Manual:手动,delayed-auto延迟启动
dim ObjServices,SRV_msg'返回值:正常完成/操作值错mode/无此服务
Set ObjServices = GetObject("winmgmts:\\.\root\cimv2").ExecQuery("Select * from Win32_Service where Name="&"'"&Service_Name &"'")
SRV="未找到" & Service_Name:FOREXIT=0
For Each Service In ObjServices
SRV="有服务" & Service_Name
Service_mode=LCase(mode)'默认手工启动,是否考虑预置Start=3 ?
Select Case LCase(Service_mode)
Case "stop"'停止服务
Call Service.StopService()
Start=0
'If Service.State = "Running" Then '不同服务停下来时间不一样
Case "start"'启动服务
Call Service.Start()
Start=0
Case "del"'删除服务
Start=6
Case "demand"'手动
Start = 3
Case "auto"'自动启动
Start = 2
Service_mode="Automatic"
Case "delayed-auto"'延迟启动
Start = 5
Service_mode="Automatic"
Case "disabled"'禁用
Start = 4
Service_mode="Disabled"
case else
SRV="操作错" & mode
Start=0
End Select
if Start>0 then
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
oReg.EnumKey HKEY_LOCAL_MACHINE,"SYSTEM\CurrentControlSet\Services",arrSubKeys
SRV="无服务" & Service_Name
For Each subkey In arrSubKeys
SRV="找到有" & Service_Name
if subkey=Service.Name then
if Start=6 then '单独处理删除服务
SRV_reg="HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services" & subkey & "\Start"
Service.StopService() '防火墙服务必须停止后才能删除,其他大多不必
Service.Delete():SRV="删成功" & subkey'删除本服务
SRV_msg="":on error resume next:SRV_msg=WshShell.RegRead(SRV_reg):on error goto 0'尝试读这个服务
if SRV_msg>"" then'如果这个服务仍然没被删除就解除注册表权限然后尝试直接删除注册表
SetRegACL "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services"& subkey
oReg.deletekey HKEY_LOCAL_MACHINE ,"SYSTEM\CurrentControlSet\Services" & subkey
SRV_msg="":on error resume next:SRV_msg=WshShell.RegRead(SRV_reg):on error goto 0'尝试读这个服务
if SRV_msg>"" then '尝试使用Reg命令
'msgbox "cmd /c reg delete ""HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services" & subkey & """ /f"
WshShell.Run "cmd /c reg delete ""HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services" & subkey & """ /f",0,true
SRV_msg="":on error resume next:SRV_msg=WshShell.RegRead(SRV_reg):on error goto 0'尝试读这个服务
if SRV_msg>"" then SRV="删失败" & subkey else SRV="删成功" & subkey
end if
end if
else
'Service.ChangeStartMode(Service_mode)'本来用这句就可以了,能得到最好的兼容性,但权限问题会造成不确定的无效
Delay=0:if start=5 then Delay=1:Start=2'预设不延时启动(具体秒在Control\AutoStartDelay)
TryWrtReg "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services" & subkey & "\DelayedAutostart",Delay,"REG_DWORD"
TryWrtReg "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services" & subkey & "\Start" ,Start,"REG_DWORD"
end if
FOREXIT=1'只可能有一个同名服务,不需要完成所有循环
end if
if FOREXIT=1 then exit for
Next
end if
if FOREXIT=1 then exit for
Next
Set ObjServices = nothing
End Function
如果你喜欢我们的文章,欢迎您分享或收藏路人粉的文章! 我们网站的目标是帮助每一个有求知欲的人,无论他们的水平和经验如何。我们相信,只要有热情和毅力,无论从什么时候开始学习都不晚。
2. 本站资源大多存储在云盘,如发现链接失效,请联系我们我们会第一时间更新。
★特别声明:
本站为个人博客,博客所发布的一切修改补丁、注册机、注册信息及软件和视频教程的文章仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关,您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。访问和下载本站内容,说明您已同意上述条款。 本站为非盈利性站点,本站不贩卖软件,所有内容不作为商业行为。
暂无评论内容