VBScript+SCR+NetApi+Accoreconsole 批处理dwg文件
2024-09-05 02:29:18
继上次powershell运行accoreconsole(https://www.cnblogs.com/NanShengBlogs/p/10981687.html)的研究之后又觉得不是很合适,毕竟powershell还存在权限问题,不像vbs这么windows原生的的脚本好用。
脚本主要部分
Option Explicit Dim acoreFn,fso acoreFn=inputbox("输入AutoCAD的版本号","用户输入","") if int(acoreFn)>= then Set fso = CreateObject("Scripting.FileSystemObject") if fso.FileExists("C:\Program Files\Autodesk\AutoCAD " & acoreFn & "\accoreconsole.exe") then acoreFn=chr() & "C:\Program Files\Autodesk\AutoCAD " & acoreFn & "\accoreconsole.exe" &chr() call AccoreCmdExecute("myScrFile.scr",acoreFn)
else msgbox "请确认本机的autocad"& int(acoreFn) & "安装路径为:" & vbNewLine & "C:\Program Files\Autodesk\AutoCAD " & acoreFn & "",vbError+vbOKOnly end if else
msgbox "Accoreconsole.exe 程序从AutoCAD2013 开始支持!",vbError+vbOKOnly end if set fso=nothing public sub AccoreCmdExecute(scrFileName,accoreconsoleFileName) Dim objFSO,curFdName,fl,fd,WshShell,scrFile,args Set objFSO = CreateObject("Scripting.FileSystemObject") curFdName = objFSO.GetFile(WScript.ScriptFullName).ParentFolder scrFile=" /s " & chr() & curFdName & "\" & scrFileName & chr() set fd=objFSO.GetFolder(curFdName) Set WshShell=Wscript.CreateObject("Wscript.Shell") for each fl in fd.Files if LCase(objFSO.GetExtensionName(fl))="dwg" then if (objFSO.getfile(fl).Attributes and ) or CheckFileInuse(fl)=true then msgbox fl.name & "是只读文件或者被打开,无法执行脚本命!"
else
args=" /i " & chr() & curFdName& "\" & fl.name & chr() WshShell.run accoreconsoleFileName & args & scrFile,,false msgbox fl.name & "执行完成!" end if end if
next set fd=nothing
set objFSO=nothing
set WshShell=nothing end sub public function CheckFileInuse(fn) dim fso,fl Set fso = CreateObject("Scripting.FileSystemObject") Set fl = fso.GetFile(fn) ON ERROR RESUME NEXT fl.move fl.path if Err= then CheckFileInuse=true
else
CheckFileInuse=false
end if Set fso =nothing Set fl = nothing end function
执行命令的部分
检查文件名是否被打开。
最新文章
- ElasticSearch 5学习(10)——结构化查询(包括新特性)
- Vuforia结合Skyshop: Image-Based Lighting Tools &; Shaders插件实现真实的光照效果
- centos7设置网关
- ExecutorService线程池应用
- Maven异常:Could not find artifact
- 从.o文件中提取指定开头依赖于外部接口的脚本
- [OrangePi] Installation on internal EMMC
- 在svg里面画虚线
- Java Web架构知识整理——记一次阿里面试经历
- Qt for Android 程序禁止屏幕旋转
- 【Java重构系列】重构31式之封装集合
- Windows安装Subversion
- js时间戳与日期格式之间的互转
- python数据类型—列表(增改删查,统计,取值,排序)
- ‘Microsoft.Jet.OLEDB.4.0’ provider is not registered
- 【转】Appium 服务器端从启动到case完成的活动分析
- 如何把程序钉到Windows7任务栏(修正版)
- Git问题集锦
- git 之路
- XACT_ABORT选项
热门文章
- STM32F407 GPIO原理 个人笔记
- [luoguP1022] 计算器的改良(模拟)
- hdu1978
- vue2.0一个书城实例
- 玛丽卡(codevs 1021)
- Thinkphp5.0 的Db操作
- 关于变量__name__的理解
- [bzo1211][HNOI2004]树的计数_prufer序列
- [bzoj2091][Poi2010]The Minima Game_动态规划
- P2819 图的m着色问题 洛谷