Jump to content

Line -1 : Error: Variable must be of type "Object"


secman
 Share

Recommended Posts

Hi all,

I am very new to AutoIt but have been able to put together a few scripts mostly using code examples posted by those much more experienced than I.

I have created a script to run on a laptop. The student logs on using a local ID and password and this script runs to allow them to log onto their network account via a wireless link. This has been working fine but recently I have been enhancing it a bit to try to link it directly to another script to run a simple menu for firing off applications.

When I run the compiled script now from a laptop or from another PC (one that does not have Autoit installed), I get

"Line -1 Error: Variable must be of type "Object"

Now I don't think I have used any "objects" in my script as I am trying to keep it basic and I am not by any means a programmer. I hope someone can help.

The code is as follows:

#include <GUIConstants.au3>

#include <String.au3>

#include <IE.au3>

#include <Array.au3>

#include <Inet.au3>

#include <Date.au3>

#include <ADFunctions.au3>

;

Global $LoginGUI, $loginusername, $loginpassword, $loginlogin, $logincreate, $domuname, $uname, $loginPW, $loginUN, $line1, $line2, $line3, $defusername

; ------- Default Username ------

$defusername = ""

; ------- GUI create ------------

$LoginGUI = GUICreate("Login", 302, 135)

$loginusername = GUICtrlCreateInput($defusername, 102, 21, 165, 21)

GUICtrlCreateLabel("Username:", 30, 22, 55, 17)

$loginpassword = GUICtrlCreateInput("", 102, 55, 165, 21, 32)

GUICtrlCreateLabel("Password:", 30, 56, 53, 17)

GUICtrlCreateGroup("Enter Your Username and Password", 6, 1, 286, 86)

GUICtrlSetColor(-1, 0x0000ff)

GUICtrlCreateGroup("", -99, -99, 1, 1)

$loginlogin = GUICtrlCreateButton("Login", 5, 105, 88, 25, 0)

GUICtrlSetState(-1, $GUI_DEFBUTTON)

GUICtrlSetTip(-1, "Click here to login")

; -------------------------------

GUISetState(@SW_SHOW)

While 1

Sleep(20)

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

ExitLoop

Case $loginlogin

$loginUN = GUICtrlRead($loginusername)

$loginPW = GUICtrlRead($loginpassword)

$uname = "\\server2\" & $loginUN & "$"

$domuname = "DOMAIN\" & $loginUN

DriveMapAdd("H:", $uname, 0, $domuname, $loginPW)

DriveMapAdd("S:", "\\server2\shared", 0, $domuname, $loginPW)

DriveMapAdd("P:", "\\server2\apps", 0, $domuname, $loginPW)

ExitLoop

EndSwitch

sleep(20)

;Check Network Drives

IF DriveStatus( "H:\" ) = "INVALID" Then DriveMapAdd("H:", $uname, 0, $domuname, $loginPW)

IF DriveStatus( "P:\" ) = "INVALID" Then DriveMapAdd("P:", "\\server2\apps", 0, $domuname, $loginPW)

IF DriveStatus( "S:\" ) = "INVALID" Then DriveMapAdd("S:", "\\server2\shared", 0, $domuname, $loginPW)

WEnd

IF DriveStatus( "H:\" ) = "READY" Then $line1 = "H: is Connected to HOME"

IF DriveStatus( "H:\" ) = "INVALID" Then $line1 = "Drive H: not mapped"

IF DriveStatus( "P:\" ) = "READY" Then $line2 = "P: is Connected to APPS"

IF DriveStatus( "P:\" ) = "INVALID" Then $line2 = "Drive P: is not mapped"

IF DriveStatus( "S:\" ) = "READY" Then $line3 = "S: is Connected to SHARED"

IF DriveStatus( "S:\" ) = "INVALID" Then $line3 = "Drive S: is not mapped"

MsgBox(4096, "Drive Status" , $line1 & @CR & $line2 & @CR & $line3, 3)

ShellExecute("C:\menu\mathsmenu.exe")

Link to comment
Share on other sites

  • 2 weeks later...
  • Moderators

HOW? Your posting really is useless because you didn't tell anyone how you fixed the problem.

They probably used IsObj() in a conditional statement after making the object/method.

And or they trapped it with COM Error Handling which can be found in the "Obj/COM Reference" of the help file.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • 3 weeks later...

They probably used IsObj() in a conditional statement after making the object/method.

And or they trapped it with COM Error Handling which can be found in the "Obj/COM Reference" of the help file.

Sorry Gents,

The problem was sort of sorted as I found that the error occured if the script could not find the network. If the network was available - no problems, If the network was disconnected or not fully active (i.e. waiting for DHCP or the wireless link to start) the error occured.

I still get the error though - Is there any reliable way to trap and manage the error - Be gentle with me, I am still new to this.

Thanks

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...