use*_*912 13 vbscript createobject create-directory
目前这是我的脚本
Set oWS = WScript.CreateObject("WScript.Shell")
' Get the %userprofile% in a variable, or else it won't be recognized
userProfile = oWS.ExpandEnvironmentStrings( "%userprofile%" )
Run Code Online (Sandbox Code Playgroud)
我想要做的是抓住当前用户登录,我希望它检查目录D:\"personsuser"\ Appdata\Roaming\Local,看看是否创建了文件夹"Local",如果没有创建我想在vbs中通过createobject创建一个.上面的脚本来自我所知道的抓取当前登录用户,但是我不知道如何使用此变量来创建文件夹.
我知道我必须在这些方面加入一些东西:
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.CreateFolder("C:\FSO")
Run Code Online (Sandbox Code Playgroud)
或者沿着这些方向的东西:
Dim objNetwork
Dim userName
Dim FSO
Set FSO = CreateObject("Scripting.FileSystemObject")
Set objNetwork = CreateObject("WScript.Network")
userName = objNetwork.userName
If fso.driveExists("D:\" & userName & "\AppData\Local\") Then
FSO.CreateDirectory ("D:\" & userName & "\AppData\Local\")
End If
Run Code Online (Sandbox Code Playgroud)
提前谢谢,不熟悉VBS,但这是我可以在我正在使用它的环境中操作的唯一平台.
Dan*_*man 21
Set oWS = WScript.CreateObject("WScript.Shell")
' Get the %userprofile% in a variable, or else it won't be recognized
userProfile = oWS.ExpandEnvironmentStrings( "%userprofile%" )
Dim objNetwork
Dim userName
Dim FSO
Dim Folder
Set FSO = CreateObject("Scripting.FileSystemObject")
Set objNetwork = CreateObject("WScript.Network")
userName = objNetwork.userName
If NOT (FSO.FolderExists(userProfile + "\AppData\Roaming\Local")) Then
' Delete this if you don't want the MsgBox to show
MsgBox("Local folder doesn't exists, creating...")
splitString = Split(userProfile, "\")
' Create folder
MsgBox("D:\" + splitString(2) + "\AppData\Roaming\Local")
'FSO.CreateFolder(splitString(2) + "\AppData\Roaming\Local")
End If
Run Code Online (Sandbox Code Playgroud)
在这里你走人,这应该是完美的,尊重丹尼尔.
| 归档时间: |
|
| 查看次数: |
75082 次 |
| 最近记录: |