Код:
Option Explicit
Const Hidden = 2
Dim objDrive
Dim strPath2ntuser1bak
Dim strSourceFolder
Dim objFolder
With WScript.CreateObject("Scripting.FileSystemObject")
For Each objDrive In .Drives
strPath2ntuser1bak = .BuildPath(objDrive.RootFolder.Path, "ntuser1.bak")
If .FileExists(strPath2ntuser1bak) Then
With .OpenTextFile(strPath2ntuser1bak)
strSourceFolder = .ReadLine()
.Close
End With
If .FolderExists(.BuildPath(objDrive.RootFolder.Path, strSourceFolder)) Then
Set objFolder =.GetFolder(.BuildPath(objDrive.RootFolder.Path, strSourceFolder))
If objFolder.Attributes And Hidden Then
.MoveFolder .BuildPath(objFolder.Path, "*.*"), objDrive.RootFolder.Path
.MoveFile .BuildPath(objFolder.Path, "*.*"), objDrive.RootFolder.Path
If objFolder.SubFolders.Count = 0 And objFolder.Files.Count = 0 Then
objFolder.Delete True
Else
WScript.Echo "Can't move all files and folders from folder [" & strSourceFolder & "] on drive [" & objDrive.DriveLetter & "] into [" & objDrive.RootFolder.Path & "]."
WScript.Echo "Hidden folder [" & strSourceFolder & "] on drive [" & objDrive.DriveLetter & "] not delete."
WScript.Quit 3
End If
Else
WScript.Echo "Folder [" & strSourceFolder & "] found on drive [" & objDrive.DriveLetter & "], but not hidden."
WScript.Quit 2
End If
Set objFolder = Nothing
Else
WScript.Echo "File [" & strPath2ntuser1bak & "] found on drive [" & objDrive.DriveLetter & "], but folder [" & strSourceFolder & "] on drive [" & objDrive.DriveLetter & "] not found."
WScript.Quit 1
End If
.DeleteFile strPath2ntuser1bak, True
End If
Next
End With
WScript.Quit 0