找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
查看: 19459|回复: 2

[问题求助] vbs转换成BAT

[复制链接]
发表于 2012-8-8 12:04:14 | 显示全部楼层 |阅读模式
本帖最后由 cwll444 于 2012-8-8 21:38 编辑

一个vbs文件如何转成BAT文件同样实现VBS文件实现的功能。
以下是VBS文件内容
Dim oFSO
Set oFSO = CreateObject("Scripting.FileSystemObject")
Dim oShell
Set oShell = CreateObject("WScript.Shell")
Dim arrPath
arrPath = ""

If oFSO.FolderExists("C:\Drs") Then
FolderTree("C:\Drs")
Else
WScript.Quit
End If


Dim sDevicePath
sDevicePath = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\DevicePath"
oShell.RegWrite sDevicePath,"%SystemRoot%\inf;" & arrPath,"REG_EXPAND_SZ"


' 递归查询文件夹函数
Function FolderTree(sPath)
Dim oFolder,oSubFolder
Set oFolder = oFSO.GetFolder(sPath)

For Each oSubFolder In oFolder.SubFolders
  arrPath = arrPath & oSubFolder.Path & ";"
  FolderTree(oSubFolder.Path)
Next
End Function
发表于 2012-8-8 13:25:46 | 显示全部楼层
本帖最后由 CrLf 于 2012-8-11 19:05 编辑

尽量仿楼主代码:
  1. @echo off
  2. set "arrPath="
  3. if exist C:\Drs\ (call :FolderTree C:\Drs\) else exit
  4. if exist E:\nt5_Driver\ (call :FolderTree E:\nt5_Driver\) else exit

  5. set sDevicePath="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\DevicePath"
  6. reg add %sDevicePath% /t REG_EXPAND_SZ /d "%SystemRoot%\inf;%arrPath%"

  7. goto :eof

  8. :FolderTree
  9. for /f "delims=" %%a in ('dir /s /b /ad"%~1"^|sort) do (
  10.         set "path=%%a"
  11.         setlocal enabledelayedexpansion
  12.         set "sDevicePath=!sDevicePath!!path!;"
  13.         endlocal
  14. )
复制代码
 楼主| 发表于 2012-8-8 20:51:00 | 显示全部楼层
回复 2# CrLf


    还是没有办法实现VBS的效果,咋回事啊
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-3-17 10:23 , Processed in 0.017572 second(s), 8 queries , File On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表