0

I am trying to run a .bat file with audit policy settings inside an azure vm. For this I used a terraform vm custom script extension to call a .ps file which calls another .2ndps file.

The .2ndps file includes just the following:

start-process .\setAuditPolicies.bat

However, the .bat file doesn't get run or audit policies doesn't get set.

Am I calling the .bat file wrong, within the powershell script?

Hinda
  • 27
  • 1
  • 7
  • 2
    `Start-Process` used like that should run your `.bat` file if it is in the current directory at the time the second PowerShell script runs it. The question is what do you mean it doesn't 'get set', what are you expecting to happen when you run the batch file? – Compo May 24 '20 at 21:01
  • Like @Compo said, you need to be in the directory the file is in or put the full filepath. For example, if the file is in `C:\Users\Neko\Testfiles` I should use `cd C:\Users\Neko\Testfiles` and then `start .\testfile.bat` or `start "C:|Users\Neko\Testfiles\testfile.bat"` – Nico Nekoru May 24 '20 at 22:57
  • 3
    …or `Start-Process -FilePath "P:\ath\to\setAuditPolicies.bat"`, or `Start-Process -FilePath "setAuditPolicies.bat" -WorkingDirectory "P:\ath\to"`. I'm going to assume that your issue is the the code within that `.bat` file isn't setting the audit policy and for that I'm assuming that you're using `secedit.exe` or `auditpol.exe`. For those you'll very probably need to run the batch file elevated. – Compo May 24 '20 at 23:28
  • @Compo and Neko thanks so much :) using the path to the file worked. I was trying to set Audit policies, I should have been more specific. – Hinda May 25 '20 at 23:47

0 Answers0