-2

Good day, please help with powershell script. I run PS Script with a monitoring tool that runs under the system account as a service. If I change to a user account, then one bat script will not terminate the process to be terminated.

I am writing a condition, if else. I need to run three bat files in a row in a powershell environment. 1bat terminates the process - run the bat and wait for completion 2bat executes compact database - run bat and wait for completion 3bat starts the process - done

But I need to run the last 3bat under the rights of another account, not under the system but under the user xxxxx

Can anyone advise how?

i know poweshell i will run the bat file. Some tasks will be performed. But they are executed under the account: SYSTEM

I tried to set the user in the bat file: psexec \a-81yt8j7opm4fb -u user1 -p userpass -d "C:\REPNET-WIN\RepNet97.exe" however, the process does not start this way

if i put in a bat file only: START C:\REPNET-WIN\RepNet97.exe the process starts, but under the SYSTEM account. I need another user: user1

This is how it behaves when the script is run via the nsc ++ client from monitoring.

If I run the script manually from the command line, it works without a problem. I ran the command line as an administrator, not user1 and also without a problem.

some idea?

My ps1 script: $fileToCheck = "C:\REPNET-WIN\Base\RepNet97.mdb" if (Test-Path $fileToCheck -PathType leaf) {Start-Process "C:\Scripts\test.bat";exit 1}

else {write-host ("WARNING: File RepNet97.mdb not found");exit 1}

esetman
  • 1
  • 1

1 Answers1

0

runas /noprofile /user:COMPUTERNAME\USERNAME "C:\MYBAT.bat" is a variant, but I don't know how to enter the password into the script

esetman
  • 1
  • 1