I has two scripts to create folder under %systemroot%(C:\windows), It work fine in win7, but fail in win8.1(I had disabled uac.). It also work when create folder under Drive C (C:\Mylogs) in win8.1
I use vbsedit to convert them to exe, run as administrator, ScriptA still fail, ScriptB work.
What's the difference between Win8.1 and Win7?
How can I use vbs script to create folder under %systemroot%(C:\windows) in win8.1?
ScriptA
set fso = CreateObject("Scripting.FileSystemObject")
CreateFullPath "%systemroot%\MyLogs"
sub CreateFullPath (byval path)
set fso = CreateObject("Scripting.FileSystemObject")
dim parent
path = fso.GetAbsolutePathname(path)
parent = fso.GetParentFolderName(path)
if not fso.FolderExists(parent) then
CreateFullPath parent
end if
if not fso.FolderExists(path) then ' if necessary create subfolder
fso.CreateFolder(path)
end if
end subScriptB
Createfolder("%systemroot%\MyLogs")
Function CreateFolder(path) Dim Wsl,Fso Set Wsl=createobject("wscript.shell") set Fso = CreateObject("Scripting.FileSystemObject") path=Wsl.ExpandEnvironmentStrings(path) If Not Fso.FileExists(path) Then Wsl.Run "cmd /c md " & Chr(34) & path & Chr(34),0,True End If End Function