|  | 
 
| sunyao 初级用户
 
   
 
 
 积分 141
 发帖 60
 注册 2006-10-28
 来自 天津
 状态 离线
 | 
| 『楼 主』:
 征集批处理接受脚本语言返回结果的方法!
 
使用 LLM 解释/回答一下 
 
 
在批处理文件中接受vbs等其他脚本语言的返回结果的方法!! 
Methods to accept the return results of other scripting languages such as VBS in batch files! 
 
 
 |  | 
|  2006-11-7 04:00 |  | 
|  | 
 
| sunyao 初级用户
 
   
 
 
 积分 141
 发帖 60
 注册 2006-10-28
 来自 天津
 状态 离线
 | 
| 『第 2 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
先举一例子引用youxi01用户的例子:看看以下代码:
 
 @echo off
 ::写一个求字符串长度的vbs文件
 echo temp=wscript.arguments(0) >temp.vbe
 echo for i=1 to len(temp) >>temp.vbe
 echo    if asc(mid(temp,i,1))^<0 then >>temp.vbe
 echo        strlen=strlen+2 >>temp.vbe
 echo     else >>temp.vbe
 echo        strlen=strlen+1 >>temp.vbe
 echo     end if >>temp.vbe
 echo next >>temp.vbe
 echo wscript.echo strlen >>temp.vbe
 :Start
 set /p EN=请输入字符串:(直接回车退出)=
 if not defined EN goto :Over
 ::获取vbe文件的执行结果
 for /f %%i in ('cscript.exe temp.vbe %EN% //nologo') do echo.&echo    字符串长度为:  %%i
 set EN=
 goto :Start
 :Over
 ::删除生成的文件
 del temp.vbe
 
 这一句是关键:
 for /f %%i in ('cscript.exe temp.vbe %EN% //nologo')  do ......
 利用for循环,读取vbs返回结果,也可以算是批处理接受脚本语言返回结果的一种解决办法吧。(当然在本程序中,没必要一定要使用for)
 
First, give an example citing the example of user youxi01:
 Look at the following code:
 
 @echo off
 :: Write a VBS file to find the length of a string
 echo temp=wscript.arguments(0) >temp.vbe
 echo for i=1 to len(temp) >>temp.vbe
 echo    if asc(mid(temp,i,1))^<0 then >>temp.vbe
 echo        strlen=strlen+2 >>temp.vbe
 echo     else >>temp.vbe
 echo        strlen=strlen+1 >>temp.vbe
 echo     end if >>temp.vbe
 echo next >>temp.vbe
 echo wscript.echo strlen >>temp.vbe
 :Start
 set /p EN=Please enter a string: (Press Enter directly to exit)=
 if not defined EN goto :Over
 :: Get the execution result of the VBE file
 for /f %%i in ('cscript.exe temp.vbe %EN% //nologo') do echo.&echo    The length of the string is:  %%i
 set EN=
 goto :Start
 :Over
 :: Delete the generated file
 del temp.vbe
 
 This sentence is the key:
 for /f %%i in ('cscript.exe temp.vbe %EN% //nologo')  do ......
 Using a for loop to read the VBS return result can also be regarded as a solution for batch processing to receive the return result of a script language. (Of course, in this program, it is not necessary to use for necessarily)
 
 
 
 |  | 
|  2006-11-7 04:02 |  | 
|  | 
 
| electronixtar 铂金会员
 
        
 
 
 
 积分 7493
 发帖 2672
 注册 2005-9-2
 状态 离线
 | 
|  『第 3 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
1. 临时文件2. 参数
 3. 变量
 4. 输出重定向
 
1. Temporary files2. Parameters
 3. Variables
 4. Output redirection
 
 
 
 
 
 
 |  
                  |  
 C:\>BLOG http://initiative.yo2.cn/
 C:\>hh.exe ntcmds.chm::/ntcmds.htm
 C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
 |  | 
|  2006-11-7 05:13 |  | 
|  | 
 
| sunyao 初级用户
 
   
 
 
 积分 141
 发帖 60
 注册 2006-10-28
 来自 天津
 状态 离线
 | 
| 『第 4 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
高人举几个例子  解释一下吧 
Experts, please give a few examples and explain them. 
 
 
 |  | 
|  2006-11-7 05:28 |  | 
|  | 
 
| youxi01 高级用户
 
     
 
 
 积分 846
 发帖 247
 注册 2006-10-27
 来自 湖南==》广东
 状态 离线
 | 
