Имя пользователя:
Пароль:  
Помощь | Регистрация | Забыли пароль?  

Название темы: Скрытые файлы на флешке
Показать сообщение отдельно

Ветеран


Сообщения: 27449
Благодарности: 8086

Профиль | Отправить PM | Цитировать


Ну, с учётом всего вышеизложенного, давайте попробуем так (на WSH):
Скрытый текст
Код: Выделить весь код
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

Хотя, на мой взгляд, куда как проще и надёжнее делать сие под каким-нибудь сторонним файловым менеджером, типа Far Manager.
Это сообщение посчитали полезным следующие участники:

Отправлено: 03:58, 21-08-2016 | #13

Название темы: Скрытые файлы на флешке