Hello everyone,
What I have here is the start of a project, But it is throwing up error codes. This script checks for drive S: and then if its there check for S:\USB_KEY.FAB . I would like it to say for instance "Welcome ~Ghost~" one time until it is replaced with a different authorized key. Each USB key has its own UUID. One last thing could you also help me find a way when drive S: is taken out it resets the last UUID key read?
Thank you
Error Codes:
-with it plugged in first then running it.-
Error - Running script, script run or compile error in file: Test Zone Key_Check.txt13:Type mismatch: 'arrFileLines' in line 55 More info: Type mismatch: 'arrFileLines'
-with it not plugged in first then running it.-
NO ERRORS
-with it not plugged in first then running it. Plugging it in with script running.-
Error - Running script, script run or compile error in file: Test Zone - Key_Check.txt13:Type mismatch: 'arrFileLines' in line 55 More info: Type mismatch: 'arrFileLines'
'``````````````````````````````````````````````````````````` `````
'Name:Key Check
'Lang:VBS
'Purpose: Used to check keys
'Note: Testing Zone
sub main()
'//DEVICES //
AcessLevel = hs.DeviceString("Y99")
'//DEVICES //
hs.speak "Now Checking for keys"
do until KeyCheckLP = 1
if KeyCheck = 3 then
KeyCheckLP = 1
else
KeyCheck = hs.DeviceStatus("Y98")
if not FAB_UUID = UUIDOLD then
else
'//Varibles//
Dim arrFileLines
ForReading = 1
Set FSO = CreateObject("Scripting.FileSystemObject")
FLGREASON = "ALERT !!! ALERT THIS KEY HAS BEEN TAMPERED WITH. NOW LOCKING KEY OUT. The following differentces from the database to the Fab has set off a flag, "
if (FSO.DriveExists("S:")) Then
if (FSO.FileExists("S:\USB_KEY.FAB")) Then
Dim xlApp, xlBook, xlSht
Dim USER_LIST
USER_LIST = "D:\HomeSeer HSPRO\Config\usr\KC.xlsx"
set xlApp = CreateObject("Excel.Application")
xlApp.Application.DisplayAlerts = False
set xlBook = xlApp.WorkBooks.Open(USER_LIST)
set xlSht = xlApp.activesheet
CNT = 2
MCNT = 0
HN = 1
FLGLINE = 0
i = 0
Set objTextFile = FSO.OpenTextFile("S:\USB_KEY.FAB", ForReading)
'//Read FAB//
Do Until objTextFile.AtEndOfStream
Redim Preserve arrFileLines(i)
arrFileLines(i) = objTextFile.ReadLine
i = i + 1
Loop
objTextFile.Close
For l = Ubound(arrFileLines) to LBound(arrFileLines) Step -1
Next
'//FAB Varibles//
FAB_FNAME = arrFileLines(0)
FAB_MNAME = arrFileLines(1)
FAB_LNAME = arrFileLines(2)
FAB_LGRAMAR = arrFileLines(3)
FAB_GENDER = arrFileLines(4)
FAB_ACCESSLVL = arrFileLines(5)
FAB_UUID = arrFileLines(6)
FAB_CDATE = arrFileLines(7)
FAB_CTIME = arrFileLines(8)
FAB_EXPIRATION = arrFileLines(9)
FAB_PHONE = arrFileLines(10)
FAB_CARRIER = arrFileLines(11)
FAB_EMAIL = arrFileLines(12)
FAB_RELATION = arrFileLines(13)
FAB_LABLE = arrFileLines(14)
FAB_STAYING = arrFileLines(15)
FAB_SCED = arrFileLines(16)
FAB_MEDS = arrFileLines(17)
FAB_FLAGREASON = arrFileLines(18)
'//FAB Varibles//
'//Load Excel for key auth.//
do until MCNT = 1
DB_A = xlSht.Cells(CNT, 1).text 'Status
DB_B = xlSht.Cells(CNT, 2).text 'First Name
DB_C = xlSht.Cells(CNT, 3).text 'Middle Name
DB_D = xlSht.Cells(CNT, 4).text 'Last Name
DB_E = xlSht.Cells(CNT, 5).text 'Gramar
DB_F = xlSht.Cells(CNT, 6).text 'Gender
DB_G = xlSht.Cells(CNT, 6).text 'Access Level
DB_H = xlSht.Cells(CNT, 7).text 'UUID
DB_I = xlSht.Cells(CNT, 8).text 'Date
DB_J = xlSht.Cells(CNT, 9).text 'Time
DB_K = xlSht.Cells(CNT, 10).text 'Expiration
DB_L = xlSht.Cells(CNT, 11).text 'Phone Number
DB_M = xlSht.Cells(CNT, 5).text 'Carrier
DB_N = xlSht.Cells(CNT, 12).text 'E-Mail Address
DB_O = xlSht.Cells(CNT, 13).text 'Relation
DB_P = xlSht.Cells(CNT, 14).text 'Lable
DB_Q = xlSht.Cells(CNT, 15).text 'Stay
DB_R = xlSht.Cells(CNT, 16).text 'Shedule
DB_S = xlSht.Cells(CNT, 17).text 'Medication
DB_T = xlSht.Cells(CNT, 18).text 'Flag Reason
DB_U = xlSht.Cells(CNT, 19).text 'House Code
if DB_A = "STP" then
MCNT = 1
else
if DB_A = "A" then
if FAB_UUID = DB_H then
UUIDOLD = FAB_UUID
FLGLINE = CNT
if FAB_FNAME = DB_B then
else
FLGREASON = FLGREASON & " First name, "
UUIDOLD = ""
xlSht.Cells(FLGLINE, 1) = "T"
FLG = 1
KEY_MATCH = 4
end if
if FAB_MNAME = DB_C then
else
FLGREASON = FLGREASON & " Middle name, "
UUIDOLD = ""
xlSht.Cells(FLGLINE, 1) = "T"
FLG = 1
KEY_MATCH = 4
end if
if FAB_LNAME = DB_D then
else
FLGREASON = FLGREASON & " Last name, "
UUIDOLD = ""
xlSht.Cells(FLGLINE, 1) = "T"
FLG = 1
KEY_MATCH = 4
end if
if FAB_LGRAMAR = DB_E then
else
FLGREASON = FLGREASON & " Last name gramar, "
UUIDOLD = ""
xlSht.Cells(FLGLINE, 1) = "T"
FLG = 1
KEY_MATCH = 4
end if
if FAB_GENDER = DB_F then
else
FLGREASON = FLGREASON & " Gender, "
UUIDOLD = ""
xlSht.Cells(FLGLINE, 1) = "T"
FLG = 1
KEY_MATCH = 4
end if
if FAB_ACCESSLVL = DB_G then
else
FLGREASON = FLGREASON & " Acess level, "
UUIDOLD = ""
xlSht.Cells(FLGLINE, 1) = "T"
FLG = 1
KEY_MATCH = 4
end if
if FAB_CDATE = DB_I then
else
FLGREASON = FLGREASON & " Creation date, "
UUIDOLD = ""
xlSht.Cells(FLGLINE, 1) = "T"
FLG = 1
KEY_MATCH = 4
end if
if FAB_CTIME = DB_J then
else
FLGREASON = FLGREASON & " Creation time, "
UUIDOLD = ""
xlSht.Cells(FLGLINE, 1) = "T"
FLG = 1
KEY_MATCH = 4
end if
if FAB_EXPIRATION = DB_K then
else
FLGREASON = FLGREASON & " Expiration Date, "
UUIDOLD = ""
xlSht.Cells(FLGLINE, 1) = "T"
FLG = 1
KEY_MATCH = 4
end if
if FAB_PHONE = DB_L then
else
FLGREASON = FLGREASON & " Phone number, "
UUIDOLD = ""
xlSht.Cells(FLGLINE, 1) = "T"
FLG = 1
KEY_MATCH = 4
end if
if FAB_CARRIER = DB_M then
else
FLGREASON = FLGREASON & " Phone carrier, "
UUIDOLD = ""
xlSht.Cells(FLGLINE, 1) = "T"
FLG = 1
KEY_MATCH = 4
end if
if FAB_EMAIL = DB_N then
else
FLGREASON = FLGREASON & " E Mail address, "
UUIDOLD = ""
xlSht.Cells(FLGLINE, 1) = "T"
FLG = 1
KEY_MATCH = 4
end if
if FAB_RELATION = DB_O then
else
FLGREASON = FLGREASON & " Relation, "
UUIDOLD = ""
xlSht.Cells(FLGLINE, 1) = "T"
FLG = 1
KEY_MATCH = 4
end if
if FAB_LABLE = DB_P then
else
FLGREASON = FLGREASON & " Lable, "
UUIDOLD = ""
xlSht.Cells(FLGLINE, 1) = "T"
FLG = 1
KEY_MATCH = 4
end if
if FAB_STAYING = DB_Q then
else
FLGREASON = FLGREASON & " Staying, "
UUIDOLD = ""
xlSht.Cells(FLGLINE, 1) = "T"
FLG = 1
KEY_MATCH = 4
end if
if FAB_SCED = DB_R then
else
FLGREASON = FLGREASON & " Schedule, "
UUIDOLD = ""
xlSht.Cells(FLGLINE, 1) = "T"
FLG = 1
KEY_MATCH = 4
end if
if FAB_MEDS = DB_S then
else
FLGREASON = FLGREASON & " Medication Chart, "
UUIDOLD = ""
xlSht.Cells(FLGLINE, 1) = "T"
FLG = 1
KEY_MATCH = 4
MCNT = 1
end if
else
CNT = CNT +1
end if
else
if FAB_UUID = DB_H then
if DB_A = "E" then
KEY_MATCH = 2
MCNT = 1
end if
if DB_A = "D" then
KEY_MATCH = 3
MCNT = 1
end if
if DB_A = "T" then
KEY_MATCH = 4
MCNT = 1
end if
else
CNT = CNT +1
end if
end if
end if
loop
if FLG = 0 then
KEY_MATCH = 1
end if
'//Results//
if KEY_MATCH = 0 then
hs.speak " This key does not match any in my data base."
UUIDOLD = ""
hs.SetDeviceString "Y99", "A"
MCNT = 1
end if
if KEY_MATCH = 1 then
hs.speak "Welcome " & FAB_FNAME & " your, access level is " & FAB_ACCESSLVL & "."
hs.SetDeviceString "Y99", FAB_ACCESSLVL
end if
if KEY_MATCH = 2 then
hs.speak " This key has expired. Please Contact a administrator to create a new one."
hs.SetDeviceString "Y99", "A"
MCNT = 1
end if
if KEY_MATCH = 3 then
hs.speak " This key has been marked for deletion. Please Contact a administrator to create a new one, or have this one extended."
hs.SetDeviceString "Y99", "A"
MCNT = 1
end if
if KEY_MATCH = 4 then
hs.SetDeviceString "Y99", "A"
hs.speak "This key has been flagged for tampering and is locked out."
hs.waitsecs(2)
hs.speak "Please contact a admin or a maintainace user."
end if
'//Results//
'//Close Excel for key auth.//
xlApp.activesheet.SaveAs "D:\HomeSeer HSPRO\Config\KC.xlsx"
xlBook.Close False
xlApp.Quit
set xlSht = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
'//Close Excel for key auth.//
'//Read FAB//
else
UUIDOLD = ""
end if
else
UUIDOLD = ""
end if
end if
end if
Loop
hs.speak "I am no longer checking for keys"
end sub
What I have here is the start of a project, But it is throwing up error codes. This script checks for drive S: and then if its there check for S:\USB_KEY.FAB . I would like it to say for instance "Welcome ~Ghost~" one time until it is replaced with a different authorized key. Each USB key has its own UUID. One last thing could you also help me find a way when drive S: is taken out it resets the last UUID key read?
Thank you
Error Codes:
-with it plugged in first then running it.-
Error - Running script, script run or compile error in file: Test Zone Key_Check.txt13:Type mismatch: 'arrFileLines' in line 55 More info: Type mismatch: 'arrFileLines'
-with it not plugged in first then running it.-
NO ERRORS
-with it not plugged in first then running it. Plugging it in with script running.-
Error - Running script, script run or compile error in file: Test Zone - Key_Check.txt13:Type mismatch: 'arrFileLines' in line 55 More info: Type mismatch: 'arrFileLines'
'``````````````````````````````````````````````````````````` `````
'Name:Key Check
'Lang:VBS
'Purpose: Used to check keys
'Note: Testing Zone
sub main()
'//DEVICES //
AcessLevel = hs.DeviceString("Y99")
'//DEVICES //
hs.speak "Now Checking for keys"
do until KeyCheckLP = 1
if KeyCheck = 3 then
KeyCheckLP = 1
else
KeyCheck = hs.DeviceStatus("Y98")
if not FAB_UUID = UUIDOLD then
else
'//Varibles//
Dim arrFileLines
ForReading = 1
Set FSO = CreateObject("Scripting.FileSystemObject")
FLGREASON = "ALERT !!! ALERT THIS KEY HAS BEEN TAMPERED WITH. NOW LOCKING KEY OUT. The following differentces from the database to the Fab has set off a flag, "
if (FSO.DriveExists("S:")) Then
if (FSO.FileExists("S:\USB_KEY.FAB")) Then
Dim xlApp, xlBook, xlSht
Dim USER_LIST
USER_LIST = "D:\HomeSeer HSPRO\Config\usr\KC.xlsx"
set xlApp = CreateObject("Excel.Application")
xlApp.Application.DisplayAlerts = False
set xlBook = xlApp.WorkBooks.Open(USER_LIST)
set xlSht = xlApp.activesheet
CNT = 2
MCNT = 0
HN = 1
FLGLINE = 0
i = 0
Set objTextFile = FSO.OpenTextFile("S:\USB_KEY.FAB", ForReading)
'//Read FAB//
Do Until objTextFile.AtEndOfStream
Redim Preserve arrFileLines(i)
arrFileLines(i) = objTextFile.ReadLine
i = i + 1
Loop
objTextFile.Close
For l = Ubound(arrFileLines) to LBound(arrFileLines) Step -1
Next
'//FAB Varibles//
FAB_FNAME = arrFileLines(0)
FAB_MNAME = arrFileLines(1)
FAB_LNAME = arrFileLines(2)
FAB_LGRAMAR = arrFileLines(3)
FAB_GENDER = arrFileLines(4)
FAB_ACCESSLVL = arrFileLines(5)
FAB_UUID = arrFileLines(6)
FAB_CDATE = arrFileLines(7)
FAB_CTIME = arrFileLines(8)
FAB_EXPIRATION = arrFileLines(9)
FAB_PHONE = arrFileLines(10)
FAB_CARRIER = arrFileLines(11)
FAB_EMAIL = arrFileLines(12)
FAB_RELATION = arrFileLines(13)
FAB_LABLE = arrFileLines(14)
FAB_STAYING = arrFileLines(15)
FAB_SCED = arrFileLines(16)
FAB_MEDS = arrFileLines(17)
FAB_FLAGREASON = arrFileLines(18)
'//FAB Varibles//
'//Load Excel for key auth.//
do until MCNT = 1
DB_A = xlSht.Cells(CNT, 1).text 'Status
DB_B = xlSht.Cells(CNT, 2).text 'First Name
DB_C = xlSht.Cells(CNT, 3).text 'Middle Name
DB_D = xlSht.Cells(CNT, 4).text 'Last Name
DB_E = xlSht.Cells(CNT, 5).text 'Gramar
DB_F = xlSht.Cells(CNT, 6).text 'Gender
DB_G = xlSht.Cells(CNT, 6).text 'Access Level
DB_H = xlSht.Cells(CNT, 7).text 'UUID
DB_I = xlSht.Cells(CNT, 8).text 'Date
DB_J = xlSht.Cells(CNT, 9).text 'Time
DB_K = xlSht.Cells(CNT, 10).text 'Expiration
DB_L = xlSht.Cells(CNT, 11).text 'Phone Number
DB_M = xlSht.Cells(CNT, 5).text 'Carrier
DB_N = xlSht.Cells(CNT, 12).text 'E-Mail Address
DB_O = xlSht.Cells(CNT, 13).text 'Relation
DB_P = xlSht.Cells(CNT, 14).text 'Lable
DB_Q = xlSht.Cells(CNT, 15).text 'Stay
DB_R = xlSht.Cells(CNT, 16).text 'Shedule
DB_S = xlSht.Cells(CNT, 17).text 'Medication
DB_T = xlSht.Cells(CNT, 18).text 'Flag Reason
DB_U = xlSht.Cells(CNT, 19).text 'House Code
if DB_A = "STP" then
MCNT = 1
else
if DB_A = "A" then
if FAB_UUID = DB_H then
UUIDOLD = FAB_UUID
FLGLINE = CNT
if FAB_FNAME = DB_B then
else
FLGREASON = FLGREASON & " First name, "
UUIDOLD = ""
xlSht.Cells(FLGLINE, 1) = "T"
FLG = 1
KEY_MATCH = 4
end if
if FAB_MNAME = DB_C then
else
FLGREASON = FLGREASON & " Middle name, "
UUIDOLD = ""
xlSht.Cells(FLGLINE, 1) = "T"
FLG = 1
KEY_MATCH = 4
end if
if FAB_LNAME = DB_D then
else
FLGREASON = FLGREASON & " Last name, "
UUIDOLD = ""
xlSht.Cells(FLGLINE, 1) = "T"
FLG = 1
KEY_MATCH = 4
end if
if FAB_LGRAMAR = DB_E then
else
FLGREASON = FLGREASON & " Last name gramar, "
UUIDOLD = ""
xlSht.Cells(FLGLINE, 1) = "T"
FLG = 1
KEY_MATCH = 4
end if
if FAB_GENDER = DB_F then
else
FLGREASON = FLGREASON & " Gender, "
UUIDOLD = ""
xlSht.Cells(FLGLINE, 1) = "T"
FLG = 1
KEY_MATCH = 4
end if
if FAB_ACCESSLVL = DB_G then
else
FLGREASON = FLGREASON & " Acess level, "
UUIDOLD = ""
xlSht.Cells(FLGLINE, 1) = "T"
FLG = 1
KEY_MATCH = 4
end if
if FAB_CDATE = DB_I then
else
FLGREASON = FLGREASON & " Creation date, "
UUIDOLD = ""
xlSht.Cells(FLGLINE, 1) = "T"
FLG = 1
KEY_MATCH = 4
end if
if FAB_CTIME = DB_J then
else
FLGREASON = FLGREASON & " Creation time, "
UUIDOLD = ""
xlSht.Cells(FLGLINE, 1) = "T"
FLG = 1
KEY_MATCH = 4
end if
if FAB_EXPIRATION = DB_K then
else
FLGREASON = FLGREASON & " Expiration Date, "
UUIDOLD = ""
xlSht.Cells(FLGLINE, 1) = "T"
FLG = 1
KEY_MATCH = 4
end if
if FAB_PHONE = DB_L then
else
FLGREASON = FLGREASON & " Phone number, "
UUIDOLD = ""
xlSht.Cells(FLGLINE, 1) = "T"
FLG = 1
KEY_MATCH = 4
end if
if FAB_CARRIER = DB_M then
else
FLGREASON = FLGREASON & " Phone carrier, "
UUIDOLD = ""
xlSht.Cells(FLGLINE, 1) = "T"
FLG = 1
KEY_MATCH = 4
end if
if FAB_EMAIL = DB_N then
else
FLGREASON = FLGREASON & " E Mail address, "
UUIDOLD = ""
xlSht.Cells(FLGLINE, 1) = "T"
FLG = 1
KEY_MATCH = 4
end if
if FAB_RELATION = DB_O then
else
FLGREASON = FLGREASON & " Relation, "
UUIDOLD = ""
xlSht.Cells(FLGLINE, 1) = "T"
FLG = 1
KEY_MATCH = 4
end if
if FAB_LABLE = DB_P then
else
FLGREASON = FLGREASON & " Lable, "
UUIDOLD = ""
xlSht.Cells(FLGLINE, 1) = "T"
FLG = 1
KEY_MATCH = 4
end if
if FAB_STAYING = DB_Q then
else
FLGREASON = FLGREASON & " Staying, "
UUIDOLD = ""
xlSht.Cells(FLGLINE, 1) = "T"
FLG = 1
KEY_MATCH = 4
end if
if FAB_SCED = DB_R then
else
FLGREASON = FLGREASON & " Schedule, "
UUIDOLD = ""
xlSht.Cells(FLGLINE, 1) = "T"
FLG = 1
KEY_MATCH = 4
end if
if FAB_MEDS = DB_S then
else
FLGREASON = FLGREASON & " Medication Chart, "
UUIDOLD = ""
xlSht.Cells(FLGLINE, 1) = "T"
FLG = 1
KEY_MATCH = 4
MCNT = 1
end if
else
CNT = CNT +1
end if
else
if FAB_UUID = DB_H then
if DB_A = "E" then
KEY_MATCH = 2
MCNT = 1
end if
if DB_A = "D" then
KEY_MATCH = 3
MCNT = 1
end if
if DB_A = "T" then
KEY_MATCH = 4
MCNT = 1
end if
else
CNT = CNT +1
end if
end if
end if
loop
if FLG = 0 then
KEY_MATCH = 1
end if
'//Results//
if KEY_MATCH = 0 then
hs.speak " This key does not match any in my data base."
UUIDOLD = ""
hs.SetDeviceString "Y99", "A"
MCNT = 1
end if
if KEY_MATCH = 1 then
hs.speak "Welcome " & FAB_FNAME & " your, access level is " & FAB_ACCESSLVL & "."
hs.SetDeviceString "Y99", FAB_ACCESSLVL
end if
if KEY_MATCH = 2 then
hs.speak " This key has expired. Please Contact a administrator to create a new one."
hs.SetDeviceString "Y99", "A"
MCNT = 1
end if
if KEY_MATCH = 3 then
hs.speak " This key has been marked for deletion. Please Contact a administrator to create a new one, or have this one extended."
hs.SetDeviceString "Y99", "A"
MCNT = 1
end if
if KEY_MATCH = 4 then
hs.SetDeviceString "Y99", "A"
hs.speak "This key has been flagged for tampering and is locked out."
hs.waitsecs(2)
hs.speak "Please contact a admin or a maintainace user."
end if
'//Results//
'//Close Excel for key auth.//
xlApp.activesheet.SaveAs "D:\HomeSeer HSPRO\Config\KC.xlsx"
xlBook.Close False
xlApp.Quit
set xlSht = Nothing
Set xlBook = Nothing
Set xlApp = Nothing
'//Close Excel for key auth.//
'//Read FAB//
else
UUIDOLD = ""
end if
else
UUIDOLD = ""
end if
end if
end if
Loop
hs.speak "I am no longer checking for keys"
end sub