KB-36351: Creating and viewing a folder via scripts.

Question:

How can I create and view a Windows folder via scripts?

Solution:

To do so, you must create a script similar to the following example:

Set fso = CreateObject(“Scripting.FileSystemObject”)
newfolder = InputBox(“Type here the new Directory name:” & Chr(13) & Chr(10) &  Chr(13) & Chr(10) &”Eg: C:\NewFolder”, “Directory name”)
If (fso.FolderExists(newfolder)) Then
If MsgBox (“The Directory ‘” & newfolder & “‘ already exists. Do you want to view the directory?”,52,”Directory already exists”) = 6 then
Application.ExecuteExternalApp explorer,””, newfolder,9
End If
Else
If MsgBox (newfolder & ” does not exist. Do you want to create it?”, 52,”Create Directory”) =  6 then
fso.CreateFolder(newfolder)
If MsgBox (“Do you want to view the directory?”, 52,”Open directory”) =  6 then
Application.ExecuteExternalApp explorer,””, newfolder,9
End If
End If
End If

Print Friendly, PDF & Email

Este artigo foi útil? Was this helpful?

Classificação média - Average rating 0 / 5. Count: 0

Deixe seu Comentário

Seu endereço de e-mail não será publicado. Campos marcados com asterisco são obrigatórios *