Hello,
I am making a *.vbs file and I need help putting two codes in.
The first code is to make a .txt file named "Hello World", with the text in the .txt file "Time ... (your time)-Test123"
Code:
myfilename = "\Hello World.txt"
MakeHelloWorldFile myfilename
Sub MakeHelloWorldFile (FileName)
'Create a new file in C: drive or overwrite existing file
Set FSO = CreateObject("Scripting.FileSystemObject")
If FSO.FileExists(FileName) Then
Answer = MsgBox ("File " & FileName & " exists ... OK to overwrite?", vbOKCancel)
'If button selected is not OK, then quit now
'vbOK is a language constant
If Answer <> vbOK Then Exit Sub
Else
'Confirm OK to create
Answer = MsgBox ("File " & FileName & " ... OK to create?", vbOKCancel)
If Answer <> vbOK Then Exit Sub
End If
'Create new file (or replace an existing file)
Set FileObject = FSO.CreateTextFile (FileName)
FileObject.WriteLine "Time ... " & Now()
FileObject.WriteLine "Test123"
FileObject.Close()
MsgBox "File " & FileName & " ... updated."
End Sub
And the 2nd file I want to combine with this is to desplay the IP address of the machine. I would like to make it desplay the IP address in the .txt file, not as a msg box.
Code:
strcomputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
for each objitem in colitems
strIPAddress = Join(objitem.IPAddress, ",")
IP = stripaddress
wscript.echo ip
next