-
Notifications
You must be signed in to change notification settings - Fork 126
Expand file tree
/
Copy pathUnmountWIM.vbs
More file actions
81 lines (58 loc) · 2.24 KB
/
UnmountWIM.vbs
File metadata and controls
81 lines (58 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
'*******************************************************************************
' Program: UnmountWIM.vbs
' Author: Mick Pletcher
' Date: 22 February 2010
' Modified:
'
' Description: This script will unmount the current mounted WIM file.
' 1) Define Relative Path
' 2) Select the WIM file
' 3) Mount the WIM file
' 4) Cleanup Global Variables
'*******************************************************************************
Option Explicit
REM Define Global Variables
DIM RelativePath : Set RelativePath = Nothing
DefineRelativePath()
UnmountWIM()
ImageUnmounted()
GlobalVariableCleanup()
'*******************************************************************************
Sub DefineRelativePath()
REM Get File Name with full relative path
RelativePath = WScript.ScriptFullName
REM Remove file name, leaving relative path only
RelativePath = Left(RelativePath, InStrRev(RelativePath, "\"))
End Sub
'*******************************************************************************
Sub UnmountWIM()
REM Define Local Objects
DIM oShell : SET oShell = CreateObject("Wscript.Shell")
REM Define Local Variables
' DIM Unmount : Unmount = Chr(34) & "C:\Program Files\Windows AIK\Tools\x86\imagex.exe" & Chr(34) & " /unmount mount /commit"
DIM MountDIR : MountDIR = Chr(32) & "/MountDir:" & RelativePath & "Mount"
DIM Parameters : Parameters = Chr(32) & "/commit"
DIM Unmount : Unmount = "DISM /Unmount-WIM" & MountDIR & Parameters
oShell.Run Unmount, 1, True
REM Cleanup Local Variables
Set MountDIR = Nothing
Set oShell = Nothing
Set Parameters = Nothing
Set Unmount = Nothing
End Sub
'*******************************************************************************
Sub ImageUnmounted()
REM Define Local Objects
DIM FSO : Set FSO = CreateObject("Scripting.FileSystemObject")
If NOT FSO.FolderExists(RelativePath & "Mount\Windows") Then
MsgBox("Image is unmounted")
Else
MsgBox("Image failed to unmount")
End If
REM Cleanup Local Objects
Set FSO = Nothing
End Sub
'*******************************************************************************
Sub GlobalVariableCleanup()
Set RelativePath = Nothing
End Sub