Windows Scripting BLOG

Due to limited time working on this project this place is not intended to people who are new to scripting but much more for people who are already familiar with the VBS/WMI syntax.

Donnerstag, 17. Mai 2007

WISE: Automated installation script enumerating partitions and setting permissions

On error resume next
strComputer = "."
Set fso = CreateObject("Scripting.FileSystemObject")
Set WshShell = CreateObject("WScript.Shell")
Set wmiServices = GetObject _ ("winmgmts:{impersonationLevel=Impersonate}!//" & strComputer)
Set wmiDiskPartitions = wmiServices.ExecQuery _ ("SELECT * From Win32_DiskDrive WHERE Index = '0'")
for each test in wmidiskpartitions
str1 = test.Partitions

if str1=1 thenstrEscapedDeviceID1 = "Disk #0, Partition #0"
Set wmiDiskPartitions1 = wmiServices.ExecQuery _("ASSOCIATORS OF {Win32_DiskPartition.DeviceID=""" & _ strEscapedDeviceID1 & """} WHERE AssocClass = " & _ "Win32_LogicalDiskToPartition")
for each test1 in wmidiskpartitions1DriveSpec = Test1.Name
next
WSHShell.Run("mtplayerinstall-standalone.exe /S")fso.CopyFolder "MasteryNet","" & DriveSpec & "\MasteryNet"
WshShell.Run("Cacls " & Drivespec & "\MasteryNet /G ""Authenticated Users"":F /T /E")
end if
if str1>1
then
int2 = 1int3 = str1 - int2strEscapedDeviceID2 = "Disk #0, Partition #" & int3
Set wmiDiskPartitions2 = wmiServices.ExecQuery _("ASSOCIATORS OF {Win32_DiskPartition.DeviceID=""" & _ strEscapedDeviceID2 & """} WHERE AssocClass = " & _ "Win32_LogicalDiskToPartition")
for each test2 in wmidiskpartitions2
driveSpec = Test2.Name
WSHShell.Run("mtplayerinstall-standalone.exe /S")
fso.CopyFolder "MasteryNet","" & DriveSpec & "\MasteryNet"WshShell.Run("Cacls " & drivespec & "\MasteryNet /G ""Authenticated Users"":F /T /E")

next
end if


next
'created by Julian Ruf

Keine Kommentare: