继上次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

执行命令的部分

检查文件名是否被打开。

最新文章

  1. ElasticSearch 5学习(10)——结构化查询(包括新特性)
  2. Vuforia结合Skyshop: Image-Based Lighting Tools & Shaders插件实现真实的光照效果
  3. centos7设置网关
  4. ExecutorService线程池应用
  5. Maven异常:Could not find artifact
  6. 从.o文件中提取指定开头依赖于外部接口的脚本
  7. [OrangePi] Installation on internal EMMC
  8. 在svg里面画虚线
  9. Java Web架构知识整理——记一次阿里面试经历
  10. Qt for Android 程序禁止屏幕旋转
  11. 【Java重构系列】重构31式之封装集合
  12. Windows安装Subversion
  13. js时间戳与日期格式之间的互转
  14. python数据类型—列表(增改删查,统计,取值,排序)
  15. ‘Microsoft.Jet.OLEDB.4.0’ provider is not registered
  16. 【转】Appium 服务器端从启动到case完成的活动分析
  17. 如何把程序钉到Windows7任务栏(修正版)
  18. Git问题集锦
  19. git 之路
  20. XACT_ABORT选项

热门文章

  1. STM32F407 GPIO原理 个人笔记
  2. [luoguP1022] 计算器的改良(模拟)
  3. hdu1978
  4. vue2.0一个书城实例
  5. 玛丽卡(codevs 1021)
  6. Thinkphp5.0 的Db操作
  7. 关于变量__name__的理解
  8. [bzo1211][HNOI2004]树的计数_prufer序列
  9. [bzoj2091][Poi2010]The Minima Game_动态规划
  10. P2819 图的m着色问题 洛谷