how can I run a script without an extension?

懵懂的女人 提交于 2019-12-25 03:24:38

问题


Say I have a file on my desktop that doesn't have extension, but contains some code (say Batch or VBS).
Can I run this code without adding an extension to the file?
I was personally thinking about using powershell to pass an extension to wscript.exe, but this turned out to be somewhat impossible.


回答1:


For VBS\JS scripts you need to specify engine with //E switch.

Examples:

  • If file xxx contains VbScript code: wscript //E:VBScript c:\xxx
  • If file xxx contains JavaScript code: wscript //E:JScript c:\xxx

For batch files, it's not so easy. There is some workarounds, but they're somewhat limited: How to run batch script with out using *.bat extension



来源:https://stackoverflow.com/questions/29301043/how-can-i-run-a-script-without-an-extension

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!