如何从批处理脚本启动Access数据库文件? [英] How do you launch an access database file from a batch script?

查看:85
本文介绍了如何从批处理脚本启动Access数据库文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我大约有十二个用户都访问同一个Access数据库,这使更新很麻烦,因为当我更新文件时,他们都必须注销.为了解决这个问题,我想让他们使用一个简单的启动器,如下所示:

I have about a dozen users that all access this same Access Database, which is making updates painful since they all have to log out when I update the file. To solve this, I would like to have them use a simple launcher, like this:

DatabaseLauncher.bat

start Z:\AccessDatabases\SharedAccessFile-version1.accde

然后,我将在启动器中更新版本,以便用户可以关闭数据库并随意打开数据库以使用新功能.

Then, I will update the version in the launcher so that users can close the database and open it at their leisure for the new features.

运行脚本会产生此错误:该进程无法访问文件,因为该文件正在被另一个进程使用.

Running the script produces this error: The process cannot access the file because it is being used by another process.

从命令行运行命令非常正常.

Running the command from the command line works perfectly.

推荐答案

这是我在.vbs脚本中用于在注册表中搜索指定程序的代码,如果找到,请运行该程序,如果不显示消息.它是通过各种公共来源修补而成的.

Here is the code I use in a .vbs script to search the registry for the specified program and, if found run it and if not display a message. It was patched together from various public sources.

可以将其展开以启动指定的数据库,并使用/x等参数来运行指定的宏.

It can be expanded to start a specified database and use parameters such as /x to run a specified macro.

dim objShell, WshShell, ProgToFind
Set objShell = CreateObject("WScript.Shell")

Set WshShell = WScript.CreateObject("WScript.Shell")

On Error Resume Next

ProgToFind = "MSACCESS.EXE"

AppPath = WshShell.RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\" & ProgToFind & "\")

    If Len(AppPath) = 0 Then
        WScript.Echo "App Not Found"
        WScript.Quit
        End If

CommandStr = Chr(34) & AppPath & Chr(34)    'Enclose the AppPath in double quotes

objShell.run CommandStr    'Execute the command string

这篇关于如何从批处理脚本启动Access数据库文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