| 『第 5 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
electronixtar的意思是,先用vbs脚本或者其它程序将返回结果写入文件,然后利用批处理读取文件就行了。 
The meaning of electronixtar is to first use a VBS script or other programs to write the returned results to a file, and then use batch processing to read the file. 
 
 
 |  | 
|  2006-11-7 05:39 |  | 
|  | 
 
| sunyao 初级用户
 
   
 
 
 积分 141
 发帖 60
 注册 2006-10-28
 来自 天津
 状态 离线
 | 
| 『第 6 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
哦 我明白了youxi01可是用for /f   %%i in ('C:\bea\weblogic91\common\bin\wlst.cmd startserver.py %status% //Nologo') do echo %%i方法不好使
 
Oh, I understand. The method of using `for /f   %%i in ('C:\bea\weblogic91\common\bin\wlst.cmd startserver.py %status% //Nologo') do echo %%i` doesn't work. 
 
 
 |  | 
|  2006-11-7 05:48 |  | 
|  | 
 
| sunyao 初级用户
 
   
 
 
 积分 141
 发帖 60
 注册 2006-10-28
 来自 天津
 状态 离线
 | 
| 『第 7 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
electronixtar麻烦能不能举一个vbs脚本将返回结果写入文件,然后利用批处理读取文件的例子。
 谢谢!!
 
electronixtarCan you please give an example of a VBS script that writes the return result to a file and then uses a batch file to read the file?
 Thank you!
 
 
 
 |  | 
|  2006-11-7 06:45 |  | 
|  | 
 
| electronixtar 铂金会员
 
        
 
 
 
 积分 7493
 发帖 2672
 注册 2005-9-2
 状态 离线
 | 
|  『第 8 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
这个~~我写一个吧 
a.vbs
 CreateObject("Scripting.FileSystemObject").CreateTextFile("test.txt").write "hello"
 
 
b.bat
 for /f  %a in ("test.txt") do @echo %a
 
 
其实我的批处理真的很菜~
This ~~ I'll write one 
a.vbs
 CreateObject("Scripting.FileSystemObject").CreateTextFile("test.txt").write "hello"
 
 
b.bat
 for /f  %a in ("test.txt") do @echo %a
 
 
Actually, my batch processing is really bad~
 
 
 
 
 
 |  
                  |  
 C:\>BLOG http://initiative.yo2.cn/
 C:\>hh.exe ntcmds.chm::/ntcmds.htm
 C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
 |  | 
|  2006-11-7 08:34 |  | 
|  | 
 
| sunyao 初级用户
 
   
 
 
 积分 141
 发帖 60
 注册 2006-10-28
 来自 天津
 状态 离线
 | 
| 『第 9 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
我现在用for /f   %%i in ('C:\bea\weblogic91\common\bin\wlst.cmd startserver.py %status% //Nologo') do echo %%i
 我想在startserver.py文件中取出变量status的值
 怎么就去不出来呢  快疯了
 
I'm now usingfor /f   %%i in ('C:\bea\weblogic91\common\bin\wlst.cmd startserver.py %status% //Nologo') do echo %%i
 I want to get the value of the variable status in the startserver.py file
 Why can't I get it out? I'm going crazy
 
 
 
 |  | 
|  2006-11-7 22:56 |  | 
|  | 
 
| zerocq 中级用户
 
    
 
 
 积分 458
 发帖 196
 注册 2006-10-5
 状态 离线
 | 
| 『第 10 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
把批处理分成两部分第一部分调用vbs产生参数再让vbs调用第二部分批处理带上参数这样可以不?
 
 for /f   %%i in ('C:\bea\weblogic91\common\bin\wlst.cmd startserver.py %status% //Nologo') do echo %%i这句括号里带 %status% //Nologo有什么用的啊??
 
Can the batch be divided into two parts? The first part calls vbs to generate parameters, and then let vbs call the second part of the batch with parameters. Is this possible?
 What is the use of the part with %status% //Nologo in the parentheses of the line for /f   %%i in ('C:\bea\weblogic91\common\bin\wlst.cmd startserver.py %status% //Nologo') do echo %%i?
 
 
 
 |  | 
|  2006-11-7 23:24 |  | 
|  | 
 
| zjh7547 新手上路
 
  
 
 
 
 积分 4
 发帖 2
 注册 2006-9-5
 状态 离线
 | 
| 『第 11 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
批处理中调用SQL脚本时如何返回结果?比如要得到SQL Server 的安装目录 ,在批处理中如何得到?用sql命令就很简单了 ,可惜不知道如何将得到的字符串传回DOS中???
 
