标题: [问题求助] vbs转换成BAT [打印本页]
作者: cwll444 时间: 2012-8-8 12:04 标题: vbs转换成BAT
本帖最后由 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
作者: CrLf 时间: 2012-8-8 13:25
本帖最后由 CrLf 于 2012-8-11 19:05 编辑
尽量仿楼主代码:- @echo off
- set "arrPath="
- if exist C:\Drs\ (call :FolderTree C:\Drs\) else exit
- if exist E:\nt5_Driver\ (call :FolderTree E:\nt5_Driver\) else exit
-
- set sDevicePath="HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\DevicePath"
- reg add %sDevicePath% /t REG_EXPAND_SZ /d "%SystemRoot%\inf;%arrPath%"
-
- goto :eof
-
- :FolderTree
- for /f "delims=" %%a in ('dir /s /b /ad"%~1"^|sort) do (
- set "path=%%a"
- setlocal enabledelayedexpansion
- set "sDevicePath=!sDevicePath!!path!;"
- endlocal
- )
复制代码
作者: cwll444 时间: 2012-8-8 20:51
回复 2# CrLf
还是没有办法实现VBS的效果,咋回事啊
欢迎光临 批处理之家 (http://bathome.net./) |
Powered by Discuz! 7.2 |