简体   繁体   English

如何批量制作vbs文件

[英]how to make a vbs file with batch

I'm trying to make this batch file that runs a lot of things and it only inputs the last vbs line in to the actual vbs file. 我正在尝试使此批处理文件运行很多东西,并且仅将最后的vbs行输入到实际的vbs文件中。

:run
cls
color 0a
cd "%userprofile% \desk"
if exist run1.vbs del run1.vbs
copy Nul "run1.vbs"

echo set b=createobject("wscript.shell") >> "run1.vbs"
echo x=inputbox ("type:") > "run1.vbs"
echo strtext = (x) > "run1.vbs"

echo if x=("exe") then > "run1.vbs"
echo y=inputbox("run:") > "run1.vbs"

echo b.run (y) > "run1.vbs"
echo end if > "run1.vbs"
echo if x=("spam") then > "run1.vbs"
echo z=inputbox ("spam:") > "run1.vbs"
echo wscript.sleep 2000 > "run1.vbs"
echo for var = 1 to 50 > "run1.vbs"
echo b.sendkeys z > "run1.vbs"
echo b.sendkeys "{ENTER}" > "run1.vbs"
echo next > "run1.vbs"
echo end if > "run1.vbs"

cd "%userprofile% \desk"
start run1.vbs
ping -n 3 127.0.0.1>nul

exit

Better try to create a hybrid file : 最好尝试创建一个混合文件

<!-- : Begin batch script
@echo off

:run
cls
color 0a
cd "%userprofile%\desk"

cscript //nologo "%~f0?.wsf"

ping -n 3 127.0.0.1>nul
exit /b

----- Begin wsf script --->
<job><script language="VBScript">

   set b=createobject("wscript.shell") 
   x=inputbox ("type:") 
   strtext = (x) 

   if x=("exe") then 
   y=inputbox("run:") 

   b.run (y) 
   end if 
   if x=("spam") then 
   z=inputbox ("spam:") 
   wscript.sleep 2000 
   for var = 1 to 50 
   b.sendkeys z 
   b.sendkeys "{ENTER}" 
   next 
   end if 
</script></job>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM