How can I detect what kind of Ethernet connection my NIC made? That is, my NIC is a Gigabit Ethernet device, but since it's auto-sensing, it might be connected at Gigabit speed or Fast Ethernet speed.
How do I find out what speed it is being connected at?
I tried using WMI's Win32_NetworkAdapter, CIM_NetworkAdapter, even wmic NET get Name,Speed, but all of them return blank for Speed.
I'm using Windows XP Pro SP3, by the way. But I'd like a solution that will also work for Windows Server 2003 (Standard & Enterprise), Windows Server 2008, and Windows Server 2008 R2.
A mysterious person codenamed 'mystifeid' solved this puzzle on this site, third post down:
http://social.msdn.microsoft.com/Forums/uk-UA/scripting/thread/e3936dff-7395-4a6a-ab35-aa1aab0bcd71
Here's their lovely code:
Dim strQuery, strQuery2, objLocator, objWMI, objItem, objItem2, colItems, colItems2, resultString, nicName
strQuery = "SELECT * FROM Win32_PerfFormattedData_Tcpip_NetworkInterface"
strQuery2 = "SELECT * FROM Win32_NetworkAdapter"
Set objLocator = CreateObject( "WbemScripting.SWbemLocator" )
Set objWMI = objLocator.ConnectServer( ".", "root\CIMV2" )
objWMI.Security_.ImpersonationLevel = 3
Set colItems2 = objWMI.ExecQuery( strQuery2, "WQL", 0 )
Set colItems = objWMI.ExecQuery( strQuery, "WQL", 0 )
resultString = ""
For Each objItem2 In colItems2
If objItem2.NetConnectionStatus = 2 Then
nicName = Mid(objItem2.Name, 1, 5)
resultString = resultString & "Adapter Name : " & objItem2.Name & VbCrLf
resultString = resultString & "MAC Address : " & objItem2.MACAddress & VbCrLf
For Each objItem In colItems
If Mid(objItem.Name, 1, 5) = nicName Then
resultString = resultString & "CurrentBandwidth : " & objItem.CurrentBandwidth & VbCrLf
End If
Next
End If
Next
Set objLocator = Nothing
Set objWMI = Nothing
Set colItems = Nothing
Set colItems2 = Nothing
WScript.Echo resultString
PS- I'll vet it against Win7 and Win2008 soon and let all know.
Related
I am trying to bind data to my page from database the code is given below
Dim oCon, pages, Rec, DisplayNum, i, page, SQL, ipage, z, MaxRows
Set QGetList = Server.CreateObject ("ADODB.Recordset")
'QGetList.PageSize = MaxRows
'QGetList.CursorLocation = adUseClient
'Set QGetProgramItem = Server.CreateObject("ADODB.Recordset")
SQL = " SELECT ModelRow, SeriesRow, ModelCode, Item.* FROM tblSPCMaster_Item Item " &_
" LEFT OUTER JOIN viewModelSeries VM on VM.vch_ModelName = Item.vModelName AND VM.modelcode = Item.vModelCode " &_
" WHERE iSPCMasterID = '" & Request.querystring("PID") & "' ORDER BY ModelRow, SeriesRow, Item.iSeq"
QGetList.Open SQL, dpconn, 1
ipage = QGetList.PageCount
if QGetList.EOF OR QGetList.BOF Then
x = 1
else
if page = 0 or page > ipage Then
QGetList.AbsolutePage = ipage
else
QGetList.AbsolutePage = page
end if
end if
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "attachment; filename=Stock_Inventory_Management_Export_" & Year(now) & Month(now) & day(now) & hour(now) & minute(now) & ".xls"
i am getting error:
ADODB.Recordset error '800a0bb9'
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
what i am missing i am not getting please help me
This line:
QGetList.Open SQL, dpconn, 1
For the first argument, it expects an Command object. You gave it a string.
Fix your SQL Injection vulnerability.
I would like to renew an asp webapp that works with MS access databases into a new webapp using PHP and Mysql. The webapp relies on one masterquery that pulls data from an sql server used by HP Service Center and then puts the data in a table INCIDENT_DATA.
A former colleague created the asp script and I am by far a seasoned developer.
The script uses
cmd1.CommandText = "[IncidentMap].[uSp_proj_IM_IncidentList_SelectL]"
and I have no idea what it means exactly or where to put it in PHP.
the complete script:
<%
ReDim tmp_tab(1000)
Set cn1 = Server.CreateObject("ADODB.Connection")
Set cmd1 = Server.CreateObject("ADODB.Command")
Set rs1 = Server.CreateObject("ADODB.Recordset")
ds = "Provider=SQLOLEDB;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=PRG_PRD;Data Source=PRG_PRD.sql.somedomain\SQL1;"
cn1.Open ds
Set cmd1.ActiveConnection = cn1
cmd1.CommandText = "[IncidentMap].[uSp_proj_IM_IncidentList_SelectL]"
Set rs1 = cmd1.execute
If Not rs1.EOF Then
DataFound = true
Data = rs1.getrows
Else
DataFound = false
End If
If DataFound = true Then
nb_max_interv=Ubound(Data,2)
ReDim tableau_donnees(Ubound(Data,2))
ligne=0
col=0
For ctr = 1 To Ubound(Data,2)
For nb_col=0 to 27
if Data(nb_col,ctr)<>"" then
'tmp_tab(nb_col)=replace(Data(nb_col,ctr),"'"," ")
tempo=Data(nb_col,ctr)
tempo2=replace(tempo,"'"," ")
tempo3=replace(tempo2,chr(34)," ")
tempo4=replace(tempo3,chr(174)," ")
tempo5=replace(tempo4,chr(132)," ")
tempo6=replace(tempo5,chr(147)," ")
tempo7=replace(tempo6,chr(148)," ")
tempo8=replace(tempo7,chr(171)," ")
tempo9=replace(tempo8,chr(187)," ")
tempo10=replace(tempo9,chr(39)," ")
tempo11=replace(tempo10,chr(145)," ")
tempo12=replace(tempo11,chr(146)," ")
tmp_tab(nb_col)=tempo12
else
tmp_tab(nb_col)=Data(nb_col,ctr)
end if
Next
If tmp_tab(26)<>"" then
tps_restant=datediff("n",now(),tmp_tab(26))
else
tps_restant=0
end if
Tps_depuis_LastUpdate=datediff("n",tmp_tab(25),now())
SQL2="INSERT INTO data_incident (IncidentNumber,Owner,TicketStatus,AlertLevel,IncidentTitle,Description,LastName,FirstName,UserContactInformation,PhoneContactInformation,MobileContactInformation,EmailContactInformation,X1,CP,Location,Address,X2,ConfigurationItem,Hostname,AssignmentGroup,AssigneeName,Urgency,Impact,Priority,OpenedAt,LastUpdatedAt,Expiration,LastUpdatedBy,Temps_Restant,Temps_depuis_LastUpdate) VALUES('"&tmp_tab(0)&"','"&tmp_tab(1)&"','"&tmp_tab(2)&"','"&tmp_tab(3)&"','"&tmp_tab(4)&"','"&tmp_tab(5)&"','"&tmp_tab(6)&"','"&tmp_tab(7)&"','"&tmp_tab(8)&"','"&tmp_tab(9)&"','"&tmp_tab(10)&"','"&tmp_tab(11)&"','"&tmp_tab(12)&"','"&tmp_tab(13)&"','"&tmp_tab(14)&"','"&tmp_tab(15)&"','"&tmp_tab(16)&"','"&tmp_tab(17)&"','"&tmp_tab(18)&"','"&tmp_tab(19)&"','"&tmp_tab(20)&"','"&tmp_tab(21)&"','"&tmp_tab(22)&"','"&tmp_tab(23)&"','"&tmp_tab(24)&"','"&tmp_tab(25)&"','"&tmp_tab(26)&"','"&tmp_tab(27)&"','"&tps_restant&"','"&Tps_depuis_LastUpdate&"')"
Set cat2 = Server.CreateObject("ADODB.Recordset")
cat2.Open sql2, conn, 3, 3
Next
End If
'conn.close
%>
Does anyone have an idea how I could construct a PDO connectionstring and then update a mysql database with the pulled data?
This title of the question may seem to be previously asked and answered but its different scenario for me. I use this script to stop sql injection in my ASP site. As per my knowledge or injecting script i have tried everything . Is it still possible to break through this code or do you feel this is fine .
Here is the script
<%
Function IsInject(strCheck, boolForm)
IsInject = False
If Not boolForm And Len(strCheck) > 50 Then IsInject = True
' Dim sCmdList, arrCmds, i
If boolForm Then
sCmdList = "declare,varchar,convert,delete,create,is_srvrolemember,ar(,cast("
Else
sCmdList = "update,union,select,drop,declare,varchar,convert,delete,create,is_srvrolemember,ar(,cast(,char("
End If
arrCmds = Split(sCmdList, ",")
For i = 0 To UBound(arrCmds)
If Instr(UCase(CStr(strCheck)), UCase(arrCmds(i))) > 0 Then
IsInject = True
Exit For
End If
Next
Erase arrCmds
End Function
Function CleanInject(strClean, boolInt)
If boolInt Then CleanInject = CInt(strClean) Else CleanInject = Replace(strClean, "'", "''")
End Function
'-----------------------------------------------------------
'redirect user if specific IP
'Dim ipaddress, bFBIRedirect, sInjectType
bFBIRedirect = True
ipaddress = Request.ServerVariables("REMOTE_ADDR")
Select Case ipaddress
Case "90.120.206.10"
Case Else
bFBIRedirect = False
End Select
If bFBIRedirect Then Response.Redirect "http://www.fbi.gov"
'-----------------------------------------------------------
'Dim bIsInject, sHackString
bIsInject = False
If Not bInject Then
' Dim qsItm
For Each qsItm In Request.QueryString
If IsInject(Request.QueryString(qsItm), False) Then
bIsInject = True
sHackString = qsItm & "=" & Request.QueryString(qsItm)
sHackType = "QueryString"
sInjectType = "qs-" & Request.QueryString(qsItm)
Exit For
End If
Next
End If
If Not bInject Then
' Dim frmItm
' For Each frmItm In Request.Form
' If IsInject(Request.Form(frmItm), True) Then
' bIsInject = True
' sHackString = Request.Form(frmItm)
' sHackString = frmItm & "=" & Request.Form(frmItm)
' sHackType = "Form"
' Exit For
' End If
' Next
End If
If bIsInject Then
Session("hacktype") = sHackType
Session("hackstr") = sHackString
Session("thepagefrom") = Request.ServerVariables("PATH_INFO")
Session("theip") = Request.ServerVariables("REMOTE_ADDR")
' Dim arrWhereAt, iWhereAt, sRedirect
arrWhereAt = Split(Request.ServerVariables("PATH_INFO"), "/")
iWhereAt = UBound(arrWhereAt)
sRedirect = "unknownerror.asp?ip=" & Request.ServerVariables("REMOTE_ADDR") & "&err=" & sInjectType & "&pg=" & Request.ServerVariables("PATH_INFO")
If iWhereAt = 1 Then sRedirect = "../" & sRedirect
If iWhereAt = 2 Then sRedirect = "../../" & sRedirect
If iWhereAt = 3 Then sRedirect = "../../../" & sRedirect
Response.Redirect sRedirect
End If
%>
Using blacklists to remove commands is not really a good idea. You have to make sure you cover all possible commands, and still someone might sneak something past. This would also probably fail if you get data from a user that is not an attack, but still contains an attack string. Example "Back in the days of the Soviet Union".
As Nikolai suggests, see if you can find some type of prepared statements to use. Or find a really good library to properly escape data for you.
rather doing that I think I would use ADO Parameter object when creating SQL queries, the second best thing is to do type conversion of the inputfields for the dynamic SQL queries, such as converting strings to SQL strings (replace any ' with two ''), making sure number is a number etc.
How can I save and retrieve audio and video files in and from a SQL Server database?
The naive approach is to use a BLOB column and read the entire content into a byte[], then write the byte[] back to the client. The problem is that it consumes huge amounts of memory in your ASP.Net process.
A much better approach is to use streaming semantics, see these two articles:
Download and Upload images from SQL Server via ASP.Net MVC
FILESTREAM MVC: Download and Upload images from SQL Server
The articles refer to images, but you can use the code as-is to store any other form of media, including audio and video. Although the code is for ASP.Net MVC, the concepts use to stream large files into and from SQL Server can be used just as well from ASP.Net forms.
I'm not making a case that you should or should not use SQL Server as the storage for media. That is an entirely different discussion.
Refer to How to Store audio in Sql and retrieve for play, you come to know how to store the audio files in the database. Follow the same way for videos also.
Public Sub InsertAudioDataInTable(TableName, TableMapingName, TextName,_
LoopStart, LoopEnd, Panel, PathOnDisk)
Dim SndSourceStream As Stream = New FileStream(PathOnDisk, FileMode.Open,
FileAccess.Read)
Dim BinarySndReader As New BinaryReader(SndSourceStream)
Dim bytes As Byte() = BinarySndReader.ReadBytes(SndSourceStream.Length)
strImage = "#Aud" ' Aud mean a feild Audio in database
'''''''''''''''''''''''''''''''''''''''''''''''' For SQL String
Dim b = 0
Dim dataContaner(LoopEnd + 2 - LoopStart) As String
For a = LoopStart To LoopEnd
dataContaner(b) = Panel.Controls(TextName & a).Text
b = b + 1
Next
''''''''''''''
Dim myCmd As New SqlCommand
myCmd.Connection = Con
''''''''''
Dim T As String
' T.Text = null
Dim aaa = "INSERT INTO " & TableName
Dim bbb = ""
For i = LoopStart To LoopEnd
bbb = bbb + "F" & i & ","
Next
T = aaa & " (" + bbb & "Aud"
' T = T.Remove(T.Length - 1)
T = T & ")VALUES ("
Dim ccc = ""
b = 0
For a = LoopStart To LoopEnd
ccc = ccc & "'" & dataContaner(b) & "',"
b = b + 1
Next
T = T + ccc
myCmd.CommandText = T + strImage & ")"
myCmd.Parameters.Add(strImage, SqlDbType.Binary).Value = bytes
myCmd.ExecuteNonQuery()
''''''''
End Sub
Private Sub btSclass_Click(sender As Object, e As EventArgs) Handles btSclass.Click
If btSclass.Text = "Start Class" Then
If A7.Text <> "" Then
GlobalVariableDefault.startTime = DateTime.Now
A2.Text = GlobalVariableDefault.startTime.ToString("hh\:mm\:ss")
GlobalVariableDefault.StID = A7.Text
Me.Hide()
FTodayLesson.Show()
A2.Text = L.Text
btSclass.Text = "End Class"
btSclass.BackColor = Color.Red
If recording = False Then
mciSendString("open new Type waveaudio Alias recsound", "", 0, 0)
mciSendString("record recsound", "", 0, 0)
recording = True
End If
Else
MyMessage("Select a student name from list")
End If
ElseIf btSclass.Text = "End Class" Then
mciSendString("save recsound " & Filez, "", 0, 0)
mciSendString("close recsound ", "", 0, 0)
recording = False
FunConnection(DatabaseName_Audio)
InsertAudioDataInTable("RecAudio", "InsertAdio", "A", 1, 8, PShortInfo, "D:\aa\Test.wav")
btSclass.BackColor = Color.WhiteSmoke
btSclass.Text = "Start Class"
MyMessage("Data Save")
FunConnection(DatabaseName_QurqnServer)
End If
End Sub
'''''data base used in above code
Is there a way to quickly list which sites are on which IP address in IIS 7?
If I remember correctly you could sort a view of domains by IP in IIS 6 which was a big help to me in seeing which IPs I had available.
Take a look at APPCMD .
For example, to list all sites on the machine, use this command-line:
%systemroot%\system32\inetsrv\APPCMD list sites
You can try this script:
MachineName = "localhost"
IIsObjectPath = "IIS://" & MachineName & "/w3svc"
WScript.Echo "Checking : " & IISObjectPath
Set IIsObject = GetObject(IIsObjectPath)
for each obj in IISObject
if (Obj.Class = "IIsWebServer") then
BindingPath = IIsObjectPath & "/" & Obj.Name
Set IIsObjectIP = GetObject(BindingPath)
wScript.Echo BindingPath & " - " & IISObjectIP.ServerComment
ValueList = IISObjectIP.Get("ServerBindings")
ValueString = ""
For ValueIndex = 0 To UBound(ValueList)
value = ValueList(ValueIndex)
Values = split(value, ":")
IP = values(0)
if (IP = "") then
IP = "(All Unassigned)"
end if
TCP = values(1)
if (TCP = "") then
TCP = "80"
end if
HostHeader = values(2)
if (HostHeader <> "") then
wScript.Echo " IP = " & IP & " TCP/IP Port = " & TCP & ", HostHeader = " & HostHeader
else
wScript.Echo " IP = " & IP & " TCP/IP Port = " & TCP
end if
Next
wScript.Echo ""
set IISObjectIP = Nothing
end if
next
set IISObject = Nothing
(source www.iisfaq.com)