运行非蝙蝠扩展文件作为批处理文件 [英] Running a non bat extension file as a batch file

查看:351
本文介绍了运行非蝙蝠扩展文件作为批处理文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们说我有一个文本文件,它包含批处理命令。我怎样才能运行从一个内的文本文件作为一个批处理文件,重新命名它。我想太多保持便携方面也是它,所以没有注册表项或这样的。

原因没有重命名太prevent吃剩的意外后关闭unrenamed文件。


解决方案

 键入some.txt> temp.bat
电话temp.bat
德尔/ Q /˚Ftemp.bat

时创建一个临时文件作弊?它没有提到作为question.Though限制,你可以松%ERRORLEVEL%因为del命令,但你可以保持它临时变量:

 键入some.txt> temp.bat
电话temp.bat
设置temp_el =%ERRORLEVEL%
德尔/ Q /˚Ftemp.bat
退出/ B%temp_el%

Let's say I have a text file, it contains batch commands. How can I run that text file as a batch file from within one, without renaming it. I want too keep a portable aspect too it, so no registry keys or such.

The reason for no renaming is too prevent leftover unrenamed files upon unexpected closure.

解决方案

type some.txt>temp.bat
call temp.bat
del /q /f temp.bat 

Is creating a temp file cheating?It's not mentioned as restriction in the question.Though you can loose the %ERRORLEVEL% because of the del command , but you can keep it in temp variable:

type some.txt>temp.bat
call temp.bat
set temp_el=%errorlevel%
del /q /f temp.bat
exit /b %temp_el% 

这篇关于运行非蝙蝠扩展文件作为批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