How to return results when calling an SQL script in batch processing? For example, to get the installation directory of SQL Server, how to get it in batch processing? It's very simple with the SQL command, but I don't know how to pass the obtained string back to DOS. 
 
 
 |  | 
|  2006-11-7 23:44 |  | 
|  | 
 
| redtek 金牌会员
 
       
 
 
 
 积分 2902
 发帖 1147
 注册 2006-9-21
 状态 离线
 | 
| 『第 12 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
Originally posted by sunyao at 2006-11-7 22:56:我现在用
 for /f   %%i in ('C:\bea\weblogic91\common\bin\wlst.cmd startserver.py %status% //Nologo') do echo %%i
 我想在startserver.py文件中取出变量status的值
 怎么就去不出来堮..
 
) C:\bea\weblogic91\common\bin\wlst.cmd startserver.py %status%都输出什么内容?
 
) %status% 有这个变量吗?内容是什么?
 
) //Nologo 是针对wscript.exe的参数:不显示hui标,执行时不显示标致, 
       这跟你那个wlst.cmd startserver.py %status% 有关系吗? 
Originally posted by sunyao at 2006-11-7 22:56:I am currently using
 for /f   %%i in ('C:\bea\weblogic91\common\bin\wlst.cmd startserver.py %status% //Nologo') do echo %%i
 I want to get the value of the variable status in the startserver.py file
 Why can't I get it...
 
) What does C:\bea\weblogic91\common\bin\wlst.cmd startserver.py %status% output?
 
) Does %status% have this variable? What is the content?
 
) //Nologo is a parameter for wscript.exe: does not display the logo, does not display the logo when executing, 
       Is this related to your wlst.cmd startserver.py %status%? 
 
 
 
 |  
                  |  Redtek,一个永远在网上流浪的人……
 
 _.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
 |  | 
|  2006-11-7 23:52 |  | 
|  | 
 
| sunyao 初级用户
 
   
 
 
 积分 141
 发帖 60
 注册 2006-10-28
 来自 天津
 状态 离线
 | 
| 『第 13 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
我输出startserver.py时显示驱动器中没有标签
 卷的序列号是9c83-6df1
 
When I output startserver.py, it shows:There is no label in the drive
 The serial number of the volume is 9c83-6df1
 
 
 
 |  | 
|  2006-11-8 00:05 |  | 
|  | 
 
| sunyao 初级用户
 
   
 
 
 积分 141
 发帖 60
 注册 2006-10-28
 来自 天津
 状态 离线
 | 
| 『第 14 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
是不是如果dir出不来的文件就查不到呀 
Is it true that files that can't be listed by dir can't be found? 
 
 
 |  | 
|  2006-11-8 00:09 |  | 
|  | 
 
| redtek 金牌会员
 
       
 
 
 
 积分 2902
 发帖 1147
 注册 2006-9-21
 状态 离线
 | 
| 『第 15 楼』:
 
 
使用 LLM 解释/回答一下 
 
 
for /f  "delims="  %%i in ('C:\bea\weblogic91\common\bin\wlst.cmd startserver.py') do echo %%i
 再试一下输出什么?
 
 只要你 c:\bea\weblogic91\common\bin\wlst.cmd startserver.py 的输出信息正常,
 并且 wlst.cmd 代码中没有产生让你的 for /f ....主批处理遇到不可抗力的因素(如:战争、地震、……~:P)。
 
 你 C:\bea\weblogic91\common\bin\wlst.cmd startserver.py 输出的什么文本信息,你for取回了就是什么(除了特殊情况)。
 
 Last edited by redtek on 2006-11-8 at 12:12 AM ]
 
for /f  "delims="  %%i in ('C:\bea\weblogic91\common\bin\wlst.cmd startserver.py') do echo %%i
 Try again, what is output?
 
 As long as the output information of your c:\bea\weblogic91\common\bin\wlst.cmd startserver.py is normal,
 and there are no factors in the wlst.cmd code that cause the main batch processing of for /f .... to encounter不可抗力 (such as war, earthquake, ... ~: P).
 
 What text information is output by your C:\bea\weblogic91\common\bin\wlst.cmd startserver.py, and what you retrieve with for is what (except for special cases).
 
 Last edited by redtek on 2006-11-8 at 12:12 AM ]
 
 
 
 
 |  
                  |  Redtek,一个永远在网上流浪的人……
 
 _.,-*~'`^`'~*-,.__.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._,_.,-*~'`^`'~*-,._
 |  | 
|  2006-11-8 00:10 |  |