-1
'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)

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

4

1 回答 1

0

要获取桌面文件夹路径字符串并创建子目录,您可以执行以下操作:

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"
于 2020-01-01T21:58:38.840 回答