[AccessD] Starting Access from a command prompt
John Bodin
jbodin at sbor.com
Wed Sep 19 10:17:44 CDT 2018
Thanks Joe. Nice alternative. I would have to deal with the deleting of the existing file in case the user has two copies open (multiple screen app) which I could test probably with the Errorcode=5. Will look into this option.
John
John Bodin
sBOR Office Systems
jbodin at sbor.com<mailto:jbodin at sbor.com>
________________________________
From: AccessD <accessd-bounces at databaseadvisors.com> on behalf of Joe O'Connell <JoeO at appoli.com>
Sent: Wednesday, September 19, 2018 11:03 AM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Starting Access from a command prompt
John,
A lot of the applications that I develop run on a terminal server. The latest version of an Access application is placed in a folder that is accessible by all users. The users have a shortcut on their desktop that runs a VB script that copies the application to a local folder for each user and then starts the application. This way I am sure that all users are using the latest version of the software, they always have a clean copy so there is no concern with bloat, and by appending the name of the client PC to the file name multiple people can be logged with the same account but each will be running their own version of the FE. The path and names will need to be changed for your needs.
Joe O'Connell
On error Resume Next
Dim strCopyFrom
Dim strCopyTo
Dim strRunCmd
Dim strUser
Dim strClient
Dim fso
Dim objNetwork
Dim shell
Set objNetwork = CreateObject("Wscript.Network")
strUser = objNetwork.UserName
'wscript.echo strUser
Set objShell = CreateObject("WScript.Shell")
strClient = objShell.ExpandEnvironmentStrings("%clientname%")
'wscript.echo strClient
Set fso = CreateObject("Scripting.FileSystemObject")
strCopyFrom = "path\name of Access.mde"
strCopyTo = "local path-" & strClient & ".mde"
strRunCmd = Chr(34) & "C:\Program Files (x86)\Microsoft Office\OFFICE11\MSACCESS.EXE" & Chr(34) & " " & Chr(34) & strCopyTo & Chr(34)
'wscript.echo "Check if exist"
If (fso.FileExists(strCopyTo)) = True Then
fso.DeleteFile strCopyTo
If Err.number = 0 Then
' wscript.echo "Delete Successful"
Else
wscript.echo "Delete Failed" & vbcrlf & err.description
End If
End If
'wscript.echo "Copy file"
fso.CopyFile strCopyFrom, strCopyTo, True
If err.number = 0 Then
' wscript.echo "Program copied"
Else
wscript.echo "Error while copy of test program" & vbcrlf & err.description
End If
Set shell = CreateObject("WScript.Shell")
shell.Run strRunCmd, 1, false
Set shell = Nothing
strCopyFrom = vbNullString
strCopyTo = vbNullString
strRunCmd = vbNullString
Set fso = Nothing
Set objNetwork = Nothing
Set shell = Nothing
-----Original Message-----
From: AccessD <accessd-bounces at databaseadvisors.com> On Behalf Of John Bodin
Sent: Tuesday, September 18, 2018 11:11 PM
To: Access Developers discussion and problem solving <accessd at databaseadvisors.com>
Subject: Re: [AccessD] Starting Access from a command prompt
I found that I had to provide a "Title" when using the Start command when starting a Program. I didn't use that parameter so the DOS window stayed open. My second line of the batch file is now is:
START "sometitle" C:\Program Files (x86)\Microsoft Office\Office11\MSAccess.Exe C:\MyApp\MyProg.mdb
and that seems to let the DOS command prompt terminate while Access opens and appears to work fine.
Any better ideas, I'm all ears. Don't know how memory usage is affected by starting Access using the method I am trying.
Thank you.
John
-----Original Message-----
From: AccessD [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of John Bodin
Sent: Tuesday, September 18, 2018 9:54 PM
To: Access Developers discussion and problem solving (accessd at databaseadvisors.com)
Subject: [AccessD] Starting Access from a command prompt
Having a brain cramp. I have an access FE/BE app that people run using the full version of Access 2003. Periodically, the FE app decompiles on a user and causes slowdowns and issues, so I have a little batch file that they can run to copy a cleaned Compiled version to their local C drive, overwriting the fault FE file. Then they click on their normal icon that starts the Access FE from the C drive and away they go.
I am trying to make these two icons/processes into one icon. So process would be:
Copy S:\MyApp\Compiled.mdb C:\MyApp\MyProg.mdb C:\Program Files (x86)\Microsoft Office\Office11\MSAccess.Exe C:\MyApp\MyProg.mdb
I put both of those lines in a BAT file and they both execute just fine, however a Command prompt stays open showing "1 files copied" which I know is from the first line of the bat file. Access then opens and person can work, but the command prompt window is still open. Once person quits out of Access, command prompt closes, which I know is because there are lines left to run in the bat file.
The above all makes sense, but I can't remember how to use either START or CMD /C or CMD /K, etc. to force the BAT file to close after it starts running Access so the person doesn't see the window. Or what other way can this be done (I'm know it is simple, just drawing a blank.) I know FMS has a tool to maintain FE Updates, but not sure how it works.
Thanks for any help - hope it made sense.
John
---
John Bodin
sBOR Office Systems
jbodin at sbor.com<mailto:jbodin at sbor.com>
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com
More information about the AccessD
mailing list