尝试使用Windows 8.1在\ username \ appdata \ local \中创建一个文件夹,但我的代码是找不到错误路径。请帮忙!
Option Explicit
Dim oShell, oEnv, oFS, strDirectory, LocalAppData, wshshell
Set oShell = CreateObject("wscript.Shell")
set oFS = CreateObject("scripting.FileSystemObject")
Set oEnv = oShell.Environment("Process")
set wshshell = createobject("wscript.shell")
strDirectory = oEnv("USERPROFILE") & "\My Documents\MyConnect"
If Not oFS.FolderExists(strDirectory) Then oFS.CreateFolder(strDirectory)
我认为我的错误就在这里
LocalAppData = wshshell.expandenvironmentstrings("%APPDATA%") & "\Local\MyConnectSettings"
If Not oFS.FolderExists (LocalAppData) Then oFS.CreateFolder (LocalAppData)
答案 0 :(得分:0)
.CreateFolder不会创建中间目录(mkdir除外)。因此,请确保%appdata%\local
存在。