Search code examples
windowsrunas

How to run 'runas` program in Windows as administrator without password


I have a Python code that finally generates a file and it should automatically run that file as admin. I did search and found that I should use runas program, but it requires admin password.

Since I have not set any administrator password, so it should not ask for password in order to work.

The script is route add -p IP to change routing table.

There are multiple PCs in the office and all PCs have one user like saeed, david, etc. and administrator of course which has not been used yet.

The command I use is the following that asks for admin password:

C:\Users\Saeed\Desktop> Runas /profile /user:administrator ips.cmd
Enter the password for administrator:
Attempting to start new-ips.cmd as user "DESKTOP-9PR0R3P\administrator" ...
RUNAS ERROR: Unable to run - new-ips.cmd
1326: The user name or password is incorrect.

Is that possible to run run as passwordless?

I should mention that if with my current PC, I right click on ips.cmd and Run As Administrator, it does not prompt any password and runs the file.


Solution

  • Using this command works for me:

    powershell.exe "Start-Process powershell -verb runAs"