在命令行中执行VBS或者JS代码、powershell代码


今天不知道什么原因,就研究了一下在cmd命令行中执行vbs或者js代码,这里算是一种思路吧

 

执行VBS代码,再由vbs执行bat程序
:: mshta vbscript:createobject("wscript.shell").run("RunWebService.bat D:\Publish\TestWeb\TestShareFile",vbhide)(window.close)
:: mshta vbscript:createobject("wscript.shell").run("C:\t1\RunWebService.bat D:\Publish\TestWeb\TestShareFile",0)(window.close)

 

执行JS代码,再由js执行bat程序

::mshta javascript:new ActiveXObject("WScript.Shell").Run("cmd /c C:\t1\RunWebService.bat D:\Publish\TestWeb\TestShareFile",0);window.close()
::mshta javascript:(new ActiveXObject('WScript.Shell')).Run('cmd /c C:\t1\RunWebService.bat D:\Publish\TestWeb\TestShareFile',0);window.close();
::mshta "javascript: new ActiveXObject('WScript.Shell').Run('cmd /c C:\t1\RunWebService.bat D:\Publish\TestWeb\TestShareFile',0);window.close()"
::mshta javascript: new ActiveXObject("WScript.Shell").Run("cmd /c C:\t1\RunWebService.bat D:\Publish\TestWeb\TestShareFile",0);window.close()

 

执行 powershell 代码

 powershell "if(1 -gt 0){echo 1111} else {echo 000}"

 

 

具体的可以参考我上一篇文章:运行bat时隐藏cmd窗口 

==================================================================

另外,再给个命令,我自己还没有研究这个命令,先记录下;

示例功能:从指定url下载内容并保存

cscript //NoLogo /e:vbscript web_Download.vbs  "http://xxx.ddd.com/abc.html"  "c:\tmp\123.txt"


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM