【问题标题】:Create multiple folders by merging two VBS codes通过合并两个 VBS 代码创建多个文件夹
【发布时间】:2020-04-20 16:55:16
【问题描述】:
'I have 2 scripts but could not combine them


'create multiple folders script:

Dim objFSO, objFolder, strDirectory, i 
strDirectory = "C:\Users\test\Desktop\"
Set objFSO = CreateObject("Scripting.FileSystemObject") 
i = 1  ''
While i < 150 
    Set objFolder = objFSO.CreateFolder(strDirectory & i) 
    i = i+1 
    ''WScript.Quit ''
Wend 


'desktop path script

set WshShell = WScript.CreateObject("WScript.Shell")
strDesktop = WshShell.SpecialFolders("Desktop")
wscript.echo(strDesktop)

我希望代码自动找到桌面路径然后创建文件夹,请有人帮帮我吗?

【问题讨论】:

    标签: vbscript adsutil.vbs


    【解决方案1】:

    要获取桌面文件夹路径字符串并创建子目录,您可以这样做:

    Set objShell = Wscript.CreateObject("Wscript.Shell")
    strPath = objShell.SpecialFolders("Desktop")
    
    Dim objFso
    Set objFso = WScript.CreateObject("Scripting.FileSystemObject")
    
    If Not objFso.FolderExists(strPath + "\NewFolder") Then
    objFso.CreateFolder strPath + "\NewFolder"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-24
      • 1970-01-01
      • 1970-01-01
      • 2014-09-05
      • 1970-01-01
      • 1970-01-01
      • 2017-09-13
      • 1970-01-01
      相关资源
      最近更新 更多