Luis Diaz
asked on
VB Script: create txt file with DateStamp and IP Adress
VBS script :
Hello experts,
I am looking for a vbscript procedure in order to
1-Create a file with the following name Creatation_date_IP_adress of the machine
The following format should be used:DDMMMYYYY_HHMMSS__IP_ adress
IP adress refers to the machinemachine in which it is launched.
Here is the reference function
“[DDMMYYYY_HHMMSS]
3-The procedure should should contains the following param:
Sub(outputFolder) outputFolder refers to the folder in which should be generated the file.
If you have question don't hesitate to contact me.
Hello experts,
I am looking for a vbscript procedure in order to
1-Create a file with the following name Creatation_date_IP_adress of the machine
The following format should be used:DDMMMYYYY_HHMMSS__IP_
IP adress refers to the machinemachine in which it is launched.
Here is the reference function
' Build string of current date time (DDMMYYYY_HHMMSS)
Function TimeStamp(dtmDateTime)
TimeStamp = Year(dtmDateTime) & Right("0" & Month(dtmDateTime), 2) & Right("0" & Day(dtmDateTime), 2) & "_" & Right("0" & Hour(dtmDateTime), 2) & Right("0" & Minute(dtmDateTime), 2) & Right("0" & Second(dtmDateTime), 2)
End Function
'Retrieve IP adress
strQuery = "SELECT * FROM Win32_NetworkAdapterConfiguration WHERE MACAddress > ''"
Set objWMIService = GetObject( "winmgmts://./root/CIMV2" )
Set colItems = objWMIService.ExecQuery( strQuery, "WQL", 48 )
For Each objItem In colItems
If IsArray( objItem.IPAddress ) Then
If UBound( objItem.IPAddress ) = 0 Then
strIP = "IP Address: " & objItem.IPAddress(0)
Else
strIP = "IP Addresses: " & Join( objItem.IPAddress, "," )
End If
End If
Next
WScript.Echo strIP
2-File should contains the following“[DDMMYYYY_HHMMSS]
3-The procedure should should contains the following param:
Sub(outputFolder) outputFolder refers to the folder in which should be generated the file.
If you have question don't hesitate to contact me.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Set objWMIService = GetObject( "winmgmts:\\.\root\cimv2" )
Set colItems = objWMIService.ExecQuery( "Select * from Win32_ComputerSystem" )
For Each objItem in colItems
strComputerName = objItem.Name
WScript.Echo "Computer Name: " & strComputerName
Next
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It works! Thank you very much for your help!
Welcome.
~bp
~bp
ASKER