Hi, i'm new in this field. I'm working on a HTA script using VBscripting to manage our renderfarm. When first runs creates 2 .ini files computers.ini and mac.ini wich can be edit after generation. When script starts it displays a column with the IP of the Pc from computers.ini and a button for StartSystems. This way i can select what pc i want to wakeup, 2,3 or all. I need help with finishing my script to do a wake-up-on-lan using wol.exe (commandline app) that is copied in windows root directory or it's in the same folder as the HTA script.
Here is what i've got :
Sub Window_Onload
window.resizeto 660,370
ForReading = 1
ForWriting = 2
strComputersFile = "computers.ini"
strMACFile="Mac.ini"
'*** Check computers available.. if no file, create file
Set objFSO = CreateObject("Scripting.FileSystemObject")
if objFSO.FileExists(strComputersFile) Then
Set objFile = objFSO.OpenTextFile(strComputersFile, ForReading)
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
Set objOption = Document.createElement("OPTION")
objOption.Text = strLine
objOption.Value = strLine
AvailableComputers.Add(objOption)
Loop
objFile.Close
Else
objFSO.CreateTextFile(strComputersFile)
Set objFile = objFSO.OpenTextFile(strComputersFile, ForWriting)
objFile.WriteLine "192.168.0.1"
objFile.WriteLine "192.168.0.2"
objFile.WriteLine "192.168.0.3"
objFile.WriteLine "192.168.0.4"
objFile.WriteLine "192.168.0.5"
objFile.WriteLine "192.168.0.6"
objFile.WriteLine "192.168.0.7"
objFile.WriteLine "192.168.0.8"
objFile.Close
Set objFile = objFSO.OpenTextFile(strComputersFile, ForReading)
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
Set objOption = Document.createElement("OPTION")
objOption.Text = strLine
objOption.Value = strLine
AvailableComputers.Add(objOption)
Loop
objFile.Close
End If
'*** Check MAC available.. if no file, create file
Set objFSO = CreateObject("Scripting.FileSystemObject")
if objFSO.FileExists(strMACFile) Then
Set objFile = objFSO.OpenTextFile(strMACFile, ForReading)
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
Set objOption = Document.createElement("OPTION")
objOption.Text = strLine
objOption.Value = strLine
Loop
objFile.Close
Else
objFSO.CreateTextFile(strMACFile)
Set objFile = objFSO.OpenTextFile(strMACFile, ForWriting)
objFile.WriteLine "MAC1"
objFile.WriteLine "MAC2"
objFile.WriteLine "MAC3"
objFile.WriteLine "MAC4"
objFile.WriteLine "MAC5"
objFile.WriteLine "MAC6"
objFile.WriteLine "MAC7"
objFile.WriteLine "MAC8"
objFile.Close
Set objFile = objFSO.OpenTextFile(strMACFile, ForReading)
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
Set objOption = Document.createElement("OPTION")
objOption.Text = strLine
objOption.Value = strLine
Loop
objFile.Close
End If
End Sub
Sub StartSystems
For i = 0 to (AvailableComputers.Options.Length - 1)
If (AvailableComputers.Options(i).Selected) Then
strComputer = AvailableComputers.Options(i).Value
HERE IS THE PROBLEM, I DON'T KNOW HOW TO FINISH THIS. FOR THE SELECTED COMPUTERS I MUST ASSOCIATE THE MAC FROM THE SECOND INI(MAC.INI) AND CREATE THE SCRIPT THAT RUNS "WOL MAC"
strHost = "."
Set objWMIService = GetObject _
("winmgmts:\\" & strHost & "\root\cimv2:Win32_Process")
error = objWMIService.Create("wol" & strMAC)
End If
Next
End Sub
Hope you understand what my problem is.
Here is what i've got :
Sub Window_Onload
window.resizeto 660,370
ForReading = 1
ForWriting = 2
strComputersFile = "computers.ini"
strMACFile="Mac.ini"
'*** Check computers available.. if no file, create file
Set objFSO = CreateObject("Scripting.FileSystemObject")
if objFSO.FileExists(strComputersFile) Then
Set objFile = objFSO.OpenTextFile(strComputersFile, ForReading)
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
Set objOption = Document.createElement("OPTION")
objOption.Text = strLine
objOption.Value = strLine
AvailableComputers.Add(objOption)
Loop
objFile.Close
Else
objFSO.CreateTextFile(strComputersFile)
Set objFile = objFSO.OpenTextFile(strComputersFile, ForWriting)
objFile.WriteLine "192.168.0.1"
objFile.WriteLine "192.168.0.2"
objFile.WriteLine "192.168.0.3"
objFile.WriteLine "192.168.0.4"
objFile.WriteLine "192.168.0.5"
objFile.WriteLine "192.168.0.6"
objFile.WriteLine "192.168.0.7"
objFile.WriteLine "192.168.0.8"
objFile.Close
Set objFile = objFSO.OpenTextFile(strComputersFile, ForReading)
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
Set objOption = Document.createElement("OPTION")
objOption.Text = strLine
objOption.Value = strLine
AvailableComputers.Add(objOption)
Loop
objFile.Close
End If
'*** Check MAC available.. if no file, create file
Set objFSO = CreateObject("Scripting.FileSystemObject")
if objFSO.FileExists(strMACFile) Then
Set objFile = objFSO.OpenTextFile(strMACFile, ForReading)
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
Set objOption = Document.createElement("OPTION")
objOption.Text = strLine
objOption.Value = strLine
Loop
objFile.Close
Else
objFSO.CreateTextFile(strMACFile)
Set objFile = objFSO.OpenTextFile(strMACFile, ForWriting)
objFile.WriteLine "MAC1"
objFile.WriteLine "MAC2"
objFile.WriteLine "MAC3"
objFile.WriteLine "MAC4"
objFile.WriteLine "MAC5"
objFile.WriteLine "MAC6"
objFile.WriteLine "MAC7"
objFile.WriteLine "MAC8"
objFile.Close
Set objFile = objFSO.OpenTextFile(strMACFile, ForReading)
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
Set objOption = Document.createElement("OPTION")
objOption.Text = strLine
objOption.Value = strLine
Loop
objFile.Close
End If
End Sub
Sub StartSystems
For i = 0 to (AvailableComputers.Options.Length - 1)
If (AvailableComputers.Options(i).Selected) Then
strComputer = AvailableComputers.Options(i).Value
HERE IS THE PROBLEM, I DON'T KNOW HOW TO FINISH THIS. FOR THE SELECTED COMPUTERS I MUST ASSOCIATE THE MAC FROM THE SECOND INI(MAC.INI) AND CREATE THE SCRIPT THAT RUNS "WOL MAC"
strHost = "."
Set objWMIService = GetObject _
("winmgmts:\\" & strHost & "\root\cimv2:Win32_Process")
error = objWMIService.Create("wol" & strMAC)
End If
Next
End Sub
Hope you understand what my problem is.