Jump to content

Opening MS access with wrkgrp and user and password

Recommended Posts


I need to open with autoit a MS access database!

This database is opening with this shortcut:

"C:\Program Files (x86)\Microsoft Office\OFFICE11\MSACCESS.EXE" /wrkgrp \\server\folder\sys.mdw \\server\folder\database.mdb /user MyUser /pwd MyPass

How do I open this in Autoit. (using COM object)

$adoCon = ObjCreate("ADODB.Connection")

$adoCon.Open("Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & $dbname&"; SystemDB="&$wkname&"; " , $user, $pwd)

If Not(IsObj($adoCon)) Then

; create recordset
$adoRs = ObjCreate("ADODB.Recordset")
$adoRs.CursorType = 1
$adoRs.LockType = 3

$sQuery = 'SELECT * FROM Address;'

; open query
$adoRs.Open($sQuery, $adoCon)

I got an error with the Query !

Need help

Thanks in advance !


Link to comment
Share on other sites

Have you tried like this?

$adoCon.Open("Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & $dbname&"; SystemDB="&$wkname&";UID=" & $user & ";PWD=" & $pwd)


but it doesn't work:

C:\Users\Admin\Dropbox\au3\PO\test-accecss.au3 (33) : ==> The requested action with this object has failed.:
Link to comment
Share on other sites

On which line did the error occur? The $adoCon.Open statement? Also, you mentioned earlier that you received an error when you attempted to run the sql statement, but you didn't indicate what the actual error message was.

FWIW, I suspect the your initial attempt to open the file is failing and I don't believe your error checking will work as written. Here's some code from a script I previously wrote:

$sqlCon = ObjCreate("ADODB.Connection")
$sqlCon.Mode = 16 ; sharedenynone
$sqlCon.CursorLocation = 3 ; client side cursor

; Retrieve active call from ACD database
$sqlString = "DRIVER=Microsoft Access Driver (*.mdb);UID=userid;PWD=password;UserCommitSync=Yes;Threads=3;PageTimeout=5;MaxScanRows=8;MaxBufferSize=2048;FIL=MS Access;DriverId=25;DefaultDir=\\Server\Reports;DBQ=\\Server\Reports\dbACD.mdb"
$sqlCon.Open ($sqlString)

If $IEComErrorNumber = 0 Then
$sqlRs = ObjCreate("ADODB.Recordset")

$sqlString = "select count(*) as cnt from status where agentext <> 0 and status <> " & $AgentLogin
$sqlRs.open ($sqlString, $sqlCon)

If Not $sqlRs.EOF Then
; Record / field level functionality goes here


If $sqlCon.state = $adStateOpen Then


Essentially, this uses the COM error handler from IE.AU3, which avoids the script from erroring out when a COM error occurs. If you are using the latest beta version, then this won't be necessary.

Link to comment
Share on other sites


For some reasons it is working on the Access Server but not remotely...( from my remote PC !)

Both works fine for me!

$adoCon.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $dbname & ";Jet OLEDB:System Database="&$wkname&";User ID="&$user&";Password="&$pwd&";")

$adoCon.Open("Driver={Microsoft Access Driver (*.mdb)};DBQ=" & $dbname&";SystemDB="&$wkname&";Uid="&$user&";Pwd="&$pwd&";")
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

  • Create New...