Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes Menú Private Shadows Sub Shown(sender As Object, e As EventArgs) _
Handles MyBase.Shown
Try
Dim Url As New Uri(String.Empty)
Catch ex As Exception
Using ErrorDialog As New RadErrorDialog(ex, sender)
ErrorDialog.ShowDialog()
End Using
End Try
End Sub
Public Class Form1
Public Sub New()
' This call is required by the designer.
InitializeComponent()
' Catches Managed Exceptions.
AddHandler AppDomain.CurrentDomain.FirstChanceException, AddressOf Application_ManagedException
' Catches Unhandled Exceptions.
AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf Application_UnhandledException
' Catches Thread Exceptions.
AddHandler Application.ThreadException, AddressOf Application_ThreadException
End Sub
''' <summary>
''' Handles the 'UnhandledException' event of the Application.
''' </summary>
''' <param name="sender">The source of the event.</param>
''' <param name="e">The <see cref="UnhandledExceptionEventArgs"/> instance containing the event data.</param>
Private Sub Application_UnhandledException(ByVal sender As Object, ByVal e As UnhandledExceptionEventArgs)
Using ErrorDialog As New RadErrorDialog(DirectCast(e.ExceptionObject, Exception), Me)
ErrorDialog.ShowDialog()
End Using
End Sub
''' <summary>
''' Handles the 'FirstChanceException' event of the Application.
''' </summary>
''' <param name="sender">The source of the event.</param>
''' <param name="e">The <see cref="Runtime.ExceptionServices.FirstChanceExceptionEventArgs" /> instance containing the event data.</param>
Private Sub Application_ManagedException(ByVal sender As Object, ByVal e As Runtime.ExceptionServices.FirstChanceExceptionEventArgs)
Using ErrorDialog As New RadErrorDialog(e.Exception, Me)
ErrorDialog.ShowDialog()
End Using
End Sub
''' <summary>
''' Handles the 'ThreadException' event of the Application.
''' </summary>
''' <param name="sender">The source of the event.</param>
''' <param name="e">The <see cref="Threading.ThreadExceptionEventArgs"/> instance containing the event data.</param>
Private Sub Application_ThreadException(sender As Object, e As Threading.ThreadExceptionEventArgs)
Using ErrorDialog As New RadErrorDialog(e.Exception, Me)
ErrorDialog.ShowDialog()
End Using
End Sub
End Class
Public Class Test
Private Sub Test_Handler() Handles MyBase.Shown
' Create a temporal predefined ArrayList.
Dim tmpArrayList As New ArrayList(capacity:=10I)
With tmpArrayList
.Add({"Item0", 0.0F})
.Add({"Item1", 0.5F})
End With
' Check the setting status.
If My.Settings.MRU Is Nothing Then
Debug.WriteLine("MRU setting is null.")
Debug.WriteLine("Initializing the Setting...")
My.Settings.MRU = New ArrayList(capacity:=10I)
ElseIf Not My.Settings.MRU.Count Then
Debug.WriteLine("MRU is not null but the ArrayList is empty.")
Debug.WriteLine("Adding some items...")
My.Settings.MRU = tmpArrayList.Clone
ElseIf My.Settings.MRU.Count Then
Debug.WriteLine("MRU setting is OK.")
Debug.WriteLine("Item Count: " & CStr(My.Settings.MRU.Count))
Threading.Thread.Sleep(Integer.MaxValue)
End If
Debug.WriteLine("Saving any changes")
My.Settings.Save()
Debug.WriteLine("Updating any changes")
My.Settings.Reload()
Debug.WriteLine(String.Empty)
Debug.WriteLine("****************************************")
Debug.WriteLine("Checking again the MRU setting status in...")
For Count As Integer = 1 To 3
Debug.WriteLine(CStr(Count) & New String("."c, Count))
Threading.Thread.Sleep(TimeSpan.FromSeconds(1))
Next
Debug.WriteLine("****************************************")
Debug.WriteLine(String.Empty)
Me.Test_Handler()
End Sub
End Class
' Instance the FileDater Class.
Using fd As New FileDater(File:="C:\Test File.txt")
' Preserve the current date-modified of the file.
fd.Preserve(FileDater.DateType.Modified)
' Do some kind of operation that alters the current date-modified of the file.
IO.File.AppendAllText(fd.File.FullName, New String("X"c, 10I))
' Restore the previously preserved date-modified on the TestFile.
fd.Restore(FileDater.DateType.Modified)
End Using '/ fd
' Instance a test FileInfo using an unique temp file.
Dim TestFile As New IO.FileInfo(IO.Path.GetTempFileName)
' Instance the FileDater Class.
Using fd As New FileDater(File:=TestFile)
' Preserve the current dates of the TestFile.
fd.Preserve(FileDater.DateType.Created Or FileDater.DateType.Accessed Or FileDater.DateType.Modified)
' Show the type of the current preserved dates.
MessageBox.Show(fd.PreservedTypes.ToString)
' Show current preserved date-creation.
MessageBox.Show(fd.PreservedCreationDate.ToString)
' Modify the current date-creation on the TestFile.
fd.Set(FileDater.DateType.Created, Date.Parse("01/01/2015"))
' Restore the previously preserved date-creation on the TestFile.
fd.Restore(FileDater.DateType.Created)
' Show the current Creation date of the TestFile.
MessageBox.Show(TestFile.CreationTime)
End Using
' ***********************************************************************
' Author : Elektro
' Modified : 07-22-2014
' ***********************************************************************
' <copyright file="FileDater.vb" company="Elektro Studios">
' Copyright (c) Elektro Studios. All rights reserved.
' </copyright>
' ***********************************************************************
#Region " Usage Examples "
#Region " Example 1 "
'' Instance the FileDater Class.
'Using fd As New FileDater(File:="C:\Test File.txt")
' ' Preserve the current date-modified of the file.
' fd.Preserve(FileDater.DateType.Modified)
' ' Do some kind of operation that alters the current date-modified of the file.
' IO.File.AppendAllText(fd.File.FullName, New String("X"c, 10I))
' ' Restore the previously preserved date-modified on the TestFile.
' fd.Restore(FileDater.DateType.Modified)
'End Using '/ fd
#End Region
#Region " Example 2 "
'' Instance a test FileInfo using an unique temp file.
'Dim TestFile As New IO.FileInfo(IO.Path.GetTempFileName)
'' Instance the FileDater Class.
'Using fd As New FileDater(File:=TestFile)
' ' Preserve the current dates of the TestFile.
' fd.Preserve(FileDater.DateType.Created Or FileDater.DateType.Accessed Or FileDater.DateType.Modified)
' ' Show the type of the current preserved dates.
' MessageBox.Show(fd.PreservedTypes.ToString)
' ' Show current preserved date-creation.
' MessageBox.Show(fd.PreservedCreationDate.ToString)
' ' Modify the current date-creation on the TestFile.
' fd.Set(FileDater.DateType.Created, Date.Parse("01/01/2015"))
' ' Restore the previously preserved date-creation on the TestFile.
' fd.Restore(FileDater.DateType.Created)
' ' Show the current Creation date of the TestFile.
' MessageBox.Show(TestFile.CreationTime)
'End Using
#End Region
#End Region
#Region " Imports "
Imports System.ComponentModel
Imports System.IO
#End Region
#Region " FileDater "
''' <summary>
''' Contains methods to preserve, set, and restore the dates contained on file.
''' </summary>
Public NotInheritable Class FileDater : Implements IDisposable
#Region " Objects "
''' <summary>
''' Contains the files that are already used in the constructor to prevent a duplicated instance for the same file.
''' </summary>
Private Shared InstancedFiles As New List(Of FileInfo)
#End Region
#Region " Properties "
''' <summary>
''' Gets the file.
''' </summary>
''' <value>The file.</value>
Public ReadOnly Property [File] As FileInfo
Get
Return Me._File
End Get
End Property
Private _File As FileInfo
''' <summary>
''' Gets the type of the current preserved dates.
''' </summary>
Public ReadOnly Property PreservedTypes As DateType
Get
Return Me._PreservedTypes
End Get
End Property
Private _PreservedTypes As DateType = Nothing
''' <summary>
''' Gets the preserved creation date.
''' </summary>
''' <value>The preserved creation date.</value>
Public ReadOnly Property PreservedCreationDate As Date
Get
Return Me._PreservedCreationDate
End Get
End Property
Private _PreservedCreationDate As Date
''' <summary>
''' Gets the preserved last-access date.
''' </summary>
''' <value>The preserved creation date.</value>
Public ReadOnly Property PreservedLastAccessDate As Date
Get
Return Me._PreservedLastAccessDate
End Get
End Property
Private _PreservedLastAccessDate As Date
''' <summary>
''' Gets the preserved last-modify date.
''' </summary>
''' <value>The preserved creation date.</value>
Public ReadOnly Property PreservedLastModifyDate As Date
Get
Return Me._PreservedLastModifyDate
End Get
End Property
Private _PreservedLastModifyDate As Date
#End Region
#Region " Enumerations "
''' <summary>
''' Contains a FileDate flag.
''' </summary>
<FlagsAttribute>
Public Enum DateType As Integer
''' <summary>
''' The date when the file was created.
''' </summary>
Created = 1I
''' <summary>
''' The date when the file was accessed by last time.
''' </summary>
Accessed = 2I
''' <summary>
''' The date when the file was modified by last time.
''' </summary>
Modified = 4I
End Enum
#End Region
#Region " Constructors "
''' <summary>
''' Initializes a new instance of the <see cref="FileDater"/> class.
''' </summary>
''' <param name="File">Indicates the <see cref="FileInfo"/> instance.</param>
''' <exception cref="System.Exception"></exception>
Public Sub New(ByVal [File] As FileInfo)
If Not InstancedFiles.Contains([File]) Then
Me._File = [File]
InstancedFiles.Add([File])
Else
Throw New Exception(String.Format("Another instance of the '{0}' class is using the same file.", MyBase.GetType.Name))
End If
End Sub
''' <summary>
''' Initializes a new instance of the <see cref="FileDater"/> class.
''' </summary>
''' <param name="File">Indicates the file.</param>
Public Sub New(ByVal [File] As String)
Me.New(New FileInfo([File]))
End Sub
''' <summary>
''' Prevents a default instance of the <see cref="FileDater"/> class from being created.
''' </summary>
Private Sub New()
End Sub
#End Region
#Region " Hidden Methods "
''' <summary>
''' Serves as a hash function for a particular type.
''' </summary>
<EditorBrowsable(EditorBrowsableState.Never)>
Public Shadows Sub GetHashCode()
End Sub
''' <summary>
''' Determines whether the specified System.Object instances are considered equal.
''' </summary>
<EditorBrowsable(EditorBrowsableState.Never)>
Public Shadows Sub Equals()
End Sub
''' <summary>
''' Determines whether the specified System.Object instances are the same instance.
''' </summary>
<EditorBrowsable(EditorBrowsableState.Never)>
Private Shadows Sub ReferenceEquals()
End Sub
''' <summary>
''' Returns a String that represents the current object.
''' </summary>
<EditorBrowsable(EditorBrowsableState.Never)>
Public Shadows Sub ToString()
End Sub
#End Region
#Region " Public Methods "
''' <summary>
''' Preserves the specified dates of the file to restore them later at any time.
''' Note: Dates can be preserved again at any time.
''' </summary>
''' <param name="DateType">Indicates the type of dates to preserve.</param>
Public Sub Preserve(ByVal DateType As DateType)
Me.DisposedCheck()
' Creation
If DateType.HasFlag(FileDater.DateType.Created) Then
Me._PreservedCreationDate = Me._File.CreationTime
End If
' Accessed
If DateType.HasFlag(FileDater.DateType.Accessed) Then
Me._PreservedLastAccessDate = Me._File.LastAccessTime
End If
' Modified
If DateType.HasFlag(FileDater.DateType.Modified) Then
Me._PreservedLastModifyDate = Me._File.LastWriteTime
End If
Me._PreservedTypes = DateType
End Sub
''' <summary>
''' Preserves at once all the dates of the file to restore them later at any time.
''' Note: Dates can be preserved again at any time.
''' </summary>
Public Sub Preserve()
Me.DisposedCheck()
Me._PreservedCreationDate = Me._File.CreationTime
Me._PreservedLastAccessDate = Me._File.LastAccessTime
Me._PreservedLastModifyDate = Me._File.LastWriteTime
Me._PreservedTypes = DateType.Created Or DateType.Accessed Or DateType.Modified
End Sub
''' <summary>
''' Restores the specified preserved dates on the file.
''' Note: Calling this method does not cause the deletion of any preserved date.
''' </summary>
''' <param name="DateType">Indicates the type of dates to restore on the file.</param>
''' <exception cref="System.Exception">Any date was preserved.</exception>
Public Sub Restore(ByVal DateType As DateType)
Me.DisposedCheck()
' Creation
If DateType.HasFlag(FileDater.DateType.Created) _
AndAlso Me._PreservedTypes.HasFlag(FileDater.DateType.Created) Then
Me._File.CreationTime = Me._PreservedCreationDate
ElseIf DateType.HasFlag(FileDater.DateType.Created) _
AndAlso Not Me._PreservedTypes.HasFlag(FileDater.DateType.Created) Then
Throw New Exception(String.Format("The specified date was not preserved.")) With {
.Source = FileDater.DateType.Created.ToString
}
End If
' Accessed
If DateType.HasFlag(FileDater.DateType.Accessed) _
AndAlso Me._PreservedTypes.HasFlag(FileDater.DateType.Accessed) Then
Me._File.LastAccessTime = Me._PreservedLastAccessDate
ElseIf DateType.HasFlag(FileDater.DateType.Accessed) _
AndAlso Not Me._PreservedTypes.HasFlag(FileDater.DateType.Accessed) Then
Throw New Exception(String.Format("The specified date was not preserved.")) With {
.Source = FileDater.DateType.Accessed.ToString
}
End If
' Modified
If DateType.HasFlag(FileDater.DateType.Modified) _
AndAlso Me._PreservedTypes.HasFlag(FileDater.DateType.Modified) Then
Me._File.LastWriteTime = Me._PreservedLastModifyDate
ElseIf DateType.HasFlag(FileDater.DateType.Modified) _
AndAlso Not Me._PreservedTypes.HasFlag(FileDater.DateType.Modified) Then
Throw New Exception(String.Format("The specified date was not preserved.")) With {
.Source = FileDater.DateType.Modified.ToString
}
End If
End Sub
''' <summary>
''' Restores at once all the preserved dates on the file.
''' Note: Calling this method does not cause the deletion of any preserved date.
''' </summary>
Public Sub Restore()
Me.DisposedCheck()
' Creation
If Me._PreservedTypes.HasFlag(FileDater.DateType.Created) Then
Me._File.CreationTime = Me._PreservedCreationDate
End If
' Accessed
If Me._PreservedTypes.HasFlag(FileDater.DateType.Accessed) Then
Me._File.LastAccessTime = Me._PreservedLastAccessDate
End If
' Modified
If Me._PreservedTypes.HasFlag(FileDater.DateType.Modified) Then
Me._File.LastWriteTime = Me._PreservedLastModifyDate
End If
End Sub
''' <summary>
''' Sets the specified dates on the file.
''' Note:
''' Calling this method does not cause the deletion of any preserved date.
''' After setting a date, must call once the <see cref="Preserve"/> method if want to preserve any new date established.
''' </summary>
''' <param name="DateType">Indicates the type of dates to set on the file.</param>
''' <param name="Date">Indicates the date.</param>
Public Sub [Set](ByVal DateType As DateType, ByVal [Date] As Date)
Me.DisposedCheck()
' Creation
If DateType.HasFlag(FileDater.DateType.Created) Then
Me._File.CreationTime = [Date]
End If
' Accessed
If DateType.HasFlag(FileDater.DateType.Accessed) Then
Me._File.LastAccessTime = [Date]
End If
' Modified
If DateType.HasFlag(FileDater.DateType.Modified) Then
Me._File.LastWriteTime = [Date]
End If
End Sub
''' <summary>
''' Sets at once all the dates on the file.
''' Note:
''' Calling this method does not cause the deletion of any preserved date.
''' After setting a date, must call once the <see cref="Preserve"/> method if want to preserve any new date established.
''' </summary>
''' <param name="Date">Indicates the date.</param>
Public Sub [Set](ByVal [Date] As Date)
Me.DisposedCheck()
Me._File.CreationTime = [Date]
Me._File.LastAccessTime = [Date]
Me._File.LastWriteTime = [Date]
End Sub
#End Region
#Region " IDisposable "
''' <summary>
''' To detect redundant calls when disposing.
''' </summary>
Private IsDisposed As Boolean = False
''' <summary>
''' Prevent calls to methods after disposing.
''' </summary>
''' <exception cref="System.ObjectDisposedException"></exception>
Private Sub DisposedCheck()
If Me.IsDisposed Then
Throw New ObjectDisposedException(Me.GetType().FullName)
End If
End Sub
''' <summary>
''' Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
''' </summary>
Public Sub Dispose() Implements IDisposable.Dispose
Dispose(True)
GC.SuppressFinalize(Me)
End Sub
''' <summary>
''' Releases unmanaged and - optionally - managed resources.
''' </summary>
''' <param name="IsDisposing">
''' <c>true</c> to release both managed and unmanaged resources;
''' <c>false</c> to release only unmanaged resources.
''' </param>
Protected Sub Dispose(ByVal IsDisposing As Boolean)
If Not Me.IsDisposed Then
If IsDisposing Then
InstancedFiles.Remove(Me._File)
End If
End If
Me.IsDisposed = True
End Sub
#End Region
End Class
#End Region
#EXTM3U
#EXTINF:330,Track1 Title
C:\Track1.avi
C:\Track2.mp4
#EXTINF:5720,Track3 Title
C:\Track3.mp3
[playlist]
NumberOfEntries=3
Version=2
File1=C:/Track1.avi
File2=C:/Track2.mp4
Title2=My Track2 Title!
Length2=5720
File3=C:/Track3.mp3
Title3=My Track3 Title!
Length3=330
' **********************************
' Instance the PlaylistEditor Class
' **********************************
Dim Playlist As New PlaylistEditor(PlaylistFile:="C:\Playlist.m3u",
PlaylistType:=PlaylistEditor.PlaylistType.M3U,
Append:=False,
FileEncoding:=System.Text.Encoding.Default)
' ************************************
' Retrieve the instanced object info
' ************************************
MessageBox.Show(Playlist.FilePath)
MessageBox.Show(Playlist.Type.ToString)
MessageBox.Show(CStr(Playlist.Append))
MessageBox.Show(String.Format("Encoding: {0}, CodePage: {1}",
Playlist.FileEncoding.BodyName,
Playlist.FileEncoding.CodePage))
' ***************************
' Instance a TrackInfo Class
' ***************************
Dim TInfo As New PlaylistEditor.TrackInfo
With TInfo
.Path = "C:\Track1.ext"
.Title = "Track1 Title"
.Length = TimeSpan.Parse("00:05:30")
End With
' ***************
' Add a new track
' ***************
Playlist.Add(TrackInfo:=TInfo)
Playlist.Add(Path:="C:\Track2.ext", AllowDuplicate:=False)
Playlist.Add(Path:="C:\Track3.ext", Title:="Track3 Title", Length:=TimeSpan.Parse("01:35:20"))
' *************************************************
' Sets the extended track info of an existing track
' *************************************************
Dim OldTrackPath As String = "C:\Track3.ext"
Dim TInfoSet As New PlaylistEditor.TrackInfo
With TInfoSet
.Path = "C:\Modified Track3.ext"
.Title = "My modified Track3 title"
.Length = Playlist.GetTrack(OldTrackPath).Length
End With
Playlist.Set(Path:=OldTrackPath, TrackInfo:=TInfoSet)
' ************************
' Remove an existing track
' ************************
Playlist.Remove(Path:="C:\Track3.ext")
Playlist.Remove(TrackIndex:=2I)
' ********************************
' Determine whether a track exists
' ********************************
MessageBox.Show(Playlist.Exist(Path:="C:\Track3.ext"))
MessageBox.Show(Playlist.Exist(TrackIndex:=3I))
' ************************************************
' Count the total amount of tracks in the playlist
' ************************************************
MessageBox.Show(Playlist.Count)
' ************************************
' Get extended track info from a track
' ************************************
Dim TrackInfo1 As PlaylistEditor.TrackInfo = Playlist.GetTrack(Path:="C:\Track1.ext")
Dim TrackInfo2 As PlaylistEditor.TrackInfo = Playlist.GetTrack(TrackIndex:=2I)
' ******************************************
' Get all tracks and its extended track info
' ******************************************
Dim sb As New System.Text.StringBuilder
Dim Tracks As List(Of PlaylistEditor.TrackInfo) = Playlist.GetTracks()
For Each Track As PlaylistEditor.TrackInfo In Tracks
With sb
.Clear()
.AppendLine(String.Format("Track Index : {0}", CStr(Track.Index)))
.AppendLine(String.Format("Track Path : {0}", Track.Path))
.AppendLine(String.Format("Track Title : {0}", Track.Title))
.AppendLine(String.Format("Track Length: {0}", Convert.ToString(Track.Length)))
End With
MessageBox.Show(sb.ToString)
Next Track
' Find Image
' ( By Elektro )
'
' Usage Examples:
'
'Private Sub Test() Handles MyBase.Shown
'
' ' A Desktop Screenshot, in 1920x1080 px. resolution.
' Dim DesktopScreenshoot As New Bitmap("C:\Desktop.png")
'
' ' A cutted piece of the screenshot, in 50x50 px. resolution.
' Dim PartOfDesktopToFind As New Bitmap("C:\PartOfDesktop.png")
'
' ' Find the part of the image in the desktop, with the specified similarity.
' For Each matching As AForge.Imaging.TemplateMatch In
' FindImage(BaseImage:=DesktopScreenshoot, ImageToFind:=PartOfDesktopToFind, Similarity:=80.5R) ' 80,5% Similarity.
'
' Dim sb As New System.Text.StringBuilder
'
' sb.AppendFormat("Top-Left Corner Coordinates: {0}", matching.Rectangle.Location.ToString())
' sb.AppendLine()
' sb.AppendFormat("Similarity Image Percentage: {0}%", (matching.Similarity * 100.0F).ToString("00.00"))
'
' MessageBox.Show(sb.ToString)
'
' Next matching
'
'End Sub
'
''' <summary>
''' Finds a part of an image inside other image and returns the top-left corner coordinates and it's similarity percent.
''' </summary>
''' <param name="BaseImage">
''' Indicates the base image.
''' </param>
''' <param name="ImageToFind">
''' Indicates the image to find in the base image.
''' </param>
''' <param name="Similarity">
''' Indicates the similarity percentage to compare the images.
''' A value of '100' means identical image.
''' Note: High percentage values with big images could take several minutes to finish.
''' </param>
''' <returns>AForge.Imaging.TemplateMatch().</returns>
Private Function FindImage(ByVal BaseImage As Bitmap,
ByVal ImageToFind As Bitmap,
ByVal Similarity As Double) As AForge.Imaging.TemplateMatch()
Dim SingleSimilarity As Single
' Translate the readable similarity percent value to Single value.
Select Case Similarity
Case Is < 0.1R, Is > 100.0R ' Value is out of range.
Throw New Exception(String.Format("Similarity value of '{0}' is out of range, range is from '0.1' to '100.0'",
CStr(Similarity)))
Case Is = 100.0R ' Identical image comparission.
SingleSimilarity = 1.0F
Case Else ' Image comparission with specific similarity.
SingleSimilarity = Convert.ToSingle(Similarity) / 100.0F
End Select
' Set the similarity threshold to find all matching images with specified similarity.
Dim tm As New AForge.Imaging.ExhaustiveTemplateMatching(SingleSimilarity)
' Return all the found matching images,
' it contains the top-left corner coordinates of each one
' and matchings are sortered by it's similarity percent.
Return tm.ProcessImage(BaseImage, ImageToFind)
End Function
' ***********************************************************************
' Author : Elektro
' Last Modified On : 05-13-2014
' ***********************************************************************
' <copyright file="MouseHook.vb" company="Elektro Studios">
' Copyright (c) Elektro Studios. All rights reserved.
' </copyright>
' ***********************************************************************
#Region " Instructions "
' Go to page:
' Project > Properties > Debug
'
' And uncheck the option:
' Enable the Visual Studio Hosting Process
#End Region
#Region " Usage Examples "
' ''' <summary>
' ''' A low level mouse hook that captures mouse events.
' ''' </summary>
'Private WithEvents MouseEvents As MouseHook = Nothing
' ''' <summary>
' ''' Handles the 'MouseLeftDown' event of the Mouse Hook.
' ''' </summary>
' ''' <param name="MouseLocation">Indicates the mouse [X,Y] coordinates.</param>
'Private Sub MouseEvents_MouseLeftDown(ByVal MouseLocation As Point) Handles MouseEvents.MouseLeftDown
'
' Debug.WriteLine(String.Format("Mouse Left Down At: x={0}, y={1}", CStr(MouseLocation.X), CStr(MouseLocation.Y)))
'
'End Sub
' ''' <summary>
' ''' Handles the 'MouseLeftUp' event of the Mouse Hook.
' ''' </summary>
' ''' <param name="MouseLocation">Indicates the mouse [X,Y] coordinates.</param>
'Private Sub MouseEvents_MouseLeftUp(ByVal MouseLocation As Point) Handles MouseEvents.MouseLeftUp
'
' Debug.WriteLine(String.Format("Mouse Left Up At: x={0}, y={1}", CStr(MouseLocation.X), CStr(MouseLocation.Y)))
'
'End Sub
' ''' <summary>
' ''' Handles the 'MouseMove' event of the Mouse Hook.
' ''' </summary>
' ''' <param name="MouseLocation">Indicates the mouse [X,Y] coordinates.</param>
'Private Sub MouseEvents_MouseMove(ByVal MouseLocation As Point) Handles MouseEvents.MouseMove
'
' Debug.WriteLine(String.Format("Mouse Moved To: x={0}, y={1}", CStr(MouseLocation.X), CStr(MouseLocation.Y)))
'
'End Sub
' ''' <summary>
' ''' Handles the 'Click' event of the 'ButtonStartHook' control.
' ''' </summary>
'Private Sub ButtonStartHook() Handles ButtonStartHook.Click
' ' Start the Mouse Hook.
' MouseEvents = New MouseHook
'End Sub
' ''' <summary>
' ''' Handles the 'Click' event of the 'ButtonStopHook' control.
' ''' </summary>
'Private Sub ButtonStopHook() Handles ButtonStopHook.Click
' ' Stop the Mouse Hook.
' MouseEvents = Nothing
'End Sub
#End Region
#Region " Imports "
Imports System.ComponentModel
Imports System.Reflection
Imports System.Runtime.InteropServices
#End Region
#Region " MouseHook "
''' <summary>
''' A low level mouse hook class that captures mouse events.
''' </summary>
Public Class MouseHook
#Region " WinAPI "
#Region " Methods "
''' <summary>
''' Passes the hook information to the next hook procedure in the current hook chain.
''' A hook procedure can call this function either before or after processing the hook information.
''' For more info see here:
''' http://msdn.microsoft.com/en-us/library/windows/desktop/ms644974%28v=vs.85%29.aspx
''' </summary>
''' <param name="idHook">
''' This parameter is ignored.
''' </param>
''' <param name="nCode">
''' The hook code passed to the current hook procedure.
''' The next hook procedure uses this code to determine how to process the hook information.
''' </param>
''' <param name="wParam">
''' The wParam value passed to the current hook procedure.
''' The meaning of this parameter depends on the type of hook associated with the current hook chain.
''' </param>
''' <param name="lParam">
''' The lParam value passed to the current hook procedure.
''' The meaning of this parameter depends on the type of hook associated with the current hook chain.
''' </param>
''' <returns>
''' This value is returned by the next hook procedure in the chain.
''' The current hook procedure must also return this value.
''' The meaning of the return value depends on the hook type.
''' For more information, see the descriptions of the individual hook procedures.
''' </returns>
<DllImport("user32.dll", CallingConvention:=CallingConvention.StdCall, CharSet:=CharSet.Auto)>
Private Shared Function CallNextHookEx(
ByVal idHook As Integer,
ByVal nCode As Integer,
ByVal wParam As Integer,
ByVal lParam As MSLLHOOKSTRUCT
) As Integer
End Function
''' <summary>
''' Installs an application-defined hook procedure into a hook chain.
''' You would install a hook procedure to monitor the system for certain types of events.
''' These events are associated either with a specific thread
''' or with all threads in the same desktop as the calling thread.
''' For more info see here:
''' http://msdn.microsoft.com/en-us/library/windows/desktop/ms644990%28v=vs.85%29.aspx
''' </summary>
''' <param name="idHook">
''' The type of hook procedure to be installed.
''' </param>
''' <param name="lpfn">
''' A pointer to the hook procedure.
''' If the dwThreadId parameter is zero or specifies the identifier of a thread created by a different process,
''' the lpfn parameter must point to a hook procedure in a DLL.
''' Otherwise, lpfn can point to a hook procedure in the code associated with the current process.
''' </param>
''' <param name="hInstance">
''' A handle to the DLL containing the hook procedure pointed to by the lpfn parameter.
''' The hMod parameter must be set to NULL if the dwThreadId parameter specifies a thread created by
''' the current process and if the hook procedure is within the code associated with the current process.
''' </param>
''' <param name="threadId">
''' The identifier of the thread with which the hook procedure is to be associated.
''' For desktop apps, if this parameter is zero, the hook procedure is associated
''' with all existing threads running in the same desktop as the calling thread.
''' </param>
''' <returns>
''' If the function succeeds, the return value is the handle to the hook procedure.
''' If the function fails, the return value is NULL.
''' </returns>
<DllImport("user32.dll", CallingConvention:=CallingConvention.StdCall, CharSet:=CharSet.Auto)>
Private Shared Function SetWindowsHookEx(
ByVal idHook As HookType,
ByVal lpfn As MouseProcDelegate,
ByVal hInstance As IntPtr,
ByVal threadId As Integer
) As Integer
End Function
''' <summary>
''' Removes a hook procedure installed in a hook chain by the 'SetWindowsHookEx' function.
''' For more info see here:
''' http://msdn.microsoft.com/en-us/library/windows/desktop/ms644993%28v=vs.85%29.aspx
''' </summary>
''' <param name="idHook">
''' A handle to the hook to be removed.
''' This parameter is a hook handle obtained by a previous call to SetWindowsHookEx.
''' </param>
''' <returns>
''' If the function succeeds, the return value is nonzero.
''' If the function fails, the return value is zero.
''' </returns>
<DllImport("user32.dll", CallingConvention:=CallingConvention.StdCall, CharSet:=CharSet.Auto)>
Private Shared Function UnhookWindowsHookEx(
ByVal idHook As Integer
) As Boolean
End Function
#End Region
#Region " Enums "
''' <summary>
''' Indicates a type of Hook procedure to be installed.
''' </summary>
<Description("Enum used in 'idHook' parameter of 'SetWindowsHookEx' function")>
Private Enum HookType As Integer
' **************************************
' This enumeration is partially defined.
' **************************************
''' <summary>
''' Installs a hook procedure that monitors low-level mouse input events.
''' For more information, see the LowLevelMouseProc hook procedure.
''' </summary>
WH_MOUSE_LL = 14
End Enum
#End Region
#Region " Structures "
''' <summary>
''' Contains information about a low-level mouse input event.
''' </summary>
<Description("Structure used in 'lParam' parameter of 'CallNextHookEx' function")>
Private Structure MSLLHOOKSTRUCT
''' <summary>
''' The ptThe x- and y-coordinates of the cursor, in screen coordinates.
''' </summary>
Public pt As Point
''' <summary>
''' If the message is 'WM_MOUSEWHEEL', the high-order word of this member is the wheel delta.
''' The low-order word is reserved.
''' A positive value indicates that the wheel was rotated forward, away from the user;
''' a negative value indicates that the wheel was rotated backward, toward the user.
''' One wheel click is defined as 'WHEEL_DELTA', which is '120'.
''' </summary>
Public mouseData As Integer
''' <summary>
''' The event-injected flag.
''' </summary>
Public flags As Integer
''' <summary>
''' The time stamp for this message.
''' </summary>
Public time As Integer
''' <summary>
''' Additional information associated with the message.
''' </summary>
Public dwExtraInfo As Integer
End Structure
#End Region
#End Region
#Region " Variables "
''' <summary>
'''
''' </summary>
Private MouseHook As Integer
#End Region
#Region " Delegates "
''' <summary>
''' Delegate MouseProcDelegate
''' </summary>
''' <returns>System.Int32.</returns>
Private Delegate Function MouseProcDelegate(
ByVal nCode As Integer,
ByVal wParam As Integer,
ByRef lParam As MSLLHOOKSTRUCT
) As Integer
''' <summary>
''' </summary>
Private MouseHookDelegate As MouseProcDelegate
#End Region
#Region " Enums "
''' <summary>
''' Indicates a Windows Message related to a mouse events.
''' For more info see here:
''' http://msdn.microsoft.com/en-us/library/windows/desktop/ff468877%28v=vs.85%29.aspx
''' </summary>
Private Enum MouseWindowsMessages As Integer
''' <summary>
''' Posted to a window when the cursor moves.
''' If the mouse is not captured, the message is posted to the window that contains the cursor.
''' Otherwise, the message is posted to the window that has captured the mouse
''' </summary>
WM_MOUSEMOVE = &H200
''' <summary>
''' Posted when the user presses the left mouse button while the cursor is in the client area of a window.
''' If the mouse is not captured, the message is posted to the window beneath the cursor.
''' Otherwise, the message is posted to the window that has captured the mouse
''' </summary>
WM_LBUTTONDOWN = &H201
''' <summary>
''' Posted when the user releases the left mouse button while the cursor is in the client area of a window.
''' If the mouse is not captured, the message is posted to the window beneath the cursor.
''' Otherwise, the message is posted to the window that has captured the mouse
''' </summary>
WM_LBUTTONUP = &H202
''' <summary>
''' Posted when the user double-clicks the left mouse button while the cursor is in the client area of a window.
''' If the mouse is not captured, the message is posted to the window beneath the cursor.
''' Otherwise, the message is posted to the window that has captured the mouse
''' </summary>
WM_LBUTTONDBLCLK = &H203
''' <summary>
''' Posted when the user presses the right mouse button while the cursor is in the client area of a window.
''' If the mouse is not captured, the message is posted to the window beneath the cursor.
''' Otherwise, the message is posted to the window that has captured the mouse
''' </summary>
WM_RBUTTONDOWN = &H204
''' <summary>
''' Posted when the user releases the right mouse button while the cursor is in the client area of a window.
''' If the mouse is not captured, the message is posted to the window beneath the cursor.
''' Otherwise, the message is posted to the window that has captured the mouse
''' </summary>
WM_RBUTTONUP = &H205
''' <summary>
''' Posted when the user double-clicks the right mouse button while the cursor is in the client area of a window.
''' If the mouse is not captured, the message is posted to the window beneath the cursor.
''' Otherwise, the message is posted to the window that has captured the mouse
''' </summary>
WM_RBUTTONDBLCLK = &H206
''' <summary>
''' Posted when the user presses the middle mouse button while the cursor is in the client area of a window.
''' If the mouse is not captured, the message is posted to the window beneath the cursor.
''' Otherwise, the message is posted to the window that has captured the mouse
''' </summary>
WM_MBUTTONDOWN = &H207
''' <summary>
''' Posted when the user releases the middle mouse button while the cursor is in the client area of a window.
''' If the mouse is not captured, the message is posted to the window beneath the cursor.
''' Otherwise, the message is posted to the window that has captured the mouse
''' </summary>
WM_MBUTTONUP = &H208
''' <summary>
''' Posted when the user double-clicks the middle mouse button while the cursor is in the client area of a window.
''' If the mouse is not captured, the message is posted to the window beneath the cursor.
''' Otherwise, the message is posted to the window that has captured the mouse
''' </summary>
WM_MBUTTONDBLCLK = &H209
''' <summary>
''' Sent to the active window when the mouse's horizontal scroll wheel is tilted or rotated.
''' The DefWindowProc function propagates the message to the window's parent.
''' There should be no internal forwarding of the message,
''' since DefWindowProc propagates it up the parent chain until it finds a window that processes it.
''' </summary>
WM_MOUSEWHEEL = &H20A
End Enum
''' <summary>
''' Indicates the whell direction of the mouse.
''' </summary>
Public Enum WheelDirection
''' <summary>
''' The wheel is moved up.
''' </summary>
WheelUp
''' <summary>
''' The wheel is moved down.
''' </summary>
WheelDown
End Enum
#End Region
#Region " Events "
''' <summary>
''' Occurs when the mouse moves.
''' </summary>
Public Event MouseMove(ByVal MouseLocation As Point)
''' <summary>
''' Occurs when the mouse left button is pressed.
''' </summary>
Public Event MouseLeftDown(ByVal MouseLocation As Point)
''' <summary>
''' Occurs when the mouse left button is released.
''' </summary>
Public Event MouseLeftUp(ByVal MouseLocation As Point)
''' <summary>
''' Occurs when the mouse left button is double-clicked.
''' </summary>
Public Event MouseLeftDoubleClick(ByVal MouseLocation As Point)
''' <summary>
''' Occurs when the mouse right button is pressed.
''' </summary>
Public Event MouseRightDown(ByVal MouseLocation As Point)
''' <summary>
''' Occurs when the mouse right button is released.
''' </summary>
Public Event MouseRightUp(ByVal MouseLocation As Point)
''' <summary>
''' Occurs when the mouse right button is double-clicked.
''' </summary>
Public Event MouseRightDoubleClick(ByVal MouseLocation As Point)
''' <summary>
''' Occurs when the mouse middle button is pressed.
''' </summary>
Public Event MouseMiddleDown(ByVal MouseLocation As Point)
''' <summary>
''' Occurs when the mouse middle button is released.
''' </summary>
Public Event MouseMiddleUp(ByVal MouseLocation As Point)
''' <summary>
''' Occurs when the mouse middle button is double-clicked.
''' </summary>
Public Event MouseMiddleDoubleClick(ByVal MouseLocation As Point)
''' <summary>
''' Occurs when [mouse move].
''' </summary>
Public Event MouseWheel(ByVal MouseLocation As Point,
ByVal WheelDirection As WheelDirection)
#End Region
#Region " Constructors "
''' <summary>
''' Initializes a new instance of this class.
''' </summary>
Public Sub New()
MouseHookDelegate = New MouseProcDelegate(AddressOf MouseProc)
MouseHook = SetWindowsHookEx(HookType.WH_MOUSE_LL,
MouseHookDelegate,
Marshal.GetHINSTANCE(Assembly.GetExecutingAssembly.GetModules()(0)).ToInt32, 0)
End Sub
#End Region
#Region " Protected Methods "
''' <summary>
''' Allows an object to try to free resources
''' and perform other cleanup operations before it is reclaimed by garbage collection.
''' </summary>
Protected Overrides Sub Finalize()
UnhookWindowsHookEx(MouseHook)
MyBase.Finalize()
End Sub
#End Region
#Region " Private Methods "
''' <summary>
''' Processes the mouse windows messages and raises it's corresponding events.
''' </summary>
''' <returns>System.Int32.</returns>
Private Function MouseProc(ByVal nCode As Integer,
ByVal wParam As Integer,
ByRef lParam As MSLLHOOKSTRUCT
) As Integer
If nCode = 0 Then
Select Case wParam
Case MouseWindowsMessages.WM_MOUSEMOVE
RaiseEvent MouseMove(lParam.pt)
Case MouseWindowsMessages.WM_LBUTTONDOWN
RaiseEvent MouseLeftDown(lParam.pt)
Case MouseWindowsMessages.WM_LBUTTONUP
RaiseEvent MouseLeftUp(lParam.pt)
Case MouseWindowsMessages.WM_LBUTTONDBLCLK
RaiseEvent MouseLeftDoubleClick(lParam.pt)
Case MouseWindowsMessages.WM_RBUTTONDOWN
RaiseEvent MouseRightDown(lParam.pt)
Case MouseWindowsMessages.WM_RBUTTONUP
RaiseEvent MouseRightUp(lParam.pt)
Case MouseWindowsMessages.WM_RBUTTONDBLCLK
RaiseEvent MouseRightDoubleClick(lParam.pt)
Case MouseWindowsMessages.WM_MBUTTONDOWN
RaiseEvent MouseMiddleDown(lParam.pt)
Case MouseWindowsMessages.WM_MBUTTONUP
RaiseEvent MouseMiddleUp(lParam.pt)
Case MouseWindowsMessages.WM_MBUTTONDBLCLK
RaiseEvent MouseMiddleDoubleClick(lParam.pt)
Case MouseWindowsMessages.WM_MOUSEWHEEL
Dim wDirection As WheelDirection
If lParam.mouseData < 0 Then
wDirection = WheelDirection.WheelDown
Else
wDirection = WheelDirection.WheelUp
End If
RaiseEvent MouseWheel(lParam.pt, wDirection)
End Select
End If
Return CallNextHookEx(MouseHook, nCode, wParam, lParam)
End Function
#End Region
End Class
#End Region
' ***********************************************************************
' Author : Elektro
' Last Modified On : 06-03-2014
' ***********************************************************************
' <copyright file="RegionSelector.vb" company="Elektro Studios">
' Copyright (c) Elektro Studios. All rights reserved.
' </copyright>
' ***********************************************************************
#Region " Usage Examples "
'Public Class Form1
' Dim SelectedRegion As Rectangle = Rectangle.Empty
' Dim RegionSelectorIsWorking As Boolean = False
' Private Sub Button_Click() Handles Button1.Click
' GetScreenRegion()
' End Sub
' Public Sub GetScreenRegion()
' Dim Callback As RegionSelector.RegionSelectedDelegate
' Dim Selector As New RegionSelector(BorderColor:=Color.YellowGreen,
' BorderSize:=3,
' backgroundcolor:=Color.YellowGreen,
' BackgroundOpacity:=0.06R)
' Select Case RegionSelectorIsWorking
' Case True ' Only one selection at once!
' Exit Sub
' Case Else
' RegionSelectorIsWorking = True
' Callback = New RegionSelector.RegionSelectedDelegate(AddressOf SelectionFinished)
' With Selector
' .Callback = Callback
' .Show()
' End With
' End Select
' ' Don't do any stuff here... do it in Rectangle Drawn...
' End Sub
' Private Sub SelectionFinished(ByVal Region As Rectangle)
' RegionSelectorIsWorking = False ' Allow draw again.
' Me.SelectedRegion = Region
' Dim sb As New System.Text.StringBuilder
' With sb
' .AppendLine("Selected Area")
' .AppendLine()
' .AppendLine("· Size")
' .AppendLine(String.Format("Width: {0}", CStr(SelectedRegion.Width)))
' .AppendLine(String.Format("Height: {0}", CStr(SelectedRegion.Height)))
' .AppendLine()
' .AppendLine("· Coordinates")
' .AppendLine(String.Format("Top: {0}", CStr(SelectedRegion.Top)))
' .AppendLine(String.Format("Left: {0}", CStr(SelectedRegion.Left)))
' .AppendLine(String.Format("Right: {0}", CStr(SelectedRegion.Right)))
' .AppendLine(String.Format("Bottom: {0}", CStr(SelectedRegion.Bottom)))
' .AppendLine()
' End With
' MessageBox.Show(sb.ToString)
' End Sub
'End Class
#End Region
''' <summary>
''' Selects a region on the Screen.
''' </summary>
Public NotInheritable Class RegionSelector : Inherits Form
#Region " Delegates "
''' <summary>
''' Delegate RegionSelectedDelegate.
''' </summary>
''' <param name="Region">The region.</param>
Public Delegate Sub RegionSelectedDelegate(ByVal Region As Rectangle)
#End Region
#Region " Properties "
''' <summary>
''' Callback to be invoked when drawing is done...
''' </summary>
''' <value>Delegate of Region Selected</value>
Public Property Callback As RegionSelectedDelegate = Nothing
''' <summary>
''' Gets or sets the border size of the region selector.
''' </summary>
''' <value>The size of the border.</value>
Public Property BorderSize As Integer = 2
''' <summary>
''' Gets or sets the border color of the region selector.
''' </summary>
''' <value>The color of the border.</value>
Public Property BorderColor As Color = Color.Red
''' <summary>
''' Gets or sets the background color of the region selector.
''' </summary>
''' <value>The color of the border.</value>
Public Property BackgroundColor As Color = Color.RoyalBlue
''' <summary>
''' Gets or sets the background opacity of the region selector.
''' </summary>
''' <value>The color of the border.</value>
Public Property BackgroundOpacity As Double = 0.08R
''' <summary>
''' Gets the rectangle that contains the selected region.
''' </summary>
Public ReadOnly Property SelectedRegion As Rectangle
Get
Return Me.DrawRect
End Get
End Property
#End Region
#Region " Objects "
''' <summary>
''' Indicates the initial location when the mouse left button is clicked.
''' </summary>
Private InitialLocation As Point = Point.Empty
''' <summary>
''' The rectangle where to draw the region.
''' </summary>
Public DrawRect As Rectangle = Rectangle.Empty
''' <summary>
''' The Graphics object to draw on the screen.
''' </summary>
Private ScreenGraphic As Graphics = Graphics.FromHwnd(IntPtr.Zero)
''' <summary>
''' Indicates the Rectangle Size.
''' </summary>
Dim DrawSize As Size
''' <summary>
''' Indicates the draw form.
''' </summary>
Dim DrawForm As Form
''' <summary>
''' Indicates whether the RegionSelector is busy drawing the rectangle.
''' </summary>
Public IsDrawing As Boolean = False
#End Region
#Region " Constructors "
''' <summary>
''' Initializes a new instance of the <see cref="RegionSelector"/> class.
''' </summary>
Public Sub New()
End Sub
''' <summary>
''' Initializes a new instance of the <see cref="RegionSelector" /> class.
''' </summary>
''' <param name="BorderColor">Indicates the border color of the region selector.</param>
''' <param name="BorderSize">Indicates the border size of the region selector.</param>
''' <param name="BackgroundColor">Indicates the background color of the region selector.</param>
''' <param name="BackgroundOpacity">Indicates the background opacity size of the region selector.</param>
Public Sub New(Optional ByVal BorderColor As Color = Nothing,
Optional ByVal BorderSize As Integer = 2,
Optional ByVal BackgroundColor As Color = Nothing,
Optional ByVal BackgroundOpacity As Double = 0.1R)
If BorderColor = Nothing _
OrElse BorderColor = Color.Transparent Then
BorderColor = Color.Red
End If
If BackgroundColor = Nothing _
OrElse BackgroundColor = Color.Transparent Then
BackgroundColor = Color.Black
End If
Me.BorderSize = BorderSize
Me.BorderColor = BorderColor
Me.BackgroundOpacity = BackgroundOpacity
Me.BackgroundColor = BackgroundColor
End Sub
#End Region
#Region " Event Handlers "
''' <summary>
''' Handles the Load event of the RegionSelector.
''' </summary>
''' <param name="sender">The source of the event.</param>
''' <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
Private Sub RegionSelector_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Me.SuspendLayout()
Me.AutoScaleMode = AutoScaleMode.None
Me.BackColor = Me.BackgroundColor
Me.BackgroundImageLayout = ImageLayout.None
Me.CausesValidation = False
Me.ClientSize = New Size(0, 0)
Me.ControlBox = False
Me.Cursor = Cursors.Cross
Me.DoubleBuffered = True
Me.FormBorderStyle = FormBorderStyle.None
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "RegionSelector"
Me.Opacity = Me.BackgroundOpacity
Me.ShowIcon = False
Me.ShowInTaskbar = False
Me.SizeGripStyle = SizeGripStyle.Hide
Me.StartPosition = FormStartPosition.CenterScreen
Me.TopMost = False
Me.WindowState = FormWindowState.Maximized
Me.ResumeLayout(False)
Me.DrawForm = New DrawingRegionClass(Me)
With DrawForm
.AutoScaleMode = AutoScaleMode.None
.BackColor = Color.Tomato
.BackgroundImageLayout = ImageLayout.None
.ControlBox = False
.FormBorderStyle = FormBorderStyle.None
.MaximizeBox = False
.MinimizeBox = False
.ShowIcon = False
.ShowInTaskbar = False
.SizeGripStyle = SizeGripStyle.Hide
.StartPosition = FormStartPosition.CenterScreen
.TopLevel = True
.TopMost = True
.TransparencyKey = Color.Tomato
.WindowState = FormWindowState.Maximized
End With
Me.AddOwnedForm(Me.DrawForm)
Me.DrawForm.Show()
End Sub
''' <summary>
''' Raises the <see cref="E:System.Windows.Forms.Control.MouseDown" /> event.
''' </summary>
''' <param name="e">A <see cref="T:System.Windows.Forms.MouseEventArgs" /> that contains the event data.</param>
Protected Overrides Sub OnMouseDown(ByVal e As MouseEventArgs)
If e.Button = MouseButtons.Left Then
Me.InitialLocation = e.Location
Me.IsDrawing = True
End If
End Sub
''' <summary>
''' Raises the <see cref="E:System.Windows.Forms.Control.MouseUp" /> event.
''' </summary>
''' <param name="e">A <see cref="T:System.Windows.Forms.MouseEventArgs" /> that contains the event data.</param>
Protected Overrides Sub OnMouseUp(ByVal e As MouseEventArgs)
Me.IsDrawing = False
Callback.Invoke(SelectedRegion)
Me.Close() ' Must be called last.
End Sub
''' <summary>
''' Raises the <see cref="E:System.Windows.Forms.Control.MouseMove" /> event.
''' </summary>
''' <param name="e">A <see cref="T:System.Windows.Forms.MouseEventArgs" /> that contains the event data.</param>
Protected Overrides Sub OnMouseMove(ByVal e As MouseEventArgs)
If Me.IsDrawing Then
Me.DrawSize = New Size(e.X - Me.InitialLocation.X, e.Y - Me.InitialLocation.Y)
Me.DrawRect = New Rectangle(Me.InitialLocation, Me.DrawSize)
If Me.DrawRect.Height < 0 Then
Me.DrawRect.Height = Math.Abs(Me.DrawRect.Height)
Me.DrawRect.Y -= Me.DrawRect.Height
End If
If Me.DrawRect.Width < 0 Then
Me.DrawRect.Width = Math.Abs(Me.DrawRect.Width)
Me.DrawRect.X -= Me.DrawRect.Width
End If
Me.DrawForm.Invalidate()
End If
End Sub
#End Region
End Class
''' <summary>
''' Class DrawingRegionClass. This class cannot be inherited.
''' </summary>
Friend NotInheritable Class DrawingRegionClass : Inherits Form
Private DrawParent As RegionSelector
Public Sub New(ByVal Parent As Form)
Me.DrawParent = Parent
End Sub
Protected Overrides Sub OnPaintBackground(ByVal e As PaintEventArgs)
Dim Bg As Bitmap
Dim Canvas As Graphics
If Me.DrawParent.IsDrawing Then
Bg = New Bitmap(Width, Height)
Canvas = Graphics.FromImage(Bg)
Canvas.Clear(Color.Tomato)
Using pen As New Pen(Me.DrawParent.BorderColor, Me.DrawParent.BorderSize)
Canvas.DrawRectangle(pen, Me.DrawParent.DrawRect)
End Using
Canvas.Dispose()
e.Graphics.DrawImage(Bg, 0, 0, Width, Height)
Bg.Dispose()
Else
MyBase.OnPaintBackground(e)
End If
End Sub
End Class
' Take Region ScreenShot
' ( By Elektro )
'
' Usage Examples :
'
' Dim RegionScreenShot As Bitmap = TakeRegionScreenShot(New Point(0, 0), New Size(256, 256))
' Dim RegionScreenShot As Bitmap = TakeRegionScreenShot(New Rectangle With {.Location = Point.Empty, .Size = New Size(256, 256)})
' PictureBox1.BackgroundImage = RegionScreenShot
' RegionScreenShot.Save("C:\RegionScreenShot.png", Imaging.ImageFormat.Png)
'
''' <summary>
''' Takes an image screenshot of an specific screen region.
''' </summary>
''' <param name="Coordinates">
''' The X-coordinate is the point at the upper-left corner of the region.
''' The Y-coordinate is the point at the upper-left corner of the region.
''' </param>
''' <param name="Size">Indicates the size of the area to be transferred.</param>
''' <param name="PixelFormat">Indicates the Bitmap pixel format.</param>
''' <returns>Bitmap.</returns>
Private Function TakeRegionScreenShot(ByVal Coordinates As Point,
ByVal [Size] As Size,
Optional ByVal [PixelFormat] As Imaging.PixelFormat =
Imaging.PixelFormat.Format24bppRgb) As Bitmap
Using ScreenImage As New Bitmap([Size].Width, [Size].Height, [PixelFormat])
Using ScreenGraphics As Graphics = Graphics.FromImage(ScreenImage)
ScreenGraphics.CopyFromScreen(Coordinates, Point.Empty, ScreenImage.Size)
End Using ' ScreenGraphics
Return CType(ScreenImage.Clone, Bitmap)
End Using ' ScreenImage
End Function
''' <summary>
''' Takes an image screenshot of an specific screen region.
''' </summary>
''' <param name="Region">Indicates a Rectangle structure that contains the region coordinates and the size.</param>
''' <param name="PixelFormat">Indicates the Bitmap pixel format.</param>
''' <returns>Bitmap.</returns>
Private Function TakeRegionScreenShot(ByVal [Region] As Rectangle,
Optional ByVal [PixelFormat] As Imaging.PixelFormat =
Imaging.PixelFormat.Format24bppRgb) As Bitmap
Return TakeRegionScreenShot([Region].Location, [Region].Size, [PixelFormat])
End Function
' Count Agrupations In String
' // By Elektro
'
' Example Usages :
'
'Private Sub Test()
'
' Dim InputStrings As String() =
' {
' "(This) is (good)",
' "This (is (good))",
' "This is good",
' "This is (bad))",
' "This is (bad",
' "This is bad)",
' "This is bad)("
' }
'
' Dim AgrupationChars As New Tuple(Of Char, Char)("(", ")")
'
' For Each InputString As String In InputStrings
'
' Dim Info As AgrupationCharsInfo = Me.CountAgrupationsInString(AgrupationChars, InputString)
'
' Dim sb As New System.Text.StringBuilder
'
' With sb
'
' .AppendLine(String.Format("Input String: {0}", Info.InputString))
' .AppendLine(String.Format("Agrupation Characters: {0}{1}", Info.AgrupationChars.Item1,
' Info.AgrupationChars.Item2))
'
' .AppendLine()
' .AppendLine(String.Format("String has closed agrupations?: {0}", Info.StringHasClosedAgrupations))
' .AppendLine(String.Format("String has opened agrupations?: {0}", Info.StringHasOpenedAgrupations))
'
' .AppendLine()
' .AppendLine(String.Format("Closed Agrupations Count: {0}", Info.CountClosedAgrupations))
' .AppendLine(String.Format("Opened Agrupations Count: {0}", Info.CountOpenedAgrupations))
'
' .AppendLine()
' .AppendLine("Closed Agrupations Indexes:")
' For Each Item As Tuple(Of Integer, Integer) In Info.ClosedAgrupationsIndex
' .AppendLine(String.Format("Start: {0}, End: {1}",
' CStr(Item.Item1), CStr(Item.Item2)))
' Next Item
'
' .AppendLine()
' .AppendLine(String.Format("Opened Agrupations Indexes: {0}",
' String.Join(", ", Info.OpenedAgrupationsIndex)))
'
' End With '/ sb
'
' MessageBox.Show(sb.ToString, "Agrupations Information",
' MessageBoxButtons.OK, MessageBoxIcon.Information)
'
' Next InputString
'
'End Sub
''' <summary>
''' Retrieves info about the closed and opened agrupation characters inside a String.
''' </summary>
''' <param name="AgrupationChars">Indicates the characters to determine agrupations.</param>
''' <param name="InputString">Indicates the string where to count the agrupations.</param>
''' <returns>AgrupationCharsInfo.</returns>
''' <exception cref="System.Exception">'InputString' parameter cannot be an empty String..</exception>
Public Function CountAgrupationsInString(ByVal AgrupationChars As Tuple(Of Char, Char),
ByVal InputString As String) As AgrupationCharsInfo
If String.IsNullOrEmpty(InputString) OrElse String.IsNullOrWhiteSpace(InputString) Then
Throw New Exception("'InputString' parameter cannot be an empty String.")
End If
Dim CharStack As New Stack(Of Integer)
Dim Result As New AgrupationCharsInfo
With Result
.InputString = InputString
.AgrupationChars = New Tuple(Of Char, Char)(AgrupationChars.Item1, AgrupationChars.Item2)
For i As Integer = 0 To InputString.Length - 1
Select Case InputString(i)
Case .AgrupationChars.Item1
CharStack.Push(i)
.OpenedAgrupationsIndex.Add(i)
.CountOpenedAgrupations += 1
Case .AgrupationChars.Item2
Select Case CharStack.Count
Case Is = 0
.CountOpenedAgrupations += 1
.OpenedAgrupationsIndex.Add(i)
Case Else
.CountClosedAgrupations += 1
.CountOpenedAgrupations -= 1
.ClosedAgrupationsIndex.Add(Tuple.Create(Of Integer, Integer)(CharStack.Pop, i))
.OpenedAgrupationsIndex.RemoveAt(.OpenedAgrupationsIndex.Count - 1)
End Select '/ CharStack.Count
End Select '/ InputString(i)
Next i
.StringHasClosedAgrupations = .CountClosedAgrupations <> 0
.StringHasOpenedAgrupations = .CountOpenedAgrupations <> 0
End With '/ Result
Return Result
End Function
''' <summary>
''' Stores info about closed and opened agrupations of chars in a String.
''' </summary>
Public NotInheritable Class AgrupationCharsInfo
''' <summary>
''' Indicates the input string.
''' </summary>
''' <value>The input string.</value>
Public Property InputString As String = String.Empty
''' <summary>
''' Indicates the agrupation characters.
''' </summary>
''' <value>The agrupation characters.</value>
Public Property AgrupationChars As Tuple(Of Char, Char) = Nothing
''' <summary>
''' Determines whether the input string contains closed agrupation.
''' </summary>
Public Property StringHasClosedAgrupations As Boolean = False
''' <summary>
''' Determines whether the input string contains opened agrupations.
''' </summary>
Public Property StringHasOpenedAgrupations As Boolean = False
''' <summary>
''' Indicates the total amount of closed agrupations.
''' </summary>
''' <value>The closed agrupations count.</value>
Public Property CountClosedAgrupations As Integer = 0
''' <summary>
''' Indicates the total amount of opened agrupations.
''' </summary>
''' <value>The opened agrupations count.</value>
Public Property CountOpenedAgrupations As Integer = 0
''' <summary>
''' Indicates the closed agrupations index positions in the string.
''' </summary>
''' <value>The closed agrupations index positions.</value>
Public Property ClosedAgrupationsIndex As New List(Of Tuple(Of Integer, Integer))
''' <summary>
''' Indicates the opened agrupations index positions in the string.
''' </summary>
''' <value>The opened agrupations index positions.</value>
Public Property OpenedAgrupationsIndex As New List(Of Integer)
End Class '/ AgrupationCharsInfo
Private Shadows Sub Shown(sender As Object, e As EventArgs) _
Handles MyBase.Shown
Try
Dim Url As New Uri(String.Empty)
Catch ex As Exception
Using ErrorDialog As New ErrorDialog(ex, sender)
ErrorDialog.ShowDialog()
End Using
End Try
End Sub
Public Class Form1
Public Sub New()
' This call is required by the designer.
InitializeComponent()
' Catches Managed Exceptions.
AddHandler AppDomain.CurrentDomain.FirstChanceException, AddressOf Application_ManagedException
' Catches Unhandled Exceptions.
AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf Application_UnhandledException
' Catches Thread Exceptions.
AddHandler Application.ThreadException, AddressOf Application_ThreadException
End Sub
''' <summary>
''' Handles the 'UnhandledException' event of the Application.
''' </summary>
''' <param name="sender">The source of the event.</param>
''' <param name="e">The <see cref="UnhandledExceptionEventArgs"/> instance containing the event data.</param>
Private Sub Application_UnhandledException(ByVal sender As Object, ByVal e As UnhandledExceptionEventArgs)
Using ErrorDialog As New ErrorDialog(DirectCast(e.ExceptionObject, Exception), Me)
ErrorDialog.ShowDialog()
End Using
End Sub
''' <summary>
''' Handles the 'FirstChanceException' event of the Application.
''' </summary>
''' <param name="sender">The source of the event.</param>
''' <param name="e">The <see cref="Runtime.ExceptionServices.FirstChanceExceptionEventArgs" /> instance containing the event data.</param>
Private Sub Application_ManagedException(ByVal sender As Object, ByVal e As Runtime.ExceptionServices.FirstChanceExceptionEventArgs)
Using ErrorDialog As New ErrorDialog(e.Exception, Me)
ErrorDialog.ShowDialog()
End Using
End Sub
''' <summary>
''' Handles the 'ThreadException' event of the Application.
''' </summary>
''' <param name="sender">The source of the event.</param>
''' <param name="e">The <see cref="Threading.ThreadExceptionEventArgs"/> instance containing the event data.</param>
Private Sub Application_ThreadException(sender As Object, e As Threading.ThreadExceptionEventArgs)
Using ErrorDialog As New ErrorDialog(e.Exception, Me)
ErrorDialog.ShowDialog()
End Using
End Sub
End Class
Run Bootable Images\WinPE.iso
@Echo OFF
REM =================
REM Console Settings:
REM =================
Title WIM Resource Replacer - By Elektro
Mode Con Cols=150 Lines=50
CHCP 1252 1>NUL & REM Windows-1252, Spanish-Latin.
REM =====
REM Info:
REM =====
Echo+
Echo --------------------------------------------------------------------------------------------------
Echo This script mounts a Windows Image ^(WIM^) and then replaces image resources inside resource files
Echo --------------------------------------------------------------------------------------------------
Echo+
REM ====================
REM User defined values:
REM ====================
REM This value indicates whether the Windows Image should be mounted.
REM True = 'DISM' will try to mount the 'WIM' image.
REM False = 'DISM' will not try to mount the WIM image.
REM Set this value to 'FALSE' if the 'WIM' image is already mounted in the specified mount directory,
REM Otherwise, keep it as 'TRUE'.
Set "MountImage=True"
REM This value indicates whether the Windows Image should be unmounted at the end.
REM True = 'DISM' will try to unmount the 'WIM' image.
REM False = 'DISM' will not try to unmount the WIM image.
REM Set this value to 'FALSE' if you want to keep the image mounted to make other changes,
REM Otherwise, keep it as 'TRUE'.
Set "UnmountImage=True"
REM This value indicates whether the Windows Image should be rebuilt at the end.
REM True = 'ImageX' will try to rebuild the 'WIM' image.
REM False = 'ImageX' will keep the 'WIM' image as is.
REM Set this value to 'FALSE' if you want to keep the image with normal size to make other changes,
REM Otherwise, keep it as 'TRUE'.
Set "Rebuild=True"
REM This value indicates whether the Windows Image should be cleaned-up at the end.
REM True = 'Dism' will try to CleanUp the 'WIM' image components.
REM False = 'Dism' will keep the 'WIM' image as is.
REM Set this value to 'FALSE' if you want to keep the image with normal size to make other changes,
REM Otherwise, keep it as 'TRUE'.
Set "CleanUp=True"
REM This value indicates the 'WIM' image to be mounted.
Set "WindowsImage=%UserProfile%\Desktop\win 8 .1\win\sources\Boot.wim"
REM This value indicates the Image Index of the 'WIM' image.
Set "ImageIndex=2"
REM This value indicates the directory where to mount the 'WIM' image.
Set "MountDir=%HomeDrive%\WinBootMount"
REM This value indicates the ubication of Anolis Resourcer 'Anolis.exe' file.
Set "Anolis=%CD%\Tools\Anolis.exe"
REM This value indicates the textfile that contains the Recource files to replace.
Set "ResourceList=%CD%\Resources.txt"
REM This value indicates the ubication of 'ImageX.exe' file.
Set "ImageX=%CD%\Tools\Dism\ImageX.exe"
REM This value indicates the ubication of a custom 'DISM.exe' file if needed.
REM Default ubication: "%SystemRoot%\System32\Dism.exe"
Set "Dism=%CD%\Tools\Dism\Dism.exe"
REM This value indicates the ubication of the logfile that will record 'DISM' errors.
Set "DismLogfile=%CD%\%~n0 DISM.log"
REM This value indicates the logging-level of the 'DISM' process.
REM 1 = Errors only
REM 2 = Errors and warnings
REM 3 = Errors, warnings, and informational
REM 4 = All of the information listed previously, plus debug output
Set /A "DismLogLevel=2"
REM This value indicates the ubication of the logfile that will record Main information.
Set "Logfile=%CD%\%~n0.log"
REM =====
REM Main:
REM =====
:: Call Methods.
Call :CheckErrors
Call :CreateLogs
Call :CreateMountDir
Call :GetWIMSizeBefore
Call :StartTimer
Call :Mount
CLS
Call :ParseResources
Call :Unmount
Call :StopTimer
Call :GetWIMSizeAfter
Call :EndLog
Pause&Exit
REM ========
REM Methods:
REM ========
:CreateLogs
:: Create the 'DISM' logfile with 'ANSI' encoding,
:: this is necessary to record a non-default 'DISM' loglevel such as '1' or '2'.
Echo+ >"%Logfile%"
:: Create the Main Logfile and record starting info on it.
(
Echo+
Echo WIM Resource Replacer
Echo ===========================
Echo %DATE% ^| %TIME:~0,-3%
Echo /\/\/\/\/\/\/\/\/\/\/\/\/\/
Echo+
Echo [i] Mount Image?...: %MountImage%
Echo [i] Unmount Image?.: %UnmountImage%
Echo [i] CleanUp Image?.: %CleanUp%
Echo [i] Rebuild Image?.: %Rebuild%
Echo+
Echo [i] Windows Image..: %WindowsImage%
Echo [i] Image Index....: %ImageIndex%
Echo [i] Mount Directory: %MountDir%
Echo+
Echo [i] ImageX Path....: %ImageX%
Echo [i] Dism Path......: %Dism%
Echo [i] Dism Log File..: %DismLogfile%
Echo [i] Dism Log Level.: %DismLogLevel%
Echo+
Echo [i] Anolis Path....: %Anolis%
Echo [i] Resource List..: %ResourceList%
Echo [i] Log File.......: %LogFile%
Echo+
Echo ===========================
)>"%Logfile%"
:: Display starting log info.
Type "%Logfile%"
:: Continue writting log.
(
Echo+
Echo Resource conflicts:
Echo ===================
Echo+
)>>"%LogFile%"
Goto:EOF
:EndLog
(
Echo+
Echo [i] Done!
Echo [i] WIM Size Before....: %WIMSizeBefore%
Echo [i] WIM Size After.....: %WIMSizeAfter%
Echo [i] Resources Success..: %ResourceSuccessCount% files.
Echo [i] Resources Failed...: %ResourceFailsCount% files.
Echo [i] Resources Not Found: %ResourceNotFoundCount% files.
Echo [i] Files Added........: %FilesAddedCount% files.
Echo [i] Files Failed.......: %FilesFailsCount% files.
Echo [i] Files Not Found....: %FilesNotFoundCount% files.
Echo [i] Elapsed Time.......: %ElapsedTime%
Echo+
)>>"%LogFile%"
:: Display ending information.
CLS
Type "%LogFile%"
Goto:EOF
:CreateMountDir
:: Create the mount directory.
(
If Not Exist "%MountDir%" If /I "%MountImage%" EQU "True" (
MkDir "%MountDir%" 2>NUL
)
) || (
Echo+
Echo [x] Error trying to create the directory "%MountDir%" to mount the Windows Image.
Echo [i] Ensure that you have Admin rights to create the directory.
Echo [i] Ensure that the directory name does not contains illegal characters.
Echo+
Pause&Exit
)
Goto:EOF
:Mount
:: Mount the Windows Image into the directory.
Echo+
Echo [+] Mounting WIM Image...
If /I "%MountImage%" EQU "True" (
"%Dism%" /Mount-Image /ImageFile:"%WindowsImage%" /Index:"%ImageIndex%" /MountDir:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%" || (
Echo+
Echo [x] Error mounting the Image Index "%ImageIndex%" in "%MountDir%"
Echo [i] Ensure that the Image Index exist.
Echo [i] Ensure that you have Admin rights to write inside the directory.
Echo [i] Ensure that the directory is not already mounted.
Echo [i] Ensure that the directory is fully empty.
Echo+
REM Try to unmount the failed image and discard changes.
If /I "%UnmountImage%" EQU "True" (
Echo [+] Unmounting and discarding changes...
"%Dism%" /Unmount-WIM /Discard /MountDir:"%MountDir%"
)
Pause&Exit
)
)
Goto:EOF
:CleanUp
Echo [+] CleaningUp WIM Image...
"%Dism%" /CleanUp-Image /StartComponentCleanUp /Image:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%" /Quiet
Echo+
Goto:EOF
:Unmount
:: Unmount the Windows Image commiting changes.
Echo [+] Unmounting WIM Image...
If /I "%UnmountImage%" EQU "True" (
"%Dism%" /Unmount-WIM /Commit /MountDir:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%"
)
Goto:EOF
:Rebuild
If /I "%Rebuild%" EQU "False" (Goto:EOF)
Echo+
Echo [+] Rebuilding WIM image...
("%ImageX%" /Compress Maximum /Export "%WindowsImage%" "*" "%TEMP%\Rebuilt Image.wim" /Check) && (
Del /Q /F "%WindowsImage%" 1>NUL
Move /Y "%TEMP%\Rebuilt Image.wim" "%WindowsImage%" 1>NUL
) || (
Echo [x] Error rebuilding Image "%WindowsImage%" to "%TEMP%\Rebuilt Image.wim".
)
Goto :EOF
:StartTimer
Set "StartingDate=%Date%"
Set "StarttingTime=%Time:~0,-3%"
Goto :EOF
:StopTimer
(
Echo Minutes = DateDiff^("n", "%StartingDate% %StarttingTime%", Now^)
Echo WScript.Echo Minutes ^& " Minutes"
)>"%TEMP%\%~n0 MinuteDiff.vbs"
For /F "Tokens=*" %%# In (
'Cscript.exe /Nologo "%TEMP%\%~n0 MinuteDiff.vbs"'
) Do (
Set "ElapsedTime=%%#"
)
Goto:EOF
:WriteConvertBytesScript
If Exist "%TEMP%\%~n0 Convert Bytes.vbs" (Goto:EOF)
(
Echo Suffix = Array^("Bytes", "KB", "MB", "GB", "TB"^)
Echo+
Echo Function Convert^(Bytes^)
Echo Convert = convert0^(Bytes, 0^)
Echo End Function
Echo+
Echo Function Convert0^(Bytes, Level^)
Echo If Bytes ^>= 1024 Then
Echo Bytes = Round^(Bytes / 1024, 2^)
Echo Level = Level + 1
Echo Convert0 = Convert0^(Bytes, Level^)
Echo End If
Echo Convert0 = Bytes ^& " " ^& Suffix^(Level^)
Echo End Function
Echo+
Echo WScript.Echo Convert^(WScript.Arguments^(0^)^)
)>"%TEMP%\%~n0 Convert Bytes.vbs"
Goto:EOF
:GetWIMSizeBefore
Call :WriteConvertBytesScript
For %%# in ("%WindowsImage%") Do (Set "WIMSizeBefore=%%~z#")
For /F "Tokens=*" %%# In (
'Cscript.exe /Nologo "%TEMP%\%~n0 Convert Bytes.vbs" "%WIMSizeBefore%"'
) Do (
Set "WIMSizeBefore=%%#"
)
Del /Q "%TEMP%\%~n0 Convert Bytes.vbs"
Goto:EOF
:GetWIMSizeAfter
Call :WriteConvertBytesScript
For %%# in ("%WindowsImage%") Do (Set "WIMSizeAfter=%%~z#")
For /F "Tokens=*" %%# In (
'Cscript.exe /Nologo "%TEMP%\%~n0 Convert Bytes.vbs" "%WIMSizeAfter%"'
) Do (
Set "WIMSizeAfter=%%#"
)
Del /Q "%TEMP%\%~n0 Convert Bytes.vbs"
Goto:EOF
:TakeOwn
(
Takeown.exe /F "%~f1"
ICacls.exe "%~f1" /Grant "%UserName%":"F"
Attrib.exe -R -A -S -H -I "%~f1"
)>NUL || (Exit /B 1)
Goto:EOF
:ParseResources
Set /A "ResourceSuccessCount=0"
Set /A "ResourceFailsCount=0"
Set /A "ResourceNotFoundCount=0"
Set /A "FilesAddedCount=0"
Set /A "FilesFailsCount=0"
Set /A "FilesNotFoundCount=0"
For /F "UseBackQ Tokens=1,2,* Delims=;" %%a In ("%ResourceList%") Do (
If /I "%%~xa" EQU ".dll" (Call :ReplaceResource "%MountDir%\%%~a" "%%~b" "%%~c")
If /I "%%~xa" NEQ ".dll" (Call :CopyFile "%MountDir%\%%~a" "%%~b")
)
Goto:EOF
:CopyFile
If Not Exist "%~2" (
Echo Can't locate file to copy from: "%~2">>"%LogFile%"
Set /A "FilesNotFoundCount+=1"
Goto:EOF
)
Call :TakeOwn "%~f1" || (
Echo Unable to grant file permissions in file: "%~1">>"%Logfile%"
Set /A "FilesFailsCount+=1"
Goto:EOF
)
Echo [o] Copying "%~2" to "%~1"
Copy /Y "%~f2" "%~f1" 1>NUL || (
Echo Unable to copy file "%~2">>"%Logfile%"
Set /A "FilesFailsCount+=1"
Goto:EOF
)
Set /A "FilesAddedCount+=1"
Goto:EOF
:ReplaceResource
If Not Exist "%~f3" (
Echo Can't locate the resource to copy from: "%~3">>"%LogFile%"
Set /A "ResourceNotFoundCount+=1"
Goto:EOF
)
If Not Exist "%~f1" (
Echo Can't locate the resource file to edit "%~1">>"%Logfile%"
Set /A "ResourceNotFoundCount+=1"
Goto:EOF
)
Call :TakeOwn "%~f1" || (
Echo Unable to grant file permissions in file: "%~1">>"%Logfile%"
Set /A "ResourceFailsCount+=1"
Goto:EOF
)
Echo [o] Replacing resource with name "%~2" in resource file "%~f1", with "%~3".
If /I "%~x3" EQU ".bmp" (
Start /W "Anolis" "%Anolis%" -op:upd -src:"%~f1" -type:Bitmap -name:"%~2" -lang:1033 -file:"%~f3")
)
If /I "%~x3" EQU ".ico" (
Start /W "Anolis" "%Anolis%" -op:upd -src:"%~f1" -type:Icon -name:"%~2" -lang:1033 -file:"%~f3")
)
Set /A "ResourceSuccessCount+=1"
Goto:EOF
REM ====================
REM File Error Controls:
REM ====================
:CheckErrors
:: WIM File Error-Check.
If /I "MountImage" EQU "True" If Not Exist "%WindowsImage%" (
Echo [x] Windows Image not found at: "%WindowsImage%" | MORE
Pause&Exit
)
:: ResourceList File Error-Check.
If Not Exist "%ResourceList%" (
Echo [x] Resource-List file not found in: "%ResourceList%" | MORE
Pause&Exit
)
:: 'DISM.exe' File Error-Check.
If Not Exist "%DISM%" (
Echo [x] 'DISM' process not found at: "%DISM%" | MORE
Pause&Exit
)
:: 'ImageX.exe' File Error-Check.
If Not Exist "%ImageX%" (
Echo [x] 'ImageX' process not found at: "%ImageX%" | MORE
Pause&Exit
)
:: 'MountImage' Value check.
If /I "%MountImage%" NEQ "True" If /I "%MountImage%" NEQ "False" (
Echo [x] Error parsing parameter 'MountImage',
Echo value '%MountImage%' is not a Boolean value.
Pause&Exit
)
:: 'UnmountImage' Value check.
If /I "%UnmountImage%" NEQ "True" If /I "%UnmountImage%" NEQ "False" (
Echo [x] Error parsing parameter 'UnmountImage',
Echo value '%UnmountImage%' is not a Boolean value.
Pause&Exit
)
:: 'Rebuild' Value check.
If /I "%Rebuild%" NEQ "True" If /I "%Rebuild%" NEQ "False" (
Echo [x] Error parsing parameter 'Rebuild',
Echo value '%Rebuild%' is not a Boolean value.
Pause&Exit
)
:: 'CleanUp' Value check.
If /I "%CleanUp%" NEQ "True" If /I "%CleanUp%" NEQ "False" (
Echo [x] Error parsing parameter 'CleanUp',
Echo value '%CleanUp%' is not a Boolean value.
Pause&Exit
)
:: 'DismLogLevel' Value check.
Echo "%DismLogLevel%"| Findstr.exe "^\"[^1-4]\"$" 1>NUL 2>&1 || (
Echo [x] Error parsing parameter 'DismLogLevel',
Echo value '%DismLogLevel%' is not in range '1-4'.
Pause&Exit
)
:: Anolis Resourcer File Error-Check.
If Not Exist "%Anolis%" (
Echo [x] Anolis process not found in: "%Anolis%" | MORE
Pause&Exit
)
Goto:EOF
@Echo OFF
REM =================
REM Console Settings:
REM =================
Title WIM Package Uninstaller - By Elektro
Mode Con Cols=150 Lines=50
CHCP 1252 1>NUL & REM Windows-1252, Spanish-Latin.
REM =====
REM Info:
REM =====
Echo+
Echo ----------------------------------------------------------------------------------
Echo This script mounts a Windows Image ^(WIM^) and then removes pre-installed packages
Echo ----------------------------------------------------------------------------------
Echo+
REM ====================
REM User defined values:
REM ====================
REM This value indicates whether the Windows Image should be mounted.
REM True = 'DISM' will try to mount the 'WIM' image.
REM False = 'DISM' will not try to mount the WIM image.
REM Set this value to 'FALSE' if the 'WIM' image is already mounted in the specified mount directory,
REM Otherwise, keep it as 'TRUE'.
Set "MountImage=True"
REM This value indicates whether the Windows Image should be unmounted at the end.
REM True = 'DISM' will try to unmount the 'WIM' image.
REM False = 'DISM' will not try to unmount the WIM image.
REM Set this value to 'FALSE' if you want to keep the image mounted to make other changes,
REM Otherwise, keep it as 'TRUE'.
Set "UnmountImage=True"
REM This value indicates whether the Windows Image should be rebuilt at the end.
REM True = 'ImageX' will try to rebuild the 'WIM' image.
REM False = 'ImageX' will keep the 'WIM' image as is.
REM Set this value to 'FALSE' if you want to keep the image with normal size to make other changes,
REM Otherwise, keep it as 'TRUE'.
Set "Rebuild=True"
REM This value indicates the 'WIM' image to be mounted.
Set "WindowsImage=%UserProfile%\Desktop\win 8 .1\win\sources\install.wim"
REM This value indicates the Image Index of the 'WIM' image.
Set "ImageIndex=1"
REM This value indicates the directory where to mount the 'WIM' image.
Set "MountDir=%HomeDrive%\WinMount"
REM This value indicates the textfile that contains the names of the packages to remove.
Set "PackageList=%CD%\Packages.txt"
REM This value indicates the ubication of the 'WIM Registry Tweak Tool.exe' file.
Set "WIMRegistryTweakTool=%CD%\Tools\WIM Registry Tweak Tool\WIM Registry Tweak Tool.exe"
REM This value indicates the ubication of 'ImageX.exe' file.
Set "ImageX=%CD%\Tools\Dism\ImageX.exe"
REM This value indicates the ubication of a custom 'DISM.exe' file if needed.
REM Default ubication: "%SystemRoot%\System32\Dism.exe"
Set "Dism=%CD%\Tools\Dism\Dism.exe"
REM This value indicates the ubication of the logfile that will record 'DISM' errors.
Set "DismLogfile=%CD%\%~n0 DISM.log"
REM This value indicates the logging-level of the 'DISM' process.
REM 1 = Errors only
REM 2 = Errors and warnings
REM 3 = Errors, warnings, and informational
REM 4 = All of the information listed previously, plus debug output
Set /A "DismLogLevel=2"
REM This value indicates the ubication of the logfile that will record Main information.
Set "Logfile=%CD%\%~n0.log"
REM =====
REM Main:
REM =====
:: Call Methods.
Call :CheckErrors
Call :CreateLogs
Call :CreateMountDir
Call :GetWIMSizeBefore
Call :StartTimer
Call :Mount
CLS
Call :ParsePackages
CLS
Call :CleanUp
Call :Unmount
Call :Rebuild
Call :StopTimer
Call :GetWIMSizeAfter
Call :EndLog
Pause&Exit
REM ========
REM Methods:
REM ========
:CreateLogs
:: Create the 'DISM' logfile with 'ANSI' encoding,
:: this is necessary to record a non-default 'DISM' loglevel such as '1' or '2'.
Echo+ >"%DismLogfile%"
:: Create the Main logfile and record starting info on it.
Echo+ >"%Logfile%"
(
Echo+
Echo WIM Package Uninstaller
Echo ===========================
Echo %DATE% ^| %TIME:~0,-3%
Echo /\/\/\/\/\/\/\/\/\/\/\/\/\/
Echo+
Echo [i] Mount Image?...: %MountImage%
Echo [i] Unmount Image?.: %UnmountImage%
Echo+
Echo [i] Windows Image..: %WindowsImage%
Echo [i] Image Index....: %ImageIndex%
Echo [i] Mount Directory: %MountDir%
Echo+
Echo [i] ImageX Path....: %ImageX%
Echo [i] Dism Path......: %Dism%
Echo [i] Dism Log File..: %DismLogfile%
Echo [i] Dism Log Level.: %DismLogLevel%
Echo+
Echo [i] WIMRegistryTool: %WIMRegistryTweakTool%
Echo [i] Package List...: %PackageList%
Echo [i] Log File.......: %Logfile%
Echo+
Echo ===========================
)>"%Logfile%"
:: Display starting log info.
Type "%Logfile%"
:: Continue writting log.
(
Echo+
Echo Package conflicts:
Echo ==================
Echo+
)>>"%LogFile%"
Goto:EOF
:EndLog
(
Echo+
Echo [i] Done!
Echo [i] WIM Image Size Before........: %WIMSizeBefore%
Echo [i] WIM Image Size After.........: %WIMSizeAfter%
Echo [i] Packages Successfully Removed: %PackagesRemovedCount% Packages.
Echo [i] Packages Failed To Remove....: %PackagesFailedCount% Packages.
Echo [i] Packages Not Found...........: %PackagesNotFoundCount% Packages.
Echo [i] Elapsed Time.................: %ElapsedTime%
Echo+
)>>"%LogFile%"
:: Display ending information.
CLS
Type "%LogFile%"
Goto:EOF
:CreateMountDir
:: Create the mount directory.
(
If Not Exist "%MountDir%" If /I "%MountImage%" EQU "True" (
MkDir "%MountDir%" 2>NUL
)
) || (
Echo+
Echo [x] Error trying to create the directory "%MountDir%" to mount the Windows Image.
Echo [i] Ensure that you have Admin rights to create the directory.
Echo [i] Ensure that the directory name does not contains illegal characters.
Echo+
Pause&Exit
)
Goto:EOF
:Mount
:: Mount the Windows Image into the directory.
Echo+
Echo [+] Mounting WIM Image...
If /I "%MountImage%" EQU "True" (
"%Dism%" /Mount-Image /ImageFile:"%WindowsImage%" /Index:"%ImageIndex%" /MountDir:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%" || (
Echo+
Echo [x] Error mounting the Image Index "%ImageIndex%" in "%MountDir%"
Echo [i] Ensure that the Image Index exist.
Echo [i] Ensure that you have Admin rights to write inside the directory.
Echo [i] Ensure that the directory is not already mounted.
Echo [i] Ensure that the directory is fully empty.
Echo+
REM Try to unmount the failed image and discard changes.
If /I "%UnmountImage%" EQU "True" (
Echo [+] Unmounting and discarding changes...
"%Dism%" /Unmount-WIM /Discard /MountDir:"%MountDir%"
)
Pause&Exit
)
)
Goto:EOF
:CleanUp
Echo [+] CleaningUp WIM Image...
"%Dism%" /CleanUp-Image /StartComponentCleanUp /Image:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%" /Quiet
Echo+
Goto:EOF
:Unmount
:: Unmount the Windows Image commiting changes.
Echo [+] Unmounting WIM Image...
If /I "%UnmountImage%" EQU "True" (
"%Dism%" /Unmount-WIM /Commit /MountDir:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%"
)
Goto:EOF
:Rebuild
If /I "%Rebuild%" EQU "False" (Goto:EOF)
Echo+
Echo [+] Rebuilding WIM image...
("%ImageX%" /Compress Maximum /Export "%WindowsImage%" "*" "%TEMP%\Rebuilt Image.wim" /Check) && (
Del /Q /F "%WindowsImage%" 1>NUL
Move /Y "%TEMP%\Rebuilt Image.wim" "%WindowsImage%" 1>NUL
) || (
Echo [x] Error rebuilding Image "%WindowsImage%" to "%TEMP%\Rebuilt Image.wim".
)
Goto :EOF
:StartTimer
Set "StartingDate=%Date%"
Set "StarttingTime=%Time:~0,-3%"
Goto :EOF
:StopTimer
(
Echo Minutes = DateDiff^("n", "%StartingDate% %StarttingTime%", Now^)
Echo WScript.Echo Minutes ^& " Minutes"
)>"%TEMP%\%~n0 MinuteDiff.vbs"
For /F "Tokens=*" %%# In (
'Cscript.exe /Nologo "%TEMP%\%~n0 MinuteDiff.vbs"'
) Do (
Set "ElapsedTime=%%#"
)
Goto:EOF
:WriteConvertBytesScript
If Exist "%TEMP%\%~n0 Convert Bytes.vbs" (Goto:EOF)
(
Echo Suffix = Array^("Bytes", "KB", "MB", "GB", "TB"^)
Echo+
Echo Function Convert^(Bytes^)
Echo Convert = convert0^(Bytes, 0^)
Echo End Function
Echo+
Echo Function Convert0^(Bytes, Level^)
Echo If Bytes ^>= 1024 Then
Echo Bytes = Round^(Bytes / 1024, 2^)
Echo Level = Level + 1
Echo Convert0 = Convert0^(Bytes, Level^)
Echo End If
Echo Convert0 = Bytes ^& " " ^& Suffix^(Level^)
Echo End Function
Echo+
Echo WScript.Echo Convert^(WScript.Arguments^(0^)^)
)>"%TEMP%\%~n0 Convert Bytes.vbs"
Goto:EOF
:GetWIMSizeBefore
Call :WriteConvertBytesScript
For %%# in ("%WindowsImage%") Do (Set "WIMSizeBefore=%%~z#")
For /F "Tokens=*" %%# In (
'Cscript.exe /Nologo "%TEMP%\%~n0 Convert Bytes.vbs" "%WIMSizeBefore%"'
) Do (
Set "WIMSizeBefore=%%#"
)
Del /Q "%TEMP%\%~n0 Convert Bytes.vbs"
Goto:EOF
:GetWIMSizeAfter
Call :WriteConvertBytesScript
For %%# in ("%WindowsImage%") Do (Set "WIMSizeAfter=%%~z#")
For /F "Tokens=*" %%# In (
'Cscript.exe /Nologo "%TEMP%\%~n0 Convert Bytes.vbs" "%WIMSizeAfter%"'
) Do (
Set "WIMSizeAfter=%%#"
)
Del /Q "%TEMP%\%~n0 Convert Bytes.vbs"
Goto:EOF
:ParsePackages
Set /A "PackagesRemovedCount=0"
Set /A "PackagesFailedCount=0"
Set /A "PackagesNotFoundCount=0"
:: Unhide packages and take registry ownership.
"%WIMRegistryTweakTool%" /p "%MountDir%"
Echo+
:: Remove Packages.
For /F "UseBackQ Tokens=* Delims=" %%# In ("%PackageList%") Do (
Echo [+] Removing package: %%~#
"%Dism%" /Remove-Package /PackageName:"%%~#" /Image:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%" /Quiet 1>NUL
Call Set /A "ExitCode=%%Errorlevel%%"
(Call Echo "%%ExitCode%%"| Findstr.exe "^\"0\"$" 1>NUL 2>&1) && (
Call Set /A "PackagesRemovedCount+=1"
)
(Call Echo "%%ExitCode%%"| Findstr.exe "^\"5\"$" 1>NUL 2>&1) && (
Call Set /A "PackagesFailedCount+=1"
Echo Failed to remove package: %%~#>>"%LogFile%"
)
(Call Echo "%%ExitCode%%"| Find.exe "-2146498555" 1>NUL 2>&1) && (
Call Set /A "PackagesNotFoundCount+=1"
Echo Package is not installed: %%~#>>"%LogFile%"
)
)
Goto:EOF
REM ===============
REM Error Controls:
REM ===============
:CheckErrors
:: WIM File Error-Check.
If /I "MountImage" EQU "True" If Not Exist "%WindowsImage%" (
Echo [x] Windows Image not found at: "%WindowsImage%" | MORE
Pause&Exit
)
:: PackageList File Error-Check.
If Not Exist "%PackageList%" (
Echo [x] PackageList not found at: "%PackageList%" | MORE
Pause&Exit
)
:: 'DISM.exe' File Error-Check.
If Not Exist "%DISM%" (
Echo [x] 'DISM' process not found at: "%DISM%" | MORE
Pause&Exit
)
:: 'ImageX.exe' File Error-Check.
If Not Exist "%ImageX%" (
Echo [x] 'ImageX' process not found at: "%ImageX%" | MORE
Pause&Exit
)
:: 'WIM Registry Tweak Tool.exe' File Error-Check.
If Not Exist "%WIMRegistryTweakTool%" (
Echo [x] 'WIM Registry Tweak Tool' process not found at: "%WIMRegistryTweakTool%" | MORE
Pause&Exit
)
:: 'MountImage' Value check.
If /I "%MountImage%" NEQ "True" If /I "%MountImage%" NEQ "False" (
Echo [x] Error parsing parameter 'MountImage',
Echo value '%MountImage%' is not a Boolean value.
Pause&Exit
)
:: 'UnmountImage' Value check.
If /I "%UnmountImage%" NEQ "True" If /I "%UnmountImage%" NEQ "False" (
Echo [x] Error parsing parameter 'UnmountImage',
Echo value '%UnmountImage%' is not a Boolean value.
Pause&Exit
)
:: 'Rebuild' Value check.
If /I "%Rebuild%" NEQ "True" If /I "%Rebuild%" NEQ "False" (
Echo [x] Error parsing parameter 'Rebuild',
Echo value '%Rebuild%' is not a Boolean value.
Pause&Exit
)
:: 'DismLogLevel' Value check.
Echo "%DismLogLevel%"| Findstr.exe "^\"[^1-4]\"$" 1>NUL 2>&1 || (
Echo [x] Error parsing parameter 'DismLogLevel',
Echo value '%DismLogLevel%' is not in range '1-4'.
Pause&Exit
)
Goto:EOF
@Echo OFF
REM =================
REM Console Settings:
REM =================
Title WIM Feature Uninstaller - By Elektro
Mode Con Cols=150 Lines=50
CHCP 1252 1>NUL & REM Windows-1252, Spanish-Latin.
REM =====
REM Info:
REM =====
Echo+
Echo -----------------------------------------------------------------------------
Echo This script mounts a Windows Image ^(WIM^) and then disables Windows features
Echo -----------------------------------------------------------------------------
Echo+
REM ====================
REM User defined values:
REM ====================
REM This value indicates whether the Windows Image should be mounted.
REM True = 'DISM' will try to mount the 'WIM' image.
REM False = 'DISM' will not try to mount the WIM image.
REM Set this value to 'FALSE' if the 'WIM' image is already mounted in the specified mount directory,
REM Otherwise, keep it as 'TRUE'.
Set "MountImage=True"
REM This value indicates whether the Windows Image should be unmounted at the end.
REM True = 'DISM' will try to unmount the 'WIM' image.
REM False = 'DISM' will not try to unmount the WIM image.
REM Set this value to 'FALSE' if you want to keep the image mounted to make other changes,
REM Otherwise, keep it as 'TRUE'.
Set "UnmountImage=True"
REM This value indicates whether the Windows Image should be rebuilt at the end.
REM True = 'ImageX' will try to rebuild the 'WIM' image.
REM False = 'ImageX' will keep the 'WIM' image as is.
REM Set this value to 'FALSE' if you want to keep the image with normal size to make other changes,
REM Otherwise, keep it as 'TRUE'.
Set "Rebuild=True"
REM This value indicates the 'WIM' image to be mounted.
Set "WindowsImage=%UserProfile%\Desktop\win 8 .1\win\sources\install.wim"
REM This value indicates the Image Index of the 'WIM' image.
Set "ImageIndex=1"
REM This value indicates the directory where to mount the 'WIM' image.
Set "MountDir=%HomeDrive%\WinMount"
REM This value indicates the textfile that contains the names of the features to disable.
Set "FeatureList=%CD%\Features.txt"
REM This value indicates the ubication of 'ImageX.exe' file.
Set "ImageX=%CD%\Tools\Dism\ImageX.exe"
REM This value indicates the ubication of a custom 'DISM.exe' file if needed.
REM Default ubication: "%SystemRoot%\System32\Dism.exe"
Set "Dism=%CD%\Tools\Dism\Dism.exe"
REM This value indicates the ubication of the logfile that will record 'DISM' errors.
Set "DismLogfile=%CD%\%~n0 DISM.log"
REM This value indicates the logging-level of the 'DISM' process.
REM 1 = Errors only
REM 2 = Errors and warnings
REM 3 = Errors, warnings, and informational
REM 4 = All of the information listed previously, plus debug output
Set /A "DismLogLevel=2"
REM This value indicates the ubication of the logfile that will record Main information.
Set "Logfile=%CD%\%~n0.log"
REM =====
REM Main:
REM =====
:: Call Methods.
Call :CheckErrors
Call :CreateLogs
Call :CreateMountDir
Call :GetWIMSizeBefore
Call :StartTimer
Call :Mount
CLS
Call :ParseFeatures
CLS
Call :CleanUp
Call :Unmount
Call :Rebuild
Call :StopTimer
Call :GetWIMSizeAfter
Call :EndLog
Pause&Exit
REM ========
REM Methods:
REM ========
:CreateLogs
:: Create the 'DISM' logfile with 'ANSI' encoding,
:: this is necessary to record a non-default 'DISM' loglevel such as '1' or '2'.
Echo+ >"%DismLogfile%"
:: Create the Main logfile and record starting info on it.
Echo+ >"%Logfile%"
(
Echo+
Echo WIM Feature Uninstaller
Echo ===========================
Echo %DATE% ^| %TIME:~0,-3%
Echo /\/\/\/\/\/\/\/\/\/\/\/\/\/
Echo+
Echo [i] Mount Image?...: %MountImage%
Echo [i] Unmount Image?.: %UnmountImage%
Echo+
Echo [i] Windows Image..: %WindowsImage%
Echo [i] Image Index....: %ImageIndex%
Echo [i] Mount Directory: %MountDir%
Echo+
Echo [i] ImageX Path....: %ImageX%
Echo [i] Dism Path......: %Dism%
Echo [i] Dism Log File..: %DismLogfile%
Echo [i] Dism Log Level.: %DismLogLevel%
Echo+
Echo [i] Feature List...: %FeatureList%
Echo [i] Log File.......: %Logfile%
Echo+
Echo ===========================
)>"%Logfile%"
:: Display starting log info.
Type "%Logfile%"
:: Continue writting log.
(
Echo+
Echo Feature conflicts:
Echo ==================
Echo+
)>>"%LogFile%"
Goto:EOF
:EndLog
(
Echo+
Echo [i] Done!
Echo [i] WIM Image Size Before.........: %WIMSizeBefore%
Echo [i] WIM Image Size After..........: %WIMSizeAfter%
Echo [i] Features Successfully Disabled: %FeaturesRemovedCount% Packages.
Echo [i] Features Failed To Disable....: %FeaturesFailedCount% Packages.
Echo [i] Features Not Found............: %FeaturesNotFoundCount% Packages.
Echo [i] Elapsed Time..................: %ElapsedTime%
Echo+
)>>"%LogFile%"
:: Display ending information.
CLS
Type "%LogFile%"
Goto:EOF
:CreateMountDir
:: Create the mount directory.
(
If Not Exist "%MountDir%" If /I "%MountImage%" EQU "True" (
MkDir "%MountDir%" 2>NUL
)
) || (
Echo+
Echo [x] Error trying to create the directory "%MountDir%" to mount the Windows Image.
Echo [i] Ensure that you have Admin rights to create the directory.
Echo [i] Ensure that the directory name does not contains illegal characters.
Echo+
Pause&Exit
)
Goto:EOF
:Mount
:: Mount the Windows Image into the directory.
Echo+
Echo [+] Mounting WIM Image...
If /I "%MountImage%" EQU "True" (
"%Dism%" /Mount-Image /ImageFile:"%WindowsImage%" /Index:"%ImageIndex%" /MountDir:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%" || (
Echo+
Echo [x] Error mounting the Image Index "%ImageIndex%" in "%MountDir%"
Echo [i] Ensure that the Image Index exist.
Echo [i] Ensure that you have Admin rights to write inside the directory.
Echo [i] Ensure that the directory is not already mounted.
Echo [i] Ensure that the directory is fully empty.
Echo+
REM Try to unmount the failed image and discard changes.
If /I "%UnmountImage%" EQU "True" (
Echo [+] Unmounting and discarding changes...
"%Dism%" /Unmount-WIM /Discard /MountDir:"%MountDir%"
)
Pause&Exit
)
)
Goto:EOF
:CleanUp
Echo [+] CleaningUp WIM Image...
"%Dism%" /CleanUp-Image /StartComponentCleanUp /Image:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%" /Quiet
Echo+
Goto:EOF
:Unmount
:: Unmount the Windows Image commiting changes.
Echo [+] Unmounting WIM Image...
If /I "%UnmountImage%" EQU "True" (
"%Dism%" /Unmount-WIM /Commit /MountDir:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%"
)
Goto:EOF
:Rebuild
If /I "%Rebuild%" EQU "False" (Goto:EOF)
Echo+
Echo [+] Rebuilding WIM image...
("%ImageX%" /Compress Maximum /Export "%WindowsImage%" "*" "%TEMP%\Rebuilt Image.wim" /Check) && (
Del /Q /F "%WindowsImage%" 1>NUL
Move /Y "%TEMP%\Rebuilt Image.wim" "%WindowsImage%" 1>NUL
) || (
Echo [x] Error rebuilding Image "%WindowsImage%" to "%TEMP%\Rebuilt Image.wim".
)
Goto :EOF
:StartTimer
Set "StartingDate=%Date%"
Set "StarttingTime=%Time:~0,-3%"
Goto :EOF
:StopTimer
(
Echo Minutes = DateDiff^("n", "%StartingDate% %StarttingTime%", Now^)
Echo WScript.Echo Minutes ^& " Minutes"
)>"%TEMP%\%~n0 MinuteDiff.vbs"
For /F "Tokens=*" %%# In (
'Cscript.exe /Nologo "%TEMP%\%~n0 MinuteDiff.vbs"'
) Do (
Set "ElapsedTime=%%#"
)
Goto:EOF
:WriteConvertBytesScript
If Exist "%TEMP%\%~n0 Convert Bytes.vbs" (Goto:EOF)
(
Echo Suffix = Array^("Bytes", "KB", "MB", "GB", "TB"^)
Echo+
Echo Function Convert^(Bytes^)
Echo Convert = convert0^(Bytes, 0^)
Echo End Function
Echo+
Echo Function Convert0^(Bytes, Level^)
Echo If Bytes ^>= 1024 Then
Echo Bytes = Round^(Bytes / 1024, 2^)
Echo Level = Level + 1
Echo Convert0 = Convert0^(Bytes, Level^)
Echo End If
Echo Convert0 = Bytes ^& " " ^& Suffix^(Level^)
Echo End Function
Echo+
Echo WScript.Echo Convert^(WScript.Arguments^(0^)^)
)>"%TEMP%\%~n0 Convert Bytes.vbs"
Goto:EOF
:GetWIMSizeBefore
Call :WriteConvertBytesScript
For %%# in ("%WindowsImage%") Do (Set "WIMSizeBefore=%%~z#")
For /F "Tokens=*" %%# In (
'Cscript.exe /Nologo "%TEMP%\%~n0 Convert Bytes.vbs" "%WIMSizeBefore%"'
) Do (
Set "WIMSizeBefore=%%#"
)
Del /Q "%TEMP%\%~n0 Convert Bytes.vbs"
Goto:EOF
:GetWIMSizeAfter
Call :WriteConvertBytesScript
For %%# in ("%WindowsImage%") Do (Set "WIMSizeAfter=%%~z#")
For /F "Tokens=*" %%# In (
'Cscript.exe /Nologo "%TEMP%\%~n0 Convert Bytes.vbs" "%WIMSizeAfter%"'
) Do (
Set "WIMSizeAfter=%%#"
)
Del /Q "%TEMP%\%~n0 Convert Bytes.vbs"
Goto:EOF
:ParseFeatures
Set /A "FeaturesRemovedCount=0"
Set /A "FeaturesFailedCount=0"
Set /A "FeaturesNotFoundCount=0"
:: Disable Features.
For /F "UseBackQ Tokens=* Delims=" %%# In ("%FeatureList%") Do (
Echo [+] Disabling Feature: %%~#
"%Dism%" /Disable-Feature /FeatureName:"%%~#" /Image:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%" /Quiet 1>NUL
Call Set /A "ExitCode=%%Errorlevel%%"
(Call Echo "%%ExitCode%%"| Findstr.exe "^\"0\"$" 1>NUL 2>&1) && (
Call Set /A "FeaturesRemovedCount+=1"
)
(Call Echo "%%ExitCode%%"| Findstr.exe "^\"5\"$" 1>NUL 2>&1) && (
Call Set /A "FeaturesFailedCount+=1"
Echo Failed to disable feature: %%~#>>"%LogFile%"
)
(Call Echo "%%ExitCode%%"| Find.exe "-2146498548" 1>NUL 2>&1) && (
Call Set /A "FeaturesNotFoundCount+=1"
Echo Feature is not found.....: %%~#>>"%LogFile%"
)
)
Goto:EOF
REM ===============
REM Error Controls:
REM ===============
:CheckErrors
:: WIM File Error-Check.
If /I "MountImage" EQU "True" If Not Exist "%WindowsImage%" (
Echo [x] Windows Image not found at: "%WindowsImage%" | MORE
Pause&Exit
)
:: FeatureList File Error-Check.
If Not Exist "%FeatureList%" (
Echo [x] FeatureList not found at: "%FeatureList%" | MORE
Pause&Exit
)
:: 'DISM.exe' File Error-Check.
If Not Exist "%DISM%" (
Echo [x] 'DISM' process not found at: "%DISM%" | MORE
Pause&Exit
)
:: 'ImageX.exe' File Error-Check.
If Not Exist "%ImageX%" (
Echo [x] 'ImageX' process not found at: "%ImageX%" | MORE
Pause&Exit
)
:: 'MountImage' Value check.
If /I "%MountImage%" NEQ "True" If /I "%MountImage%" NEQ "False" (
Echo [x] Error parsing parameter 'MountImage',
Echo value '%MountImage%' is not a Boolean value.
Pause&Exit
)
:: 'UnmountImage' Value check.
If /I "%UnmountImage%" NEQ "True" If /I "%UnmountImage%" NEQ "False" (
Echo [x] Error parsing parameter 'UnmountImage',
Echo value '%UnmountImage%' is not a Boolean value.
Pause&Exit
)
:: 'Rebuild' Value check.
If /I "%Rebuild%" NEQ "True" If /I "%Rebuild%" NEQ "False" (
Echo [x] Error parsing parameter 'Rebuild',
Echo value '%Rebuild%' is not a Boolean value.
Pause&Exit
)
:: 'DismLogLevel' Value check.
Echo "%DismLogLevel%"| Findstr.exe "^\"[^1-4]\"$" 1>NUL 2>&1 || (
Echo [x] Error parsing parameter 'DismLogLevel',
Echo value '%DismLogLevel%' is not in range '1-4'.
Pause&Exit
)
Goto:EOF
@Echo OFF
REM =================
REM Console Settings:
REM =================
Title Filesize Truncator - By Elektro
Mode Con Cols=150 Lines=50
CHCP 1252 1>NUL & REM Windows-1252, Spanish-Latin.
REM =====
REM Info:
REM =====
Echo+
Echo ------------------------------------------------------------------------------------------------------------
Echo This script will truncate to Zero the size of the files inside the working directory and it's subdirectories
Echo ------------------------------------------------------------------------------------------------------------
Echo Take extreme caution, truncating the filesize has the same effect as deleting the file !!
Echo -----------------------------------------------------------------------------------------
Echo+
REM ====================
REM User defined values:
REM ====================
REM This value indicates the directory where to list it's file structure.
Set "WorkingDir=%CD%"
REM This value indicates the ubication of the logfile that will record info.
Set "Logfile=%CD%\%~n0.log"
REM This value indicates the File-Extensions to exclude during the process.
REM ( Use an ';' delimiter to separate multiple extensions )
Set "ExcludeExts=.bat;.cmd"
REM This value indicates the filenames to exclude during the process.
REM ( Use an ';' delimiter to separate multiple filenames )
Set "ExcludeNames=%~nx0;Files.txt;Files2List.log"
REM This value indicates the files to exclude during the process.
REM ( Use an ';' delimiter to separate multiple files )
Set "ExcludeFiles=%Logfile%"
REM This value indicates how the hidden files are threated when listing the file structure.
REM True = List files and also files with the 'hidden' attribute.
REM False = List only normal files without the 'hidden' attribute.
Set "IncludeHiddenFiles=True"
REM =====
REM Main:
REM =====
:: Warning question.
Call :CreateLog
Echo+
Choice /C "YN" /M "This will delete the files, you want to continue?"
If %ErrorLevel% NEQ 1 (Exit)
Echo+
:: Call Methods.
Call :CheckErrors
Call :StartTimer
Call :TruncateFiles "%IncludeHiddenFiles%"
Call :StopTimer
Call :EndLog
Pause&Exit
REM ========
REM Methods:
REM ========
:CreateLog
:: Create the Script Logfile and record starting info on it.
FSutil.exe File CreateNew "%LogFile%" "0" 1>NUL
(
Echo+
Echo Filesize Truncator
Echo =========================
Echo %DATE% ^| %TIME:~0,-3%
Echo /\/\/\/\/\/\/\/\/\/\/\/\/
Echo+
Echo [i] Working Directory...: %WorkingDir%
Echo [i] Include Hidden Files: %IncludeHiddenFiles%
Echo [i] Excluded Extensions.: %ExcludeExts%
Echo [i] Excluded Filenames..: %ExcludeNames%
Echo [i] Excluded Files......: %ExcludeFiles%
Echo [i] Log file............: %LogFile%
Echo+
Echo =========================
)>"%LogFile%"
:: Display starting log info.
Type "%LogFile%" | MORE
:: Continue writting log.
(
Echo+
Echo Excluded Files:
Echo ===============
Echo+
)>>"%LogFile%"
Goto:EOF
:EndLog
(
Echo+
Echo [i] Done!
Echo [i] Truncated Files: %TruncatedFileCount% files.
Echo [i] Excluded Files.: %ExcludedFileCount% files.
Echo [i] Elapsed Time...: %ElapsedTime%
Echo+
)>>"%LogFile%"
:: Display ending information.
CLS
Type "%LogFile%"
Goto:EOF
:StartTimer
Set "StartingDate=%Date%"
Set "StarttingTime=%Time:~0,-3%"
Goto :EOF
:StopTimer
(
Echo Minutes = DateDiff^("n", "%StartingDate% %StarttingTime%", Now^)
Echo WScript.Echo Minutes ^& " Minutes"
)>"%TEMP%\%~n0 MinuteDiff.vbs"
For /F "Tokens=*" %%# In (
'Cscript.exe /Nologo "%TEMP%\%~n0 MinuteDiff.vbs"'
) Do (
Set "ElapsedTime=%%#"
)
Goto:EOF
:TakeOwn
(
Takeown.exe /F "%~f1"
ICacls.exe "%~f1" /Grant "%UserName%":"F"
Attrib.exe -R -A -S -H -I "%~f1"
)>NUL || (Exit /B 1)
Goto:EOF
:TruncateFiles
Echo [+] Truncating files with size greater than Zero, this operation could take some minutes long, please wait...
If /I "%~1" EQU "True" (Call :TruncateHiddenFiles)
If /I "%~1" EQU "False" (Call :TruncateNormalFiles)
Goto:EOF
:TruncateNormalFiles
FOR /R "%WorkingDir%" %%# in ("*") DO (
If %%~z# NEQ 0 (
Set "Exclude="
If Defined ExcludeExts (
(
Echo "%ExcludeExts%" | Find.exe /I "%%~x#" 1>NUL 2>&1
) && (
Call Set "Exclude=True"
)
)
If Defined ExcludeNames (
(
Echo "%ExcludeNames%" | Find.exe /I "%%~nx#" 1>NUL 2>&1
) && (
Call Set "Exclude=True"
)
)
If Defined ExcludeFiles (
(
Echo "%ExcludeFiles%" | Find.exe /I "%%~f#" 1>NUL 2>&1
) && (
Call Set "Exclude=True"
)
)
If Not Defined Exclude (
Set "File=%%~f#"
Call Echo [.] Truncating: %%File:%WorkingDir%=.%%
Call :TakeOwn "%%~f#"
Del /Q "%%~f#"
FSUtil.exe File CreateNew "%%~f#" "0" 1>NUL
Set /A "TruncatedFileCount+=1"
) Else (
Set "File=%%~f#"
Call Echo %%File:%WorkingDir%=.%%>>"%LogFile%"
Set /A "ExcludedFileCount+=1"
)
)
)
Goto:EOF
:TruncateHiddenFiles
FOR /F "Tokens=* Delims=" %%# in ('Dir /B /S /A-D "%WorkingDir%\*"') DO (
If %%~z# NEQ 0 (
Set "Exclude="
If Defined ExcludeExts (
(
Echo "%ExcludeExts%" | Find.exe /I "%%~x#" 1>NUL 2>&1
) && (
Call Set "Exclude=True"
)
)
If Defined ExcludeNames (
(
Echo "%ExcludeNames%" | Find.exe /I "%%~nx#" 1>NUL 2>&1
) && (
Call Set "Exclude=True"
)
)
If Defined ExcludeFiles (
(
Echo "%ExcludeFiles%" | Find.exe /I "%%~f#" 1>NUL 2>&1
) && (
Call Set "Exclude=True"
)
)
If Not Defined Exclude (
Set "File=%%~f#"
Call Echo [.] Truncating: %%File:%WorkingDir%=.%%
Call :TakeOwn "%%~f#"
Del /Q "%%~f#"
FSUtil.exe File CreateNew "%%~f#" "0" 1>NUL
Set /A "TruncatedFileCount+=1"
) Else (
Set "File=%%~f#"
Call Echo %%File:%WorkingDir%=.%%>>"%LogFile%"
Set /A "ExcludedFileCount+=1"
)
)
)
Goto:EOF
REM ===============
REM Error Controls:
REM ===============
:CheckErrors
:: 'IncludeHiddenFiles' Value check.
If /I "%IncludeHiddenFiles%" NEQ "True" If /I "%IncludeHiddenFiles%" NEQ "False" (
Echo [x] Error parsing parameter 'IncludeHiddenFiles',
Echo value '%IncludeHiddenFiles%' is not a Boolean value.
Pause&Exit
)
Goto:EOF
Dism.exe /Mount-Image /imageFile:".\Install.wim" /Index:"1" /MountDir:"C:\WinMount"
Dism.exe /Get-Packages /Image:"Directorio de montaje"
Dism.exe /Get-Packages /Image:"C:\WinMount" /Format:Table
"WIM Registry Tweak Tool.exe" /p "Directorio de montaje" /l
"WIM Registry Tweak Tool.exe" /p "C:\WinMount" /l
Adobe-Flash-For-Windows-Package~31bf3856ad364e35~amd64~~6.3.9600.16384
Microsoft-Windows-InternetExplorer-Optional-Package~31bf3856ad364e35~amd64~es-ES~11.0.9600.16384
Microsoft-Windows-InternetExplorer-Optional-Package~31bf3856ad364e35~amd64~~11.0.9600.16384
Microsoft-Windows-InternetExplorer-Package-shell~31bf3856ad364e35~amd64~es-ES~6.3.9600.16384
Microsoft-Windows-InternetExplorer-Package-shell~31bf3856ad364e35~amd64~~6.3.9600.16384
Microsoft-Windows-InternetExplorer-Package-ua~31bf3856ad364e35~amd64~es-ES~6.3.9600.16384
Microsoft-Windows-InternetExplorer-Package-ua~31bf3856ad364e35~amd64~~6.3.9600.16384
Microsoft-Windows-InternetExplorer-Package~31bf3856ad364e35~amd64~es-ES~11.0.9600.16384
Microsoft-Windows-InternetExplorer-Package~31bf3856ad364e35~amd64~~11.0.9600.16384
...
Dism.exe /Get-Features /Image:"Directorio de montaje" /Format:Table
Dism.exe /Get-Features /Image:"C:\WinMount" /Format:Table
"WIM Registry Tweak Tool.exe" /p "Directorio de montaje"
"WIM Registry Tweak Tool.exe" /p "C:\WinMount"
Dism.exe /Remove-Package /PackageName:"Nombre de la característica" /Imaage:"Directorio de montaje"
Dism.exe /Remove-Package /PackageName:"microsoft-windows-internetexplorer-optional-package~31bf3856ad364e35~amd64~~119600.16384" /Image:"C:\WinMount"
Dism.exe /Image:"Directorio de montaje" /Disable-Feature /FeatureName:"Nombre de característica"
Dism.exe /Image:"C:\WinMount" /Disable-Feature /FeatureName:"WindowsMediaPlayer"
Dism.exe /Unmount-Wim /Commit /MountDir:"Directorio de montaje"
Dism.exe /Unmount-Wim /Commit /MountDir:"C:\WinMount"
microsoft-windows-miracast-driver-package~31bf3856ad364e35~amd64~~6.3.9600.16384
microsoft-windows-mobilepc-client-basic-package~31bf3856ad364e35~amd64~es-es~6.3.9600.16384
microsoft-windows-vpnplugins-package~31bf3856ad364e35~amd64~~6.3.9600.16384
microsoft-windows-webcamexperience-package~31bf3856ad364e35~amd64~~6.3.9600.16384
@Echo OFF
REM =================
REM Console Settings:
REM =================
Title WIM Package Uninstaller - By Elektro
Mode Con Cols=150 Lines=50
CHCP 1252 1>NUL & REM Windows-1252, Spanish-Latin.
REM =====
REM Info:
REM =====
Echo+
Echo ----------------------------------------------------------------------------------
Echo This script mounts a Windows Image ^(WIM^) and then removes pre-installed packages
Echo ----------------------------------------------------------------------------------
Echo+
REM ====================
REM User defined values:
REM ====================
REM This value indicates whether the Windows Image should be mounted.
REM True = 'DISM' will try to mount the 'WIM' image.
REM False = 'DISM' will not try to mount the WIM image.
REM Set this value to 'FALSE' if the 'WIM' image is already mounted in the specified mount directory,
REM Otherwise, keep it as 'TRUE'.
Set "MountImage=True"
REM This value indicates whether the Windows Image should be unmounted at the end.
REM True = 'DISM' will try to unmount the 'WIM' image.
REM False = 'DISM' will not try to unmount the WIM image.
REM Set this value to 'FALSE' if you want to keep the image mounted to make other changes,
REM Otherwise, keep it as 'TRUE'.
Set "UnmountImage=True"
REM This value indicates whether the Windows Image should be rebuilt at the end.
REM True = 'ImageX' will try to rebuild the 'WIM' image.
REM False = 'ImageX' will keep the 'WIM' image as is.
REM Set this value to 'FALSE' if you want to keep the image with normal size to make other changes,
REM Otherwise, keep it as 'TRUE'.
Set "Rebuild=True"
REM This value indicates the 'WIM' image to be mounted.
Set "WindowsImage=%UserProfile%\Desktop\win 8 .1\win\sources\install.wim"
REM This value indicates the Image Index of the 'WIM' image.
Set "ImageIndex=1"
REM This value indicates the directory where to mount the 'WIM' image.
Set "MountDir=%HomeDrive%\WinMount"
REM This value indicates the textfile that contains the names of the packages to remove.
Set "PackageList=%CD%\Packages.txt"
REM This value indicates the ubication of the 'WIM Registry Tweak Tool.exe' file.
Set "WIMRegistryTweakTool=%CD%\Tools\WIM Registry Tweak Tool\WIM Registry Tweak Tool.exe"
REM This value indicates the ubication of 'ImageX.exe' file.
Set "ImageX=%CD%\Tools\Dism\ImageX.exe"
REM This value indicates the ubication of a custom 'DISM.exe' file if needed.
REM Default ubication: "%SystemRoot%\System32\Dism.exe"
Set "Dism=%CD%\Tools\Dism\Dism.exe"
REM This value indicates the ubication of the logfile that will record 'DISM' errors.
Set "DismLogfile=%CD%\%~n0 DISM.log"
REM This value indicates the logging-level of the 'DISM' process.
REM 1 = Errors only
REM 2 = Errors and warnings
REM 3 = Errors, warnings, and informational
REM 4 = All of the information listed previously, plus debug output
Set /A "DismLogLevel=2"
REM This value indicates the ubication of the logfile that will record Main information.
Set "Logfile=%CD%\%~n0.log"
REM =====
REM Main:
REM =====
:: Call Methods.
Call :CheckErrors
Call :CreateLogs
Call :CreateMountDir
Call :GetWIMSizeBefore
Call :StartTimer
Call :Mount
CLS
Call :ParsePackages
CLS
Call :CleanUp
Call :Unmount
Call :Rebuild
Call :StopTimer
Call :GetWIMSizeAfter
Call :EndLog
Pause&Exit
REM ========
REM Methods:
REM ========
:CreateLogs
:: Create the 'DISM' logfile with 'ANSI' encoding,
:: this is necessary to record a non-default 'DISM' loglevel such as '1' or '2'.
Echo+ >"%DismLogfile%"
:: Create the Main logfile and record starting info on it.
Echo+ >"%Logfile%"
(
Echo+
Echo WIM Package Uninstaller
Echo ===========================
Echo %DATE% ^| %TIME:~0,-3%
Echo /\/\/\/\/\/\/\/\/\/\/\/\/\/
Echo+
Echo [i] Mount Image?...: %MountImage%
Echo [i] Unmount Image?.: %UnmountImage%
Echo+
Echo [i] Windows Image..: %WindowsImage%
Echo [i] Image Index....: %ImageIndex%
Echo [i] Mount Directory: %MountDir%
Echo+
Echo [i] ImageX Path....: %ImageX%
Echo [i] Dism Path......: %Dism%
Echo [i] Dism Log File..: %DismLogfile%
Echo [i] Dism Log Level.: %DismLogLevel%
Echo+
Echo [i] Package List...: %PackageList%
Echo [i] Log File.......: %Logfile%
Echo+
Echo ===========================
)>"%Logfile%"
:: Display starting log info.
Type "%Logfile%"
:: Continue writting log.
(
Echo+
Echo Package conflicts:
Echo ==================
Echo+
)>>"%LogFile%"
Goto:EOF
:EndLog
(
Echo+
Echo [i] Done!
Echo [i] WIM Image Size Before........: %WIMSizeBefore%
Echo [i] WIM Image Size After.........: %WIMSizeAfter%
Echo [i] Packages Successfully Removed: %PackagesRemovedCount% Packages.
Echo [i] Packages Failed To Remove....: %PackagesFailedCount% Packages.
Echo [i] Packages Not Found...........: %PackagesNotFoundCount% Packages.
Echo [i] Elapsed Time.................: %ElapsedTime%
Echo+
)>>"%LogFile%"
:: Display ending information.
CLS
Type "%LogFile%"
Goto:EOF
:CreateMountDir
:: Create the mount directory.
(
If Not Exist "%MountDir%" If /I "%MountImage%" EQU "True" (
MkDir "%MountDir%" 2>NUL
)
) || (
Echo+
Echo [x] Error trying to create the directory "%MountDir%" to mount the Windows Image.
Echo [i] Ensure that you have Admin rights to create the directory.
Echo [i] Ensure that the directory name does not contains illegal characters.
Echo+
Pause&Exit
)
Goto:EOF
:Mount
:: Mount the Windows Image into the directory.
Echo+
Echo [+] Mounting WIM Image...
If /I "%MountImage%" EQU "True" (
"%Dism%" /Mount-Image /ImageFile:"%WindowsImage%" /Index:"%ImageIndex%" /MountDir:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%" || (
Echo+
Echo [x] Error mounting the Image Index "%ImageIndex%" in "%MountDir%"
Echo [i] Ensure that the Image Index exist.
Echo [i] Ensure that you have Admin rights to write inside the directory.
Echo [i] Ensure that the directory is not already mounted.
Echo [i] Ensure that the directory is fully empty.
Echo+
REM Try to unmount the failed image and discard changes.
If /I "%UnmountImage%" EQU "True" (
Echo [+] Unmounting and discarding changes...
"%Dism%" /Unmount-WIM /Discard /MountDir:"%MountDir%"
)
Pause&Exit
)
)
Goto:EOF
:CleanUp
Echo [+] CleaningUp WIM Image...
"%Dism%" /CleanUp-Image /StartComponentCleanUp /Image:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%" /Quiet
Echo+
Goto:EOF
:Unmount
:: Unmount the Windows Image commiting changes.
Echo [+] Unmounting WIM Image...
If /I "%UnmountImage%" EQU "True" (
"%Dism%" /Unmount-WIM /Commit /MountDir:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%"
)
Goto:EOF
:Rebuild
If /I "%Rebuild%" EQU "False" (Goto:EOF)
Echo+
Echo [+] Rebuilding WIM image...
("%ImageX%" /Compress Maximum /Export "%WindowsImage%" "*" "%TEMP%\Rebuilt Image.wim" /Check) && (
Del /Q /F "%WindowsImage%" 1>NUL
Move /Y "%TEMP%\Rebuilt Image.wim" "%WindowsImage%" 1>NUL
) || (
Echo [x] Error rebuilding Image "%WindowsImage%" to "%TEMP%\Rebuilt Image.wim".
)
Goto :EOF
:StartTimer
Set "StartingDate=%Date%"
Set "StarttingTime=%Time:~0,-3%"
Goto :EOF
:StopTimer
(
Echo Minutes = DateDiff^("n", "%StartingDate% %StarttingTime%", Now^)
Echo WScript.Echo Minutes ^& " Minutes"
)>"%TEMP%\%~n0 MinuteDiff.vbs"
For /F "Tokens=*" %%# In (
'Cscript.exe /Nologo "%TEMP%\%~n0 MinuteDiff.vbs"'
) Do (
Set "ElapsedTime=%%#"
)
Goto:EOF
:WriteConvertBytesScript
If Exist "%TEMP%\%~n0 Convert Bytes.vbs" (Goto:EOF)
(
Echo Suffix = Array^("Bytes", "KB", "MB", "GB", "TB"^)
Echo+
Echo Function Convert^(Bytes^)
Echo Convert = convert0^(Bytes, 0^)
Echo End Function
Echo+
Echo Function Convert0^(Bytes, Level^)
Echo If Bytes ^>= 1024 Then
Echo Bytes = Round^(Bytes / 1024, 2^)
Echo Level = Level + 1
Echo Convert0 = Convert0^(Bytes, Level^)
Echo End If
Echo Convert0 = Bytes ^& " " ^& Suffix^(Level^)
Echo End Function
Echo+
Echo WScript.Echo Convert^(WScript.Arguments^(0^)^)
)>"%TEMP%\%~n0 Convert Bytes.vbs"
Goto:EOF
:GetWIMSizeBefore
Call :WriteConvertBytesScript
For %%# in ("%WindowsImage%") Do (Set "WIMSizeBefore=%%~z#")
For /F "Tokens=*" %%# In (
'Cscript.exe /Nologo "%TEMP%\%~n0 Convert Bytes.vbs" "%WIMSizeBefore%"'
) Do (
Set "WIMSizeBefore=%%#"
)
Del /Q "%TEMP%\%~n0 Convert Bytes.vbs"
Goto:EOF
:GetWIMSizeAfter
Call :WriteConvertBytesScript
For %%# in ("%WindowsImage%") Do (Set "WIMSizeAfter=%%~z#")
For /F "Tokens=*" %%# In (
'Cscript.exe /Nologo "%TEMP%\%~n0 Convert Bytes.vbs" "%WIMSizeAfter%"'
) Do (
Set "WIMSizeAfter=%%#"
)
Del /Q "%TEMP%\%~n0 Convert Bytes.vbs"
Goto:EOF
:ParsePackages
Set /A "PackagesRemovedCount=0"
Set /A "PackagesFailedCount=0"
Set /A "PackagesNotFoundCount=0"
:: Unhide packages and take registry ownership.
"%WIMRegistryTweakTool%" /p "%MountDir%"
Echo+
:: Remove Packages.
For /F "UseBackQ Tokens=* Delims=" %%# In ("%PackageList%") Do (
Echo [+] Removing package: %%~#
"%Dism%" /Remove-Package /PackageName:"%%~#" /Image:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%" /Quiet 1>NUL
Call Set /A "ExitCode=%%Errorlevel%%"
(Call Echo "%%ExitCode%%"| Findstr.exe "^\"0\"$" 1>NUL 2>&1) && (
Call Set /A "PackagesRemovedCount+=1"
)
(Call Echo "%%ExitCode%%"| Findstr.exe "^\"5\"$" 1>NUL 2>&1) && (
Call Set /A "PackagesFailedCount+=1"
Echo Failed to remove package: %%~#>>"%LogFile%"
)
(Call Echo "%%ExitCode%%"| Find.exe "-2146498555" 1>NUL 2>&1) && (
Call Set /A "PackagesNotFoundCount+=1"
Echo Package is not installed: %%~#>>"%LogFile%"
)
)
Goto:EOF
REM ====================
REM File Error Controls:
REM ====================
:CheckErrors
:: WIM File Error-Check.
If /I "MountImage" EQU "True" If Not Exist "%WindowsImage%" (
Echo [x] Windows Image not found at: "%WindowsImage%" | MORE
Pause&Exit
)
:: PackageList File Error-Check.
If Not Exist "%PackageList%" (
Echo [x] PackageList not found at: "%PackageList%" | MORE
Pause&Exit
)
:: 'DISM.exe' File Error-Check.
If Not Exist "%DISM%" (
Echo [x] 'DISM' process not found at: "%DISM%" | MORE
Pause&Exit
)
:: 'ImageX.exe' File Error-Check.
If Not Exist "%ImageX%" (
Echo [x] 'ImageX' process not found at: "%ImageX%" | MORE
Pause&Exit
)
:: 'WIM Registry Tweak Tool.exe' File Error-Check.
If Not Exist "%WIMRegistryTweakTool%" (
Echo [x] 'WIM Registry Tweak Tool' process not found at: "%WIMRegistryTweakTool%" | MORE
Pause&Exit
)
Goto:EOF
DirectPlay
FaxServicesClientPackage
Internet-Explorer-Optional-amd64
Microsoft-Windows-MobilePC-LocationProvider-INF
MicrosoftWindowsPowerShellV2
MicrosoftWindowsPowerShellV2Root
Printing-Foundation-InternetPrinting-Client
Printing-XPSServices-Features
WindowsMediaPlayer
Xps-Foundation-Xps-Viewer
@Echo OFF
REM =================
REM Console Settings:
REM =================
Title WIM Feature Uninstaller - By Elektro
Mode Con Cols=150 Lines=50
CHCP 1252 1>NUL & REM Windows-1252, Spanish-Latin.
REM =====
REM Info:
REM =====
Echo+
Echo -----------------------------------------------------------------------------
Echo This script mounts a Windows Image ^(WIM^) and then disables Windows features
Echo -----------------------------------------------------------------------------
Echo+
REM ====================
REM User defined values:
REM ====================
REM This value indicates whether the Windows Image should be mounted.
REM True = 'DISM' will try to mount the 'WIM' image.
REM False = 'DISM' will not try to mount the WIM image.
REM Set this value to 'FALSE' if the 'WIM' image is already mounted in the specified mount directory,
REM Otherwise, keep it as 'TRUE'.
Set "MountImage=True"
REM This value indicates whether the Windows Image should be unmounted at the end.
REM True = 'DISM' will try to unmount the 'WIM' image.
REM False = 'DISM' will not try to unmount the WIM image.
REM Set this value to 'FALSE' if you want to keep the image mounted to make other changes,
REM Otherwise, keep it as 'TRUE'.
Set "UnmountImage=True"
REM This value indicates whether the Windows Image should be rebuilt at the end.
REM True = 'ImageX' will try to rebuild the 'WIM' image.
REM False = 'ImageX' will keep the 'WIM' image as is.
REM Set this value to 'FALSE' if you want to keep the image with normal size to make other changes,
REM Otherwise, keep it as 'TRUE'.
Set "Rebuild=True"
REM This value indicates the 'WIM' image to be mounted.
Set "WindowsImage=%UserProfile%\Desktop\win 8 .1\win\sources\install.wim"
REM This value indicates the Image Index of the 'WIM' image.
Set "ImageIndex=1"
REM This value indicates the directory where to mount the 'WIM' image.
Set "MountDir=%HomeDrive%\WinMount"
REM This value indicates the textfile that contains the names of the features to disable.
Set "FeatureList=%CD%\Features.txt"
REM This value indicates the ubication of 'ImageX.exe' file.
Set "ImageX=%CD%\Tools\Dism\ImageX.exe"
REM This value indicates the ubication of a custom 'DISM.exe' file if needed.
REM Default ubication: "%SystemRoot%\System32\Dism.exe"
Set "Dism=%CD%\Tools\Dism\Dism.exe"
REM This value indicates the ubication of the logfile that will record 'DISM' errors.
Set "DismLogfile=%CD%\%~n0 DISM.log"
REM This value indicates the logging-level of the 'DISM' process.
REM 1 = Errors only
REM 2 = Errors and warnings
REM 3 = Errors, warnings, and informational
REM 4 = All of the information listed previously, plus debug output
Set /A "DismLogLevel=2"
REM This value indicates the ubication of the logfile that will record Main information.
Set "Logfile=%CD%\%~n0.log"
REM =====
REM Main:
REM =====
:: Call Methods.
Call :CheckErrors
Call :CreateLogs
Call :CreateMountDir
Call :GetWIMSizeBefore
Call :StartTimer
Call :Mount
CLS
Call :ParseFeatures
CLS
Call :CleanUp
Call :Unmount
Call :Rebuild
Call :StopTimer
Call :GetWIMSizeAfter
Call :EndLog
Pause&Exit
REM ========
REM Methods:
REM ========
:CreateLogs
:: Create the 'DISM' logfile with 'ANSI' encoding,
:: this is necessary to record a non-default 'DISM' loglevel such as '1' or '2'.
Echo+ >"%DismLogfile%"
:: Create the Main logfile and record starting info on it.
Echo+ >"%Logfile%"
(
Echo+
Echo WIM Feature Uninstaller
Echo ===========================
Echo %DATE% ^| %TIME:~0,-3%
Echo /\/\/\/\/\/\/\/\/\/\/\/\/\/
Echo+
Echo [i] Mount Image?...: %MountImage%
Echo [i] Unmount Image?.: %UnmountImage%
Echo+
Echo [i] Windows Image..: %WindowsImage%
Echo [i] Image Index....: %ImageIndex%
Echo [i] Mount Directory: %MountDir%
Echo+
Echo [i] Dism Path......: %Dism%
Echo [i] Dism Log File..: %DismLogfile%
Echo [i] Dism Log Level.: %DismLogLevel%
Echo+
Echo [i] Feature List...: %FeatureList%
Echo [i] Log File.......: %Logfile%
Echo+
Echo ===========================
)>"%Logfile%"
:: Display starting log info.
Type "%Logfile%"
:: Continue writting log.
(
Echo+
Echo Feature conflicts:
Echo ==================
Echo+
)>>"%LogFile%"
Goto:EOF
:EndLog
(
Echo+
Echo [i] Done!
Echo [i] WIM Image Size Before.........: %WIMSizeBefore%
Echo [i] WIM Image Size After..........: %WIMSizeAfter%
Echo [i] Features Successfully Disabled: %FeaturesRemovedCount% Packages.
Echo [i] Features Failed To Disable....: %FeaturesFailedCount% Packages.
Echo [i] Features Not Found............: %FeaturesNotFoundCount% Packages.
Echo [i] Elapsed Time..................: %ElapsedTime%
Echo+
)>>"%LogFile%"
:: Display ending information.
CLS
Type "%LogFile%"
Goto:EOF
:CreateMountDir
:: Create the mount directory.
(
If Not Exist "%MountDir%" If /I "%MountImage%" EQU "True" (
MkDir "%MountDir%" 2>NUL
)
) || (
Echo+
Echo [x] Error trying to create the directory "%MountDir%" to mount the Windows Image.
Echo [i] Ensure that you have Admin rights to create the directory.
Echo [i] Ensure that the directory name does not contains illegal characters.
Echo+
Pause&Exit
)
Goto:EOF
:Mount
:: Mount the Windows Image into the directory.
Echo+
Echo [+] Mounting WIM Image...
If /I "%MountImage%" EQU "True" (
"%Dism%" /Mount-Image /ImageFile:"%WindowsImage%" /Index:"%ImageIndex%" /MountDir:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%" || (
Echo+
Echo [x] Error mounting the Image Index "%ImageIndex%" in "%MountDir%"
Echo [i] Ensure that the Image Index exist.
Echo [i] Ensure that you have Admin rights to write inside the directory.
Echo [i] Ensure that the directory is not already mounted.
Echo [i] Ensure that the directory is fully empty.
Echo+
REM Try to unmount the failed image and discard changes.
If /I "%UnmountImage%" EQU "True" (
Echo [+] Unmounting and discarding changes...
"%Dism%" /Unmount-WIM /Discard /MountDir:"%MountDir%"
)
Pause&Exit
)
)
Goto:EOF
:CleanUp
Echo [+] CleaningUp WIM Image...
"%Dism%" /CleanUp-Image /StartComponentCleanUp /Image:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%" /Quiet
Echo+
Goto:EOF
:Unmount
:: Unmount the Windows Image commiting changes.
Echo [+] Unmounting WIM Image...
If /I "%UnmountImage%" EQU "True" (
"%Dism%" /Unmount-WIM /Commit /MountDir:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%"
)
Goto:EOF
:Rebuild
If /I "%Rebuild%" EQU "False" (Goto:EOF)
Echo+
Echo [+] Rebuilding WIM image...
("%ImageX%" /Compress Maximum /Export "%WindowsImage%" "*" "%TEMP%\Rebuilt Image.wim" /Check) && (
Del /Q /F "%WindowsImage%" 1>NUL
Move /Y "%TEMP%\Rebuilt Image.wim" "%WindowsImage%" 1>NUL
) || (
Echo [x] Error rebuilding Image "%WindowsImage%" to "%TEMP%\Rebuilt Image.wim".
)
Goto :EOF
:StartTimer
Set "StartingDate=%Date%"
Set "StarttingTime=%Time:~0,-3%"
Goto :EOF
:StopTimer
(
Echo Minutes = DateDiff^("n", "%StartingDate% %StarttingTime%", Now^)
Echo WScript.Echo Minutes ^& " Minutes"
)>"%TEMP%\%~n0 MinuteDiff.vbs"
For /F "Tokens=*" %%# In (
'Cscript.exe /Nologo "%TEMP%\%~n0 MinuteDiff.vbs"'
) Do (
Set "ElapsedTime=%%#"
)
Goto:EOF
:WriteConvertBytesScript
If Exist "%TEMP%\%~n0 Convert Bytes.vbs" (Goto:EOF)
(
Echo Suffix = Array^("Bytes", "KB", "MB", "GB", "TB"^)
Echo+
Echo Function Convert^(Bytes^)
Echo Convert = convert0^(Bytes, 0^)
Echo End Function
Echo+
Echo Function Convert0^(Bytes, Level^)
Echo If Bytes ^>= 1024 Then
Echo Bytes = Round^(Bytes / 1024, 2^)
Echo Level = Level + 1
Echo Convert0 = Convert0^(Bytes, Level^)
Echo End If
Echo Convert0 = Bytes ^& " " ^& Suffix^(Level^)
Echo End Function
Echo+
Echo WScript.Echo Convert^(WScript.Arguments^(0^)^)
)>"%TEMP%\%~n0 Convert Bytes.vbs"
Goto:EOF
:GetWIMSizeBefore
Call :WriteConvertBytesScript
For %%# in ("%WindowsImage%") Do (Set "WIMSizeBefore=%%~z#")
For /F "Tokens=*" %%# In (
'Cscript.exe /Nologo "%TEMP%\%~n0 Convert Bytes.vbs" "%WIMSizeBefore%"'
) Do (
Set "WIMSizeBefore=%%#"
)
Del /Q "%TEMP%\%~n0 Convert Bytes.vbs"
Goto:EOF
:GetWIMSizeAfter
Call :WriteConvertBytesScript
For %%# in ("%WindowsImage%") Do (Set "WIMSizeAfter=%%~z#")
For /F "Tokens=*" %%# In (
'Cscript.exe /Nologo "%TEMP%\%~n0 Convert Bytes.vbs" "%WIMSizeAfter%"'
) Do (
Set "WIMSizeAfter=%%#"
)
Del /Q "%TEMP%\%~n0 Convert Bytes.vbs"
Goto:EOF
:ParseFeatures
Set /A "FeaturesRemovedCount=0"
Set /A "FeaturesFailedCount=0"
Set /A "FeaturesNotFoundCount=0"
:: Disable Features.
For /F "UseBackQ Tokens=* Delims=" %%# In ("%FeatureList%") Do (
Echo [+] Disabling Feature: %%~#
"%Dism%" /Disable-Feature /FeatureName:"%%~#" /Image:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%" /Quiet 1>NUL
Call Set /A "ExitCode=%%Errorlevel%%"
(Call Echo "%%ExitCode%%"| Findstr.exe "^\"0\"$" 1>NUL 2>&1) && (
Call Set /A "FeaturesRemovedCount+=1"
)
(Call Echo "%%ExitCode%%"| Findstr.exe "^\"5\"$" 1>NUL 2>&1) && (
Call Set /A "FeaturesFailedCount+=1"
Echo Failed to disable feature: %%~#>>"%LogFile%"
)
(Call Echo "%%ExitCode%%"| Find.exe "-2146498548" 1>NUL 2>&1) && (
Call Set /A "FeaturesNotFoundCount+=1"
Echo Feature is not found.....: %%~#>>"%LogFile%"
)
)
Goto:EOF
REM ====================
REM File Error Controls:
REM ====================
:CheckErrors
:: WIM File Error-Check.
If /I "MountImage" EQU "True" If Not Exist "%WindowsImage%" (
Echo [x] Windows Image not found at: "%WindowsImage%" | MORE
Pause&Exit
)
:: FeatureList File Error-Check.
If Not Exist "%FeatureList%" (
Echo [x] FeatureList not found at: "%FeatureList%" | MORE
Pause&Exit
)
:: 'DISM.exe' File Error-Check.
If Not Exist "%DISM%" (
Echo [x] 'DISM' process not found at: "%DISM%" | MORE
Pause&Exit
)
:: 'ImageX.exe' File Error-Check.
If Not Exist "%ImageX%" (
Echo [x] 'ImageX' process not found at: "%ImageX%" | MORE
Pause&Exit
)
Goto:EOF
@Echo OFF
REM =================
REM Console Settings:
REM =================
Title Folders2List - By Elektro
Mode Con Cols=150 Lines=50
CHCP 1252 1>NUL & REM Windows-1252, Spanish-Latin.
REM =====
REM Info:
REM =====
Echo+
Echo ------------------------------------------------------------------------------------------------------------------------------------
Echo This script writes a textfile containing the relative paths of the folder structure at the working directory and it's subdirectories
Echo ------------------------------------------------------------------------------------------------------------------------------------
Echo+
REM ====================
REM User defined values:
REM ====================
REM This value indicates the directory where to list it's folder structure.
Set "WorkingDir=%CD%"
REM This value indicates the resulting folder list.
Set "OutputFile=%CD%\Folders.txt"
REM This value indicates how the hidden folders are threated when listing the folder structure.
REM True = List folders and also folders with the 'hidden' attribute.
REM False = List only normal folders without the 'hidden' attribute.
Set "IncludeHiddenFolders=True"
REM =====
REM Main:
REM =====
:: Display starting info.
Echo [i] Working Directory...: %WorkingDir%
Echo [i] Output file.........: %OutputFile%
Echo [i] Include Hidden Files: %IncludeHiddenFolders%
Echo+
:: Call Methods.
Call :CheckErrors
Call :StartTimer
Call :ListFolders "%IncludeHiddenFolders%"
Call :StopTimer
:: Finish.
Echo [i] Done! | MORE
Echo [i] Listed Folders: %FolderCount% folders.
Echo [i] Elapsed Time..: %ElapsedTime%
Echo+
Pause&Exit
REM ========
REM Methods:
REM ========
:StartTimer
Set "StartingDate=%Date%"
Set "StarttingTime=%Time:~0,-3%"
Goto :EOF
:StopTimer
(
Echo Minutes = DateDiff^("n", "%StartingDate% %StarttingTime%", Now^)
Echo WScript.Echo Minutes ^& " Minutes"
)>"%TEMP%\%~n0 MinuteDiff.vbs"
For /F "Tokens=*" %%# In (
'Cscript.exe /Nologo "%TEMP%\%~n0 MinuteDiff.vbs"'
) Do (
Set "ElapsedTime=%%#"
)
Goto:EOF
:ListFolders
Echo [+] Collecting folders, this operation could take some minutes long, please wait...
If /I "%~1" EQU "True" (Call :ListHiddenFolders)
If /I "%~1" EQU "False" (Call :ListNormalFolders)
Goto:EOF
:ListNormalFolders
(FOR /D /R "%WorkingDir%" %%# in ("*") DO (
Set "Folder=%%~f#"
Call Echo %%Folder:%WorkingDir%=.%%
Set /A "FolderCount+=1"
))>"%OutputFile%"
Goto:EOF
:ListHiddenFolders
(FOR /F "Tokens=* Delims=" %%# in ('Dir /B /S /AD "%WorkingDir%\*"') DO (
Set "Folder=%%~f#"
Call Echo %%Folder:%WorkingDir%=.%%
Set /A "FolderCount+=1"
))>"%OutputFile%"
Goto:EOF
REM ===============
REM Error Controls:
REM ===============
:CheckErrors
:: 'IncludeHiddenFolders' Value check.
If /I "%IncludeHiddenFolders%" NEQ "True" If /I "%IncludeHiddenFolders%" NEQ "False" (
Echo [x] Error parsing parameter 'IncludeHiddenFolders',
Echo value '%IncludeHiddenFolders%' is not a Boolean value.
Pause&Exit
)
Goto:EOF
CitarExcluded Files:
===============
.\Filesize Truncator.bat
.\Folders2List.bat
.\Windows\WinSxS\Get Manifests.bat
@Echo OFF
REM =================
REM Console Settings:
REM =================
Title Files2List - By Elektro
Mode Con Cols=150 Lines=50
CHCP 1252 1>NUL & REM Windows-1252, Spanish-Latin.
REM =====
REM Info:
REM =====
Echo+
Echo ----------------------------------------------------------------------------------------------------------------------------------
Echo This script writes a textfile containing the relative paths of the file structure at the working directory and it's subdirectories
Echo ----------------------------------------------------------------------------------------------------------------------------------
Echo+
REM ====================
REM User defined values:
REM ====================
REM This value indicates the directory where to list it's file structure.
Set "WorkingDir=%CD%"
REM This value indicates the resulting file list.
Set "OutputFile=%CD%\Files.txt"
REM This value indicates the ubication of the logfile that will record info.
Set "Logfile=%CD%\%~n0.log"
REM This value indicates the File-Extensions to exclude during the process.
REM ( Use an ';' delimiter to separate multiple extensions )
Set "ExcludeExts=.bat;.cmd"
REM This value indicates the filenames to exclude during the process.
REM ( Use an ';' delimiter to separate multiple filenames )
Set "ExcludeNames=%~nx0"
REM This value indicates the files to exclude during the process.
REM ( Use an ';' delimiter to separate multiple files )
Set "ExcludeFiles=%OutputFile%;%Logfile%"
REM This value indicates how the hidden files are threated when listing the file structure.
REM True = List files and also files with the 'hidden' attribute.
REM False = List only normal files without the 'hidden' attribute.
Set "IncludeHiddenFiles=True"
REM =====
REM Main:
REM =====
:: Call Methods.
Call :CheckErrors
Call :CreateLog
Call :StartTimer
Call :ListFiles "%IncludeHiddenFiles%"
Call :StopTimer
Call :EndLog
Pause&Exit
REM ========
REM Methods:
REM ========
:CreateLog
:: Create the Script Logfile and record starting info on it.
FSutil.exe File CreateNew "%LogFile%" "0" 1>NUL
(
Echo+
Echo Files 2 List
Echo =========================
Echo %DATE% ^| %TIME:~0,-3%
Echo /\/\/\/\/\/\/\/\/\/\/\/\/
Echo+
Echo [i] Working Directory...: %WorkingDir%
Echo [i] Include Hidden Files: %IncludeHiddenFiles%
Echo+
Echo [i] Excluded Extensions.: %ExcludeExts%
Echo [i] Excluded Filenames..: %ExcludeNames%
Echo [i] Excluded Files......: %ExcludeFiles%
Echo+
Echo [i] Output file.........: %OutputFile%
Echo [i] Log file............: %LogFile%
Echo+
Echo =========================
)>"%LogFile%"
:: Display starting log info.
Type "%LogFile%" | MORE
:: Continue writting log.
(
Echo+
Echo Excluded Files:
Echo ===============
Echo+
)>>"%LogFile%"
Goto:EOF
:EndLog
(
Echo+
Echo [i] Done! | MORE
Echo [i] Listed Files..: %ListedFileCount% files.
Echo [i] Excluded Files: %ExcludedFileCount% files.
Echo [i] Elapsed Time..: %ElapsedTime%
Echo+
)>>"%LogFile%"
:: Display ending information.
CLS
Type "%LogFile%"
Goto:EOF
:StartTimer
Set "StartingDate=%Date%"
Set "StarttingTime=%Time:~0,-3%"
Goto :EOF
:StopTimer
(
Echo Minutes = DateDiff^("n", "%StartingDate% %StarttingTime%", Now^)
Echo WScript.Echo Minutes ^& " Minutes"
)>"%TEMP%\%~n0 MinuteDiff.vbs"
For /F "Tokens=*" %%# In (
'Cscript.exe /Nologo "%TEMP%\%~n0 MinuteDiff.vbs"'
) Do (
Set "ElapsedTime=%%#"
)
Goto:EOF
:ListFiles
Echo [+] Collecting files, this operation could take some minutes long, please wait...
If /I "%~1" EQU "True" (Call :ListHiddenFiles)
If /I "%~1" EQU "False" (Call :ListNormalFiles)
Goto:EOF
:ListNormalFiles
(FOR /R "%WorkingDir%" %%# in ("*") DO (
Set "Exclude="
If Defined ExcludeExts (
(
Echo "%ExcludeExts%" | Find.exe /I "%%~x#" 1>NUL 2>&1
) && (
Call Set "Exclude=True"
)
)
If Defined ExcludeNames (
(
Echo "%ExcludeNames%" | Find.exe /I "%%~nx#" 1>NUL 2>&1
) && (
Call Set "Exclude=True"
)
)
If Defined ExcludeFiles (
(
Echo "%ExcludeFiles%" | Find.exe /I "%%~f#" 1>NUL 2>&1
) && (
Call Set "Exclude=True"
)
)
If Not Defined Exclude (
Set "File=%%~f#"
Call Echo %%File:%WorkingDir%=.%%
Set /A "ListedFileCount+=1"
) Else (
Set "File=%%~f#"
Call Echo %%File:%WorkingDir%=.%%>>"%LogFile%"
Set /A "ExcludedFileCount+=1"
)
))>"%OutputFile%"
Goto :EOF
:ListHiddenFiles
(FOR /F "Tokens=* Delims=" %%# in ('Dir /B /S /A-D "%WorkingDir%\*"') DO (
Set "Exclude="
If Defined ExcludeExts (
(
Echo "%ExcludeExts%" | Find.exe /I "%%~x#" 1>NUL 2>&1
) && (
Call Set "Exclude=True"
)
)
If Defined ExcludeNames (
(
Echo "%ExcludeNames%" | Find.exe /I "%%~nx#" 1>NUL 2>&1
) && (
Call Set "Exclude=True"
)
)
If Defined ExcludeFiles (
(
Echo "%ExcludeFiles%" | Find.exe /I "%%~f#" 1>NUL 2>&1
) && (
Call Set "Exclude=True"
)
)
If Not Defined Exclude (
Set "File=%%~f#"
Call Echo %%File:%WorkingDir%=.%%
Set /A "ListedFileCount+=1"
) Else (
Set "File=%%~f#"
Call Echo %%File:%WorkingDir%=.%%>>"%LogFile%"
Set /A "ExcludedFileCount+=1"
)
))>"%OutputFile%"
Goto:EOF
REM ===============
REM Error Controls:
REM ===============
:CheckErrors
:: 'IncludeHiddenFiles' Value check.
If /I "%IncludeHiddenFiles%" NEQ "True" If /I "%IncludeHiddenFiles%" NEQ "False" (
Echo [x] Error parsing parameter 'IncludeHiddenFiles',
Echo value '%IncludeHiddenFiles%' is not a Boolean value.
Pause&Exit
)
Goto:EOF
Ruta relativa del archivo que va a ser reemplazado;Ruta relativao absoluta del archivo que se copiará
Ruta relativa del recurso a modificar;Nombre del recurso;Ruta del recurso modificado
CitarResourceList Help - By Elektro
##############################
========================
To add or replace files:
========================
Syntax: OutFile;InFile
· Outfile:
Indicates the file that will be Created/Replaced.
Should be written as a relative mount filepath.
· InFile:
Indicates the file that will be copied to the OutFile.
Should be written as an absolute filepath.
Examples:
---------
Sources\Background.bmp;.\Resources\Background.bmp
Sources\Background.bmp;C:\Resources\Background.bmp
=====================
To replace resources:
=====================
Syntax: ResourceFile;ResourceName;InResource
· ResourceFile:
Indicates the dll file that will be opened to replace resources inside.
Should be written as a relative mount filepath.
· ResourceName:
Indicates the resource name that will be replaced inside the resource file.
· InResource:
Indicates the resource to copy inside the resource file.
Should be written as an absolute filepath.
Examples:
---------
Sources\spwizimg.dll;517;.\Resources\517.bmp
Sources\spwizimg.dll;517;C:\Resources\517.bmp
Sources\Background.bmp;.\Resources\Background.bmp
Windows\System32\Setup.bmp;.\Resources\Setup.bmp
Sources\spwizimg.dll;405;.\Resources\405.bmp
Sources\spwizimg.dll;407;.\Resources\407.bmp
Sources\spwizimg.dll;408;.\Resources\408.bmp
Sources\spwizimg.dll;516;.\Resources\516.bmp
Sources\spwizimg.dll;517;.\Resources\517.bmp
Sources\w32uiimg.dll;207;.\Resources\207.bmp
@Echo Off & Title WIM Resource Replacer - By Elektro
Mode Con Cols=150 Lines=50
REM ======
REM About:
REM ======
:: Header Info.
Echo+
Echo -----------------------------------------------------------------------------------------
Echo This script mounts a Windows Image ^(WIM^) to replace image resources of a resource file.
Echo -----------------------------------------------------------------------------------------
Echo+
REM ====================
REM User defined values:
REM ====================
:: User defined values.
REM This value indicates whether the Windows Image should be mounted.
REM True = 'DISM' will try to mount the 'WIM' image.
REM False = 'DISM' will not try to mount the WIM image.
REM Set this value to 'FALSE' if the 'WIM' image is already mounted in the specified mount directory,
REM Otherwise, keep it as 'TRUE'.
Set "MountImage=True"
REM This value indicates whether the Windows Image should be unmounted at the end.
REM True = 'DISM' will try to unmount the 'WIM' image.
REM False = 'DISM' will not try to unmount the WIM image.
REM Set this value to 'FALSE' if you want to keep the image mounted to make other changes,
REM Otherwise, keep it as 'TRUE'.
Set "UnmountImage=True"
REM This value indicates the 'WIM' image to be mounted.
Set "WindowsImage=%UserProfile%\Desktop\win 8 .1\win\sources\Boot.wim"
REM This value indicates the Image Index of the 'WIM' image.
Set "ImageIndex=2"
REM This value indicates the directory where to mount the 'WIM' image.
Set "MountDir=%HomeDrive%\WinBootMount"
REM This value indicates the location of Anolis Resourcer 'Anolis.exe' file.
Set "Anolis=%CD%\Tools\Anolis.exe"
REM This value indicates the textfile that contains the Recource files to replace.
Set "ResourceList=%CD%\Resources.txt"
REM This value indicates the location of a custom 'DISM.exe' file if needed.
REM Default location:
REM "%SystemRoot%\System32\Dism.exe"
Set "Dism=%CD%\Tools\Dism\Dism.exe"
REM This value indicates the location of the logfile that will record 'DISM' exceptions.
Set "DismLogfile=%UserProfile%\Desktop\Dism.log"
REM This value indicates the logging-level of the 'DISM' process.
REM 1 = Errors only
REM 2 = Errors and warnings
REM 3 = Errors, warnings, and informational
REM 4 = All of the information listed previously, plus debug output
Set /A "DismLogLevel=2"
REM =====
REM Main:
REM =====
Call :CheckErrors
Call :CreateLog
Call :CreateMountDir
Call :Mount
CLS
Call :ParseResources
Call :Unmount
Echo+
Echo [i] Done!
Pause&Exit
REM ========
REM Methods:
REM ========
:CreateLog
:: Create the 'DISM' logfile with 'ANSI' encoding,
:: this is necessary to record a non-default 'DISM' loglevel such as '1' or '2'.
Echo+ >"%DismLogfile%"
:: Record initial info.
(
Echo+
Echo Automated DISM processing:
Echo ==========================
Echo+
Echo WIM Resource Replacer
Echo+
Echo [i] Date: %DATE% - %TIME:~0,2%:%TIME:~3,2%:%TIME:~6,2%
Echo+
Echo [i] Mount Image?...: %MountImage%
Echo [i] Unmount Image?.: %UnmountImage%
Echo+
Echo [i] Windows Image..: %WindowsImage%
Echo [i] Image Index....: %ImageIndex%
Echo [i] Mount Directory: %MountDir%
Echo+
Echo [i] Dism Path......: %Dism%
Echo [i] Dism Logfile...: %DismLogfile%
Echo [i] Dism Log Level.: %DismLogLevel%
Echo+
Echo [i] Anolis Path....: %Anolis%
Echo+
Echo ===========================
)>"%DismLogfile%"
:: Display initial info.
Type "%DismLogfile%"
Goto:EOF
:CreateMountDir
:: Create the mount directory.
(
If Not Exist "%MountDir%" If /I "%MountImage%" EQU "True" (
MkDir "%MountDir%" 2>NUL
)
) || (
Echo+
Echo [X] Error trying to create the directory "%MountDir%" to mount the Windows Image.
Echo [i] Ensure that you have Admin rights to create the directory.
Echo [i] Ensure that the directory name does not contains illegal characters.
Echo+
Pause&Exit
)
Goto:EOF
:Mount
:: Mounts the Windows Image into the mount directory.
If /I "%MountImage%" EQU "True" (
"%Dism%" /Mount-Image /ImageFile:"%WindowsImage%" /Index:"%ImageIndex%" /MountDir:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%" || (
Echo+
Echo [X] Error mounting the Image Index "%ImageIndex%" in "%MountDir%"
Echo [i] Ensure that the Image Index exist.
Echo [i] Ensure that you have Admin rights to write inside the directory.
Echo [i] Ensure that the directory is not already mounted.
Echo [i] Ensure that the directory is fully empty.
Echo+
REM Try to unmount the failed image and discard changes.
If /I "%UnmountImage%" EQU "True" (
"%Dism%" /Unmount-WIM /Discard /MountDir:"%MountDir%"
)
Exit
)
)
Goto:EOF
:ParseResources
For /F "UseBackQ Tokens=1,2,* Delims=;" %%a In ("Resources.txt") Do (
If /I "%%~xa" EQU ".dll" (Call :ReplaceResource "%MountDir%\%%~a" "%%~b" "%%~c")
If /I "%%~xa" NEQ ".dll" (Call :CopyFile "%MountDir%\%%~a" "%%~b")
)
Goto:EOF
:Unmount
:: Unmount the Windows Image commiting changes.
If /I "%UnmountImage%" EQU "True" (
"%Dism%" /Unmount-WIM /Commit /MountDir:"%MountDir%" /English /LogPath:"%DismLogfile%" /LogLevel:"%DismLogLevel%"
)
Goto:EOF
:TakeOwn
Takeown.exe /F "%~f1" 1>NUL
ICacls.exe "%~f1" /Grant "%UserName%":"F" 1>NUL
Goto:EOF
:CopyFile
Echo [+] Copying "%~2" to "%~1"
If Not Exist "%~2" (
Echo [X] Can't locate the input file "%~2". | MORE
Goto:EOF
)
Call :TakeOwn "%~f1"
Copy /Y "%~f2" "%~f1" 1>NUL
Goto:EOF
:ReplaceResource
Echo [+] Replacing Resource Name "%~2" with "%~3" in resource file "%~f1"
If Not Exist "%~1" (
Echo [X] Can't locate the resource file to open "%~1". | MORE
Goto:EOF
)
If Not Exist "%~3" (
Echo [X] Can't locate the resource to copy "%~3". | MORE
Goto:EOF
)
Call :TakeOwn "%~1"
If /I "%~x3" EQU ".bmp" (
Start /W "Anolis" "%Anolis%" -op:upd -src:"%~f1" -type:Bitmap -name:"%~2" -lang:1033 -file:"%~f3")
)
If /I "%~x3" EQU ".ico" (
Start /W "Anolis" "%Anolis%" -op:upd -src:"%~f1" -type:Icon -name:"%~2" -lang:1033 -file:"%~f3")
)
Goto:EOF
REM ====================
REM File Error Controls:
REM ====================
:CheckErrors
:: WIM File Error-Check.
If /I "MountImage" EQU "True" If Not Exist "%WindowsImage%" (
Echo [X] Windows Image not found in: "%WindowsImage%" | MORE
Pause&Exit
)
:: ResourceList File Error-Check.
If Not Exist "%ResourceList%" (
Echo [X] Resource-List file not found in: "%ResourceList%" | MORE
Pause&Exit
)
:: DISM File Error-Check.
If Not Exist "%DISM%" (
Echo [X] DISM process not found in: "%DISM%" | MORE
Pause&Exit
)
:: Anolis Resourcer File Error-Check.
If Not Exist "%Anolis%" (
Echo [X] Anolis process not found in: "%Anolis%" | MORE
Pause&Exit
)
Goto:EOF
Dism.exe /?
Dism.exe /Get-ImageInfo /ImageFile:"Imagen.wim"
Dism.exe /Get-ImageInfo /ImageFile:".\Boot.wim"
Dism.exe /Mount-Image /ImageFile:"Imagen.wim" /Index:"Índice de imagen" /MountDir:"Directorio de montaje"
MKDir "C:\WinPE Mount"
.\Dism.exe /Mount-Image /ImageFile:"%CD%\Boot.wim" /Index:"2" /MountDir:"C:\WinPE Mount"
Dism.exe /Unmount-WIM /Commit /MountDir:"Directorio montado"
Dism.exe /Unmount-WIM /Commit /MountDir:"C:\WinPE Mount"
Dism.exe /Unmount-WIM /Discard /MountDir:"Directorio montado"
Dism.exe /Unmount-WIM /Discard /MountDir:"C:\WinPE Mount"
ImageX /Export "Imagen de origen.wim" "índice" "Imagen de destino.wim" /Compress "Tipo de compresión" /Check
ImageX /Export ".\Install.wim" "*" ".\New Install.wim" /Compress "Maximum"
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<settings pass="windowsPE">
<component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<UserLocale>es-ES</UserLocale>
<UILanguageFallback>es-ES</UILanguageFallback>
<UILanguage>es-ES</UILanguage>
<SystemLocale>es-ES</SystemLocale>
<InputLocale>es-ES</InputLocale>
<SetupUILanguage>
<UILanguage>es-ES</UILanguage>
</SetupUILanguage>
</component>
<component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Display>
<HorizontalResolution>1920</HorizontalResolution>
<VerticalResolution>1080</VerticalResolution>
<ColorDepth>32</ColorDepth>
</Display>
<UserData>
<ProductKey>
<WillShowUI>OnError</WillShowUI>
<Key>334NH-RXG76-64THK-C7CKG-D3VPT</Key>
</ProductKey>
<AcceptEula>true</AcceptEula>
<Organization>Elektro Studios</Organization>
<FullName>Elektro</FullName>
</UserData>
<EnableNetwork>true</EnableNetwork>
<EnableFirewall>true</EnableFirewall>
<Restart>Restart</Restart>
<ImageInstall>
<OSImage>
<InstallFrom>
<MetaData wcm:action="add">
<Key>/IMAGE/NAME</Key>
<Value>Windows 8.1</Value>
</MetaData>
</InstallFrom>
<WillShowUI>OnError</WillShowUI>
</OSImage>
</ImageInstall>
</component>
</settings>
<settings pass="specialize">
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<AutoLogon>
<Enabled>true</Enabled>
<LogonCount>1</LogonCount>
<Username>Administrator</Username>
</AutoLogon>
<ComputerName>Elektro-PC</ComputerName>
<ProductKey>334NH-RXG76-64THK-C7CKG-D3VPT</ProductKey>
<RegisteredOrganization>Elektro Studios</RegisteredOrganization>
<TimeZone>Romance Standard Time</TimeZone>
<WindowsFeatures>
<ShowInternetExplorer>false</ShowInternetExplorer>
<ShowMediaCenter>false</ShowMediaCenter>
<ShowWindowsMediaPlayer>false</ShowWindowsMediaPlayer>
</WindowsFeatures>
<Themes>
<WindowColor>0</WindowColor>
</Themes>
<DisableAutoDaylightTimeSet>false</DisableAutoDaylightTimeSet>
<BluetoothTaskbarIconEnabled>false</BluetoothTaskbarIconEnabled>
</component>
<component name="Microsoft-Windows-HelpAndSupport" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<HelpAndSupport>
<Manufacturer>Elektro Studios</Manufacturer>
</HelpAndSupport>
</component>
<component name="Microsoft-Windows-International-Core" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<UserLocale>es-ES</UserLocale>
<UILanguageFallback>es-ES</UILanguageFallback>
<UILanguage>es-ES</UILanguage>
<SystemLocale>es-ES</SystemLocale>
<InputLocale>es-ES</InputLocale>
</component>
<component name="Microsoft-Windows-Security-SPP-UX" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SkipAutoActivation>true</SkipAutoActivation>
</component>
<component name="Microsoft-Windows-ErrorReportingCore" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<DisableWER>1</DisableWER>
</component>
</settings>
<settings pass="oobeSystem">
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<OOBE>
<HideEULAPage>true</HideEULAPage>
<ProtectYourPC>3</ProtectYourPC>
<NetworkLocation>Home</NetworkLocation>
<HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
<HideOnlineAccountScreens>true</HideOnlineAccountScreens>
<HideOEMRegistrationScreen>true</HideOEMRegistrationScreen>
<HideLocalAccountScreen>true</HideLocalAccountScreen>
</OOBE>
<VisualEffects>
<FontSmoothing>On</FontSmoothing>
<SystemDefaultBackgroundColor>0</SystemDefaultBackgroundColor>
</VisualEffects>
<TimeZone>Romance Standard Time</TimeZone>
<DisableAutoDaylightTimeSet>false</DisableAutoDaylightTimeSet>
<BluetoothTaskbarIconEnabled>false</BluetoothTaskbarIconEnabled>
<Themes>
<WindowColor>0</WindowColor>
</Themes>
<WindowsFeatures>
<ShowInternetExplorer>false</ShowInternetExplorer>
<ShowMediaCenter>false</ShowMediaCenter>
<ShowWindowsMediaPlayer>false</ShowWindowsMediaPlayer>
</WindowsFeatures>
<UserAccounts>
<LocalAccounts>
<LocalAccount wcm:action="add">
<Name>Administrator</Name>
<Group>Administrators</Group>
<DisplayName>Administrator</DisplayName>
<Description>Administrator User</Description>
</LocalAccount>
</LocalAccounts>
</UserAccounts>
<AutoLogon>
<Enabled>true</Enabled>
<Username>Administrator</Username>
<LogonCount>1</LogonCount>
</AutoLogon>
</component>
<component name="Microsoft-Windows-International-Core" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<InputLocale>es-ES</InputLocale>
<SystemLocale>es-ES</SystemLocale>
<UILanguage>es-ES</UILanguage>
<UILanguageFallback>es-ES</UILanguageFallback>
<UserLocale>es-ES</UserLocale>
</component>
</settings>
<settings pass="auditSystem">
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Themes>
<WindowColor>0</WindowColor>
</Themes>
<WindowsFeatures>
<ShowWindowsMediaPlayer>false</ShowWindowsMediaPlayer>
<ShowMediaCenter>false</ShowMediaCenter>
<ShowInternetExplorer>false</ShowInternetExplorer>
</WindowsFeatures>
</component>
</settings>
<settings pass="auditUser">
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Themes>
<WindowColor>0</WindowColor>
</Themes>
<WindowsFeatures>
<ShowWindowsMediaPlayer>false</ShowWindowsMediaPlayer>
<ShowInternetExplorer>false</ShowInternetExplorer>
<ShowMediaCenter>false</ShowMediaCenter>
</WindowsFeatures>
</component>
</settings>
<settings pass="offlineServicing">
<component name="Microsoft-Windows-LUA-Settings" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<EnableLUA>false</EnableLUA>
</component>
</settings>
<cpi:offlineImage cpi:source="wim:c:/users/administrador/desktop/win%208%20.1/win/sources/install.wim#Windows 8.1" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
</unattend>
SETX "WinKit" "C:\Program Files (x86)\Windows Kits\8.1\Assessment and Deployment Kit\Deployment Tools"
SETX "WinKit" ""
Citar
1. System is powered on
2. The MBR is located on the system drive.
3. The Boot Sector is located, BOOTMGR is loaded
4. BOOTMGR looks for an active partition on sector 0.
5. BOOTMGR then reads the BCD file
6. BOOTMGR transfers control to WINLOAD.EXE contained in Boot.wim (In the case of a resume operation, WINRESUME.EXE)
7. WINLOAD.EXE initializes memory and loads drivers set to start at boot, and then transfers control to the kernel.
HKLM\SYSTEM\CurrentControlSet\Enum\SCSI\(MANUFACTURER ID)
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\IDE
Citar
Lenguaje:
Especifica aquí el lenguaje que estás utilizando.
Si no estás utilizando ningún lenguaje, especifica el/los lenguaje(s) por los que tengas preferencia para obtener una solución apta a tus necesidades.
Este campo es obligatorio, cualquier tema publicado que no use esta plantilla para especificar el lenguaje será eliminado sin previo aviso.
Problema:
Describe aquí, de forma concisa, pero sin escatimar en detalles, el problema que tienes o la meta que deseas conseguir.
Intenta ser preciso y hacerte entender con los términos y palabras que uses, si no logramos entender tu escenario, tendrás menos posibilidades de que podamos solucionarlo. No malgastes tu tiempo ni tampoco el nuestro.
Este campo es obligatorio, cualquier tema publicado que no use esta plantilla para describir el problema será eliminado sin previo aviso.
Código:
Añade aquí el código fuente, pseudocódigo, urls, o cualquier otra información útil que muestre el progreso de tu investigación. Añade información breve si lo consideras necesario, y porfavor, utiliza las etiquetas 'GeShi' para insertar código.
Ten en cuenta que se valorará mucho más a personas que demuestren haber investigado o intentado desarrollar un código para resolverlo, que las personas que pidan un trabajo laborioso sin mostrar ningún esfuerzo ni haber buscado en Google.
Si no tienes ningún código, déjalo en blanco.
Error:
Especifica aquí toda la información posible acerca del error que te indica el Script (si alguno).
Ten en consideración que cuanto más detallada sea la información que proporciones sobre el error, más posibilidades tendrás de que podamos hayar la causa del problema y así ayudarte a encontrar una solución.
Si no tienes ninguna información, déjalo en blanco.
Otras Observaciones:
Comenta aquí cualquier otra cosa a tener en cuenta que esté relacionada con el problema.
Si no quieres comentar nada, déjalo en blanco.
Cita de: Ejemplo Python
Lenguaje:
Python 3.X
Problema:
Estoy leyendo un tutorial sobre Python pero este simple ejemplo de 'Hola mundo' me da error, no entiendo porque no funciona!
Código:import time
print "Hola"
time.sleep(3)
Error:
Esto es lo único que me indica:Cita de: Python.exeFile "C:\Users\Administrador\Desktop\Nuevo Python Script.PY", line 3
print "Hola"
^
SyntaxError: invalid syntax
Cita de: Ejemplo Batch
Lenguaje:
Batch
Si alguien lo puede hacer en VisualBasicScript no hay problema
Problema:
Hola, antes de nada gracias por ayudarme.
Quisiera obtener una lista de todos los archivos de un directorio y ordenarlos por fecha, y quedarme sólo con los que tengan antiguedad de 2 días.
Código:
Solo consigo listar los archivos, estoy usando ese code:@ECHO OFF
FOR /F "tokens=*" %%F IN ('DIR /A-D /OD /B ".\"') DO (
Echo %%~tF "%%~F"
)
Pause&Exit
Otras Observaciones:
Necesito entregar el código en 3 días para un trabajo... porfavor ayúdenme!
text/win-registry-script