Learn how to a build a cloud-first strategyRegister Now

x
• Status: Solved
• Priority: Medium
• Security: Public
• Views: 927
• Last Modified:

Startup Script not working properly Windows 7 64-bit

A startup script (.vbs) that was setup under domain policy, is not working properly on a new Windows 7 64-bit laptop that I am setting up. When I log into Windows, it will try to run this script, which updates some mdb and accdb forms. However, on the new laptop it will come up with an error that it could not successfully run the script. The line which is having the error shows the following:

ObConn.open "Provider=Microsoft.jet.oledb.4.0;Data Source=\\LLB220-DC03\Data\Update.mdb"

It looks to be an issue with the Microsoft Jet Ole DB 4.0

Is there anything that could be done to resolve this issue, so that the forms update properly on this machine?
0
jkj86
Asked:
• 3
• 3
1 Solution

Commented:
There is no 64-bit provider for the JET provider.

Startup scripts automatically run as 64-bit.

You may want to have a wrapper script call your script in 32-bit mode like this:

Launch32bit.vbs

Set oShl = CreateObject("WScript.Shell")
oShl.run oShl.ExpandEnvironmentStrings("%windir%") & "\SysWOW64\csript.exe" _
& " ""c:\path\to\your\realscript.vbs"" ", 1, true
0

Author Commented:
I checked the specific error message again, and it says the error was in line 88, character 5. "Provider could not be found. It may not be properly installed."

The source is ADODB.Connection

Here is the script file coding, however. This laptop's name starts with CTC, so that portion of the script *should* apply to it. How exactly should I go about setting up the wrapper, so that it will work properly?

Dim ObNet, Alp, FO, ObConn, ObRSet, Name, RE, Output
Const OverwriteExisting = TRUE
Apl="N"
Fo="N"

'First create the 3 main objects we will work with in the rest of the script
'LookFSO is used for verifying files and folders
'ObConn is used to connect to the database files in 3 locations
'ObjNet is used to get info on the computer after the user logs in
'RE is a regular expression used later on the computer name

Set LookFSO = CreateObject("Scripting.FileSystemObject")
Set ObConn = CreateObject("ADODB.Connection")
Set ObjNet = CreateObject("WScript.NetWork")
Set RE = New RegExp

'Get the local computer name
Name = ObjNet.ComputerName
'Change each letter in the computer name to Uppercase
Name = UCase(Name)
'Create the pattern, This pattern pulls the first 3 letters of the local computer name
RE.Pattern = "^\w{3}"
'Run the expression and asign the first 3 letters to Output
Set Output = RE.Execute(Name)

