如何使用批处理生成vbs文件

时间:2014-10-01 03:57:15

标签: file batch-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

1 个答案:

答案 0 :(得分:0)

最好尝试创建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>