ironhide1975
Programmer
Is there any easy way to grab a computer name with ASP Classic or Client Side VBScript?
Any help is appreciated.
Any help is appreciated.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
<script language="vbscript">
set wshnetwork=createobject("wscript.network")
scomputername=wshnetwork.computername
set wshnetwork=nothing
</script>
<%
Dim sIP
Dim oShell, oExec, sCommand, sOutput
sIP = Request.ServerVariables("REMOTE_ADDR")
''watch for line wrap - begin
sCommand = "%comspec% /c [at] echo off & for /f ""tokens=2"" %q in ('ping -n1 -a " & sIP & "^|find /i ""pinging""') do echo %q"
''watch for line wrap - end
Set oShell = CreateObject("WScript.Shell")
Set oExec = oShell.Exec(sCommand)
sOutput = oExec.StdOut.ReadAll
Set oExec = Nothing
Set oShell = Nothing
scomputername = sOutput
%>
REM script to return all ip's used in a subnet
REM Just change the base IP address after from 255.255.255.%2 to whatever range you want (keep the %2 though).
@echo off
if %1!==! goto start
if %1==h goto hundreds
if %1==t goto tens
if %1==u goto units
:start
echo Starting ping
echo Starting ping > pinglist.txt
for %%h in (0,1,2) do call %0 h %2%%h
goto end
:hundreds
for %%t in (0,1,2,3,4,5) do call %0 t %2%%t
goto end
:tens
for %%u in (0,1,2,3,4,5,6,7,8,9) do call %0 u %2%%u
goto end
:units
ping -a -n 1 192.168.5.%2|find "Pinging" >> pinglist.txt
IF %2!==259! goto repeat
:end
:: gets only 2nd element of pinglist
:repeat
for /f "eol=; tokens=2 delims= " %%i in (pinglist.txt) do @echo %%i>>list.txt
if "%i%"=="" goto repeat1
goto repeat
:ender
:: strips everything after 1st instance of '.' or ' '
:repeat1
for /f "eol=; tokens=1 delims=. " %%i in (list.txt) do @echo %%i>>lista.txt
if "%i%"=="" goto repeat2
goto repeat1
:ender1
:: gets rid of 192 and ping
:repeat2
awk "{if($1!=192) print $1}" lista.txt >>listb.txt
set shell = WScript.CreateObject( "WScript.Shell" )
computername = shell.ExpandEnvironmentStrings("%COMPUTERNAME%")
wscript.echo computername
SET objShell=CreateObject("Wscript.Shell")
DIM objExec, strResult
SET objExec = objShell.Exec("hostname")
strResult = objExec.StdOut.ReadAll
WScript.Echo strResult
Set wmiColl = GetObject("WinMgmts:root/cimv2")_
.ExecQuery("Select * FROM Win32_ComputerSystem")
For Each wmiObj in wmiColl
WScript.Echo wmiObj.Name
Next