Hai All,
Here I am mentioning solutions for Two problems. 1.To get the i.p. address of a system with VB Script and 2.Writing a string into a File,
In the following example I will Show How to get the IP and also to write a URL string with the IP into A File
dim NIC1, Nic, StrIP, fso, MyFile
Set NIC1 = GetObject("winmgmts:").InstancesOf("Win32_NetworkAdapterConfiguration")
For Each Nic in NIC1
if Nic.IPEnabled then
StrIP = Nic.IPAddress(i)
end if
next
Set objShell = CreateObject("Shell.Application")
Set oShell = CreateObject ("Wscript.Shell")
strPath = Wscript.ScriptFullName
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(strPath)
strFolder = objFSO.GetParentFolderName(objFile)
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.CreateTextFile(“D:\link.txt", True)
MyFile.WriteLine("http://" & StrIP & "/testSite/Index.aspx")
MyFile.Close
wscript.quit
Save the above File as ‘.vbs’ [VB Script] and run it to get the output.
Just play around with the Codes,It contains the Solution to solve both the problems I mentioned above.
@echo off
call :get_ip_address
cd c:\
cd /d %~dp0
echo http://%ip_address%/testSite/Index.aspx > ipAdress.txt
start http://%ip_address%/testSite/Index.aspx
goto :eof
REM
REM get the ip address
REM
:get_ip_address
FOR /f "tokens=1 delims=:" %%d IN ('ping %computername% -4 -n 1 ^| find /i "reply"') do (FOR /F "tokens=3 delims= " %%g IN ("%%d") DO set ip_address=%%g)
goto :eof
The Above Code will also Work As the Same, But by Using the Batch Commands, So you have to save it as ‘.BAT’ for Running it.
Thank you
Here I am mentioning solutions for Two problems. 1.To get the i.p. address of a system with VB Script and 2.Writing a string into a File,
In the following example I will Show How to get the IP and also to write a URL string with the IP into A File
dim NIC1, Nic, StrIP, fso, MyFile
Set NIC1 = GetObject("winmgmts:").InstancesOf("Win32_NetworkAdapterConfiguration")
For Each Nic in NIC1
if Nic.IPEnabled then
StrIP = Nic.IPAddress(i)
end if
next
Set objShell = CreateObject("Shell.Application")
Set oShell = CreateObject ("Wscript.Shell")
strPath = Wscript.ScriptFullName
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile(strPath)
strFolder = objFSO.GetParentFolderName(objFile)
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.CreateTextFile(“D:\link.txt", True)
MyFile.WriteLine("http://" & StrIP & "/testSite/Index.aspx")
MyFile.Close
wscript.quit
Save the above File as ‘.vbs’ [VB Script] and run it to get the output.
Just play around with the Codes,It contains the Solution to solve both the problems I mentioned above.
@echo off
call :get_ip_address
cd c:\
cd /d %~dp0
echo http://%ip_address%/testSite/Index.aspx > ipAdress.txt
start http://%ip_address%/testSite/Index.aspx
goto :eof
REM
REM get the ip address
REM
:get_ip_address
FOR /f "tokens=1 delims=:" %%d IN ('ping %computername% -4 -n 1 ^| find /i "reply"') do (FOR /F "tokens=3 delims= " %%g IN ("%%d") DO set ip_address=%%g)
goto :eof
The Above Code will also Work As the Same, But by Using the Batch Commands, So you have to save it as ‘.BAT’ for Running it.
Thank you
0 comments:
Post a Comment