or Each objItem In colItems
sn = objItem.SerialNumber
Next


cn = WshShell.expandenvironmentstrings("%COMPUTERNAME%")
un = WshShell.expandenvironmentstrings("%USERNAME%")
Dim objDict : Set objDict = CreateObject("Scripting.Dictionary")
objDict.Add "administrator2", ""
objDict.Add "administrator3", ""
objDict.Add "administrator4", ""
If objDict.Exists(un) Then
    'do something
Else
   'msgbox Serial_Number
Dim sServer,sLogin,sPwd,oCn,oRs,Wl,sql 
 
sServer = "<SQLSERVER>"
sLogin = "<USERNAME>"
sPwd = "<PASSWORD>"

Set oCn = CreateObject( "ADODB.Connection" )
Set oRs = CreateObject( "ADODB.Recordset"  )

oCn.ConnectionString = "PROVIDER=SQLOLEDB" & _
                       ";SERVER=" & sServer   & _
                       ";UID="    & sLogin  & _
                       ";PWD="    & sPwd    & _
                       ";DATABASE=bsc"
oCn.open
sql= "Select * from asp1reg where Host_Name = '"&cn&"'"
oRs.Open sql, oCn
If not oRs.EOF then
    strQuery = "update asp1reg set 

User_Name='"&un&"',Serial_Number='"&sn&"',Time_Stamp=getdate() where host_name='"&cn& "'" 
   oCn.Execute(strQuery) 
   'Get the column data for each column in the row.
   'strQuery = "update Batt_Info set 

User_Name='"&un&"',Serial_Number='"&sn&"',Time_Stamp=getdate(), Batt_Tag= '"&sn& "' where 

host_name='"&cn& "'" 
  else
   strQuery = "INSERT INTO asp1reg (Host_Name,User_Name,Serial_Number,Time_Stamp) VALUES 

('"&cn&"','" &un& "','" &sn&"',getdate())" 
   oCn.Execute(strQuery) 
   'msgbox "Attention Please- This netbook, computer name:"&cn&", SN:" & sn & ", will be 

registered with Username-" & un & ". If you are not the owner of this netbook, 

please contact ICT department ASAP."
 
end if


oCn.Close
ors.close

end if




 

About Lei

I am an IT specialist with over 10 year experience - years on Automation, on-Premise or Azure.

I am happy to develop however never want be a full time developer. Only do what I have to do. If it has to be PowerShell,HTML, PHP, CSS, C#, VBS or JS, front end or backend, so be it, doesn't matter!

Spent years with Windows, SCCM, SharePoint, SQL and Exchange servers. For last several years, I have been actively working under On Premise > Azure environment.

THERE IS NO WAY BACK!!!

Current Certificates:
    Microsoft® Certified-
  • -Enterprise Administrator
  • -Database Administrator
  • -SharePoint Administrator
  • -Administering and Deploying SCCM 2012
Red Hat Certified Technician
ITIL V3 Foundation - Practitioner

Working on Azure Certificates now and hopefully they can stop upgrading their questions one day! GIVE ME A BREAK!

Contact Lei

Name *
Email *
Comments *

Traffic since 10/08/2016

Today45
Yesterday83
This week669
This month1965
Total416325

Visitor Info

  • IP: 54.163.210.170
  • Browser: Unknown
  • Browser Version:
  • Operating System: Unknown

Who Is Online

2
Online

2017-12-17

Login