Hi everybody,
I created and manage an access database at work, and recently we've upgraded to Windows 10 / Office 365. I have 1 hurdle I am struggling to resolve and was hoping for guidance if anybody has time and would be so kind:
The database in question here is a split database. I have a batch file that creates a backup copy of both the front and back end. I built a command button on a form to call this batch. Perfect.
Now that we've been pushed to Windows 10 / Office 365, employees no longer have administrator privileges AND batch files are blocked entirely by company policy. I was told to rewrite my batch as a power shell script.
I learned powershell and rewrote my batch. Excellent. Long story short though, because we don't have admin priveledges anymore, every machine defaults to blocking scripts until you change the execution policy to bypass.
So, I can officially call powershell.exe, but the script won't open. What I, for the life of me, cannot figure out -- is: How do you pass MULTIPLE powershell commands through VBA? I'd like to set the execution policy every time the shell is called right before the script opens. I need to send the following commands during the VBA call line:
My code looks like this to call the shell:
'x = Shell("POWERSHELL.exe -noexit CD " & "'FILE PATH HERE'", vbNormalFocus)
This lets me pass the CD [Insert file path here] command through to powershell and change the directory. But I need to take this a few steps further. After changing the directory, I need to set the execution policy then run the script. Any idea what the syntax is to pass 3 separate powershell commands through VBA to a call to a single instance of powershell?
I created and manage an access database at work, and recently we've upgraded to Windows 10 / Office 365. I have 1 hurdle I am struggling to resolve and was hoping for guidance if anybody has time and would be so kind:
The database in question here is a split database. I have a batch file that creates a backup copy of both the front and back end. I built a command button on a form to call this batch. Perfect.
Now that we've been pushed to Windows 10 / Office 365, employees no longer have administrator privileges AND batch files are blocked entirely by company policy. I was told to rewrite my batch as a power shell script.
I learned powershell and rewrote my batch. Excellent. Long story short though, because we don't have admin priveledges anymore, every machine defaults to blocking scripts until you change the execution policy to bypass.
So, I can officially call powershell.exe, but the script won't open. What I, for the life of me, cannot figure out -- is: How do you pass MULTIPLE powershell commands through VBA? I'd like to set the execution policy every time the shell is called right before the script opens. I need to send the following commands during the VBA call line:
- set-executionpolicy -scope currentuser
- a
- ./backup.ps1
My code looks like this to call the shell:
'x = Shell("POWERSHELL.exe -noexit CD " & "'FILE PATH HERE'", vbNormalFocus)
This lets me pass the CD [Insert file path here] command through to powershell and change the directory. But I need to take this a few steps further. After changing the directory, I need to set the execution policy then run the script. Any idea what the syntax is to pass 3 separate powershell commands through VBA to a call to a single instance of powershell?