Try this:
runas.exe /savecred /user:administrator "%sysdrive%\testScripts\testscript1.ps1"
It saves the password the first time and never asks again. Maybe when you change the administrator password you will be prompted again.
More Related Contents:
- PowerShell The term is not recognized as cmdlet function script file or operable program
- Need to extract value of attribute from xml from Command promt [closed]
- Different behaviour and output when piping in CMD and PowerShell
- Running a powershell command using full path and arguments from command line [duplicate]
- Watch file for changes and run command with powershell
- CMD pipe different form Powershell pipe?
- Escaping the and (&) sign in Powershell
- How can I run a PowerShell script with white spaces in the path from the command line?
- How to run an installation in /silent mode with adjusted settings
- Running CMD command in PowerShell
- CMD or Powershell command to combine (merge) corresponding lines from two files [duplicate]
- this code my teacher gave it to us as homework and it does not work with me idk why
- In what scenario was Invoke-Expression designed to be used?
- How can I write/create a powershell script verbatim, from another powershell script?
- How can I replace every occurrence of a String in a file with PowerShell?
- How do I pass variables with the Invoke-Command cmdlet?
- Loop through files in a directory using PowerShell
- FORFILES date -after- (date calc in cmd file)
- Any way to double-click on .PS1 file & open them in PowerShell?
- Set-Content appends a newline (line break, CRLF) at the end of my file
- Progress during large file copy (Copy-Item & Write-Progress?)
- How remove accents in PowerShell?
- Is there a way to pass serializable objects to a PowerShell script with start-process?
- How to use PowerShell copy-item and keep structure
- How to download the SSL certificate from a website using PowerShell?
- Rename file on FTP with PowerShell
- Is there an alternative to GUID when using msiexec to uninstall an application?
- PowerShell Capture Write-Host output
- Is there a PowerShell equivalent of `paste` (i.e., horizontal file concatenation)? [duplicate]
- Getting “Can’t find the drive. The drive called ‘IIS’ does not exist.”