Hyperlink call from within Access

Keith B

New member
Local time
Today, 12:50
Joined
Nov 29, 2021
Messages
8
I am trying to run a POWERSEHLL script from within access. The script is called from a .BAT file, whihc, if run from Winfdows operated happily. There are 2 lines in the .BAT file, as follows:

SUBST T: C:\TRAFFIC
POWERSHELL T:\AMGBACK.PS1

Following is the line in the Access Event Procedure

Application.FollowHyperlink "T:\BACKUP.BAT"

The SUBST command runs happily, but not the POWERSHELL command.

Any suggestions??
 
Use Shell ?
Can't understand why SUBST (which is a Command Call) works but POWERSHELL does not. Both work when the BAT file is executed by a Windows button.
 
Can't understand why SUBST (which is a Command Call) works but POWERSHELL does not. Both work when the BAT file is executed by a Windows button.
Nor do I without some research. I was just suggesting a possible alternative which I thought was what you were asking?
Perhaps because SUBST is a internal command and POWERSHELL an external command?
 
Last edited:
Nor do I without some research. I was just suggesting a possible alternative which I thought was what you were asking?
Perhaps because SUBST is a internal command and POWERSHELL and external command?
OK thanks for your input. Tried SHELL but same result. Get a message saying cant find file or similar. Only on screen for millisecond.
 
OK, so give the full path of the powershell exe?

Edit: So I was on the right track? re internal/external commands?
You would need to supply the full path for the exe or add it's folder path to the path environment variable?
 
Last edited:
OK, so give the full path of the powershell exe?

Edit: So I was on the right track? re internal/external commands?
You would need to supply the full path for the exe or add it's folder path to the path environment variable?
POWERSHELL is not a .exe application. It is a Command function called from the Command line. Similar to SUBST.
 
@Keith B
No - you have an extra \ after the T: in your original post. Hence the query regarding the file spec.

You have
POWERSHELL T:\AMGBACK.PS1

I suggested
POWERSHELL T:AMGBACK.PS1 (or even a different expression) - as you are getting a file not found/path not found error

put a pause or whatever the DOS command is, in the batch file, so you can read the response.
 
Hi Keith. It may be possible that you'll need to elevate the user or the VBA process permission to admin to run Powershell. Just a thought...
 
@Keith B
No - you have an extra \ after the T: in your original post. Hence the query regarding the file spec.

You have
POWERSHELL T:\AMGBACK.PS1

I suggested
POWERSHELL T:AMGBACK.PS1 (or even a different expression) - as you are getting a file not found/path not found error

put a pause or whatever the DOS command is, in the batch file, so you can read the response.
OK I understand what you are saying.

Tried removing the '/' but still same response, saying cannot find target file "POWERSHELL"
 
OK I understand what you are saying.

Tried removing the '/' but still same response, saying cannot find target file "POWERSHELL"
Hi Keith. Did you see my post? I could be wrong, but I thought PowerShell requires admin rights to run.
 
Hi Keith. Did you see my post? I could be wrong, but I thought PowerShell requires admin rights to run.
Hi. Powershell runs when I initiate from the .BAT file but fails - see below - when the.BAT file is called from within ACCESS. As the script runs when called direct from the .BAT file I believe that the problem is something to do with ACCESS ability.

T:AMGBACK.PS1 : File T:\AMGBACK.PS1 cannot be loaded because running scripts is disabled on this system. For more
information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ T:AMGBACK.PS1
+ ~~~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
 
Hi. Powershell runs when I initiate from the .BAT file but fails - see below - when the.BAT file is called from within ACCESS. As the script runs when called direct from the .BAT file I believe that the problem is something to do with ACCESS ability.

T:AMGBACK.PS1 : File T:\AMGBACK.PS1 cannot be loaded because running scripts is disabled on this system. For more
information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ T:AMGBACK.PS1
+ ~~~~~~~~~~~~~
+ CategoryInfo : SecurityError: :)) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
I was thinking when you run the batch file manually, it uses your admin rights. But when Access runs the batch file, it uses the VBA process/thread persmissions, which may not have admin rights. Just a thought...
 
That suddenly smells of a security/permissions problem. Is that a trusted folder? OR can you MAKE it a trusted folder? OR can you move the file to a trusted folder and run it from there?
 
Can you please confirm for us that you have admin rights? Thanks.
 
I was thinking when you run the batch file manually, it uses your admin rights. But when Access runs the batch file, it uses the VBA process/thread persmissions, which may not have admin rights. Just a thought...
Thanks theDBguy - that is the most logical explanation for the failure. I'll pursue that with our support company.
 
Hi. Powershell runs when I initiate from the .BAT file but fails - see below - when the.BAT file is called from within ACCESS. As the script runs when called direct from the .BAT file I believe that the problem is something to do with ACCESS ability.

T:AMGBACK.PS1 : File T:\AMGBACK.PS1 cannot be loaded because running scripts is disabled on this system. For more
information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ T:AMGBACK.PS1
+ ~~~~~~~~~~~~~
+ CategoryInfo : SecurityError: :)) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
I had that when I directed output to a text file to see if any issues were occurring.
However I also use Powershell to create restore points and system images, and they work fine.

As CJ_London indicates, could be permissions?
 

Users who are viewing this thread

Back
Top Bottom