'This is a nested loop even though only 1 object is returned after running the regular expression. Output is tested to see if it fits in main branch, branch, or New London.
For Each Match in output
'First check to see if the computer is in main branch
If Match = "LLC" Then
'Look to see if a new Alps form is on the file server
If LookFSO.FileExists("\\SERVER-FS01\Common\IS\FSPForms\Alpsform.accdb") Then
'Make sure the local computer has a FSP folder
If LookFSO.FolderExists("C:\FSP\mdb") Then
'If both tests are true copy the Alps forms to local C drive
Set CopyAlp = CreateObject("Scripting.FileSystemObject")
CopyAlp.CopyFile "\\SERVER-FS01\Common\IS\FSPForms\Alpsform.accdb" , "C:\FSP\mdb\", OverwriteExisting
'Set the Apl variable to Y
Alp="Y"
End If
End IF
'Look to see if a new Fo form is on the file server
If LookFSO.FileExists("\\SERVER-FS01\Common\IS\FSPForms\FoForm.mdb") Then
'Make sure the local computer has a FSP folder
If LookFSO.FolderExists("C:\FSP\mdb") Then
'If both tests are true copy the Fo forms to local C drive
Set CopyFo = CreateObject("Scripting.FileSystemObject")
CopyFo.CopyFile "\\SERVER-FS01\Common\IS\FSPForms\FoForm.mdb" , "C:\FSP\mdb\", OverwriteExisting
'Set the Fo variable to Y
Fo="Y"
End If
End If
'Check to see if either Alp or Fo is yes then if that is true connect to the database in main branch
If Alp="Y" Or Fo="Y" Then
'Conect to the database in main branch and insert computer name, alp, and Fo veraiables to the database
ObConn.open "Provider=Microsoft.jet.oledb.4.0;Data Source=\\sample.org\sample\Data\Harland\Forms\Update.mdb"
ObConn.Execute "INSERT INTO Computer (ComputerName,Alp,Fo) Values (" & _
"'"& Name &"'," & _
"'"& Alp &"'," & _
"'"& Fo &"')"
End If
'If the local computer is in branch run this section
ElseIf Match = "CTC" Then
'Look to see if a new Alps form is on the branch Domain Controler
If LookFSO.FileExists("\\SERVER-FS01\Common\IS\FSPForms\Alpsform.accdb") Then
'Make sure the local computer has a FSP folder
If LookFSO.FolderExists("C:\FSP\mdb") Then
'If both tests are true copy the Alp forms to local C drive
Set CopyAlp = CreateObject("Scripting.FileSystemObject")
CopyAlp.CopyFile "\\SERVER-FS01\Common\IS\FSPForms\Alpsform.accdb" , "C:\FSP\mdb\", OverwriteExisting
'Set Alp to Y
Alp="Y"
End If
End IF
'Look to see if a new Fo form is on the branch Domain Controler
If LookFSO.FileExists("\\SERVER-FS01\Common\IS\FSPForms\FoForm.mdb") Then
'Make sure the local computer has a FSP folder
If LookFSO.FolderExists("C:\FSP\mdb") Then
'If both tests are true copy the Fo forms to local C drive
Set CopyFo = CreateObject("Scripting.FileSystemObject")
CopyFo.CopyFile "\\SERVER-FS01\Common\IS\FSPForms\FoForm.mdb" , "C:\FSP\mdb\", OverwriteExisting
'Set Fo to Y
Fo="Y"
End If
End If
'Check to see if either Alp or Fo is yes then if that is true connect to the database in branch
If Alp="Y" Or Fo="Y" Then
'Conect to the database in branch and insert computer name, alp, and Fo veraiables to the database
ObConn.open "Provider=Microsoft.jet.oledb.4.0;Data Source=\\SERVER-DC03\Data\Update.mdb"
ObConn.Execute "INSERT INTO Computer (ComputerName,Alp,Fo) Values (" & _
"'"& Name &"'," & _
"'"& Alp &"'," & _
"'"& Fo &"')"
End If
ElseIf Match = "LLB" Then
'Look to see if a new Alps form is on the branch Domain Controler
If LookFSO.FileExists("\\SERVER-DC03\Data\Alpsform.accdb") Then
'Make sure the local computer has a FSP folder
If LookFSO.FolderExists("C:\FSP\mdb") Then
'If both tests are true copy the Alp forms to local C drive
Set CopyAlp = CreateObject("Scripting.FileSystemObject")
CopyAlp.CopyFile "\\SERVER-DC03\Data\Alpsform.accdb" , "C:\FSP\mdb\", OverwriteExisting
'Set Alp to Y
Alp="Y"
End If
End IF
'Look to see if a new Fo form is on the branch Domain Controler
If LookFSO.FileExists("\\SERVER-DC03\Data\FoForm.mdb") Then
'Make sure the local computer has a FSP folder
If LookFSO.FolderExists("C:\FSP\mdb") Then
'If both tests are true copy the Fo forms to local C drive
Set CopyFo = CreateObject("Scripting.FileSystemObject")
CopyFo.CopyFile "\\SERVER-DC03\Data\FoForm.mdb" , "C:\FSP\mdb\", OverwriteExisting
'Set Fo to Y
Fo="Y"
End If
End If
'Check to see if either Alp or Fo is yes then if that is true connect to the database in branch
If Alp="Y" Or Fo="Y" Then
'Conect to the database in branch and insert computer name, alp, and Fo veraiables to the database
ObConn.open "Provider=Microsoft.jet.oledb.4.0;Data Source=\\SERVER-DC03\Data\Update.mdb"
ObConn.Execute "INSERT INTO Computer (ComputerName,Alp,Fo) Values (" & _
"'"& Name &"'," & _
"'"& Alp &"'," & _
"'"& Fo &"')"
End If
End If
Next

0

Commented:
To setup the wrapper simple change the code snippet below with the name of your script.
Put them both in the same folder for the startup script.
The below should work no matter where the script is and whether it is started from a UNC or drive letter.
Change "cscript.exe" to "wscript.exe" if that is the scripting host you use.

' This script name is Launch32bit.vbs
Set oShl = CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")

'Change below line to include RELATIVE script name (not full path)
FullScriptName = oFSO.BuildPath(oFSO.GetParentFolderName(wscript.scriptfullname), "realscript.vbs")

oShl.run oShl.ExpandEnvironmentStrings("%windir%") & "\SysWOW64\cscript.exe" _
& " """ & FullScriptName & """ ", 1, true
0

Author Commented:
I guess the only problem would be that this is a domain-wide policy, so is there a way I could set up this script so that if the system is 32-bit, then it will not run from SysWOW64, but then just run the script as normal?
0

Commented:
Sure, one IF statement will make sure that the SysWOW64 is only used on 64-bit Windows:

' This script name is Launch32bit.vbs
Set oShl = CreateObject("WScript.Shell")
Set oFSO = CreateObject("Scripting.FileSystemObject")

'Change below line to include RELATIVE script name (not full path)
FullScriptName = oFSO.BuildPath(oFSO.GetParentFolderName(wscript.scriptfullname), "realscript.vbs")

If oShl.ExpandEnvironmentStrings("%ProgramFiles(x86)%") <> ""
oShl.run oShl.ExpandEnvironmentStrings("%windir%") & "\SysWOW64\cscript.exe" _
& " """ & FullScriptName & """ ", 1, true
End If


We have some very creative code in .vbs, .cmd and .ps1 for doing this exact kind of thing as part of our course on 64-bit: http://csi-windows.com/courses/eng-52-windows-7-application-support-engineer
0

Author Commented:
Thank you for the help. This solved the issue perfectly!
0

Featured Post

• 3
• 3
Tackle projects and never again get stuck behind a technical roadblock.