How to initiate my exe file from administrative command prompt - windows

I have logged in with one user in my system. Like, userA. Now, I have opened command prompt window with administrator privileges. In same Administrator command prompt window need to run my EXE file for userA without the password.
I have tried "RunAs" command but it will ask for Password.
Is there any other alternative, where I can solve my problem.

I have logged in with one user in my system. Like, userA.
Ok...
In same Administrator command prompt window need to run my EXE file for userA without the password.
So you are already logged in as userA why would you need to enter the passsword again?
If you need to run something as as a different user you can create a batch file and set up a scheduled task to run it with their credentials, but don't actually give it a schedule. When you are then logged in as a differnt user you can call the scheduled task and it will run as the user it is associated with.

Related

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.
Using this command works for me:
powershell.exe "Start-Process powershell -verb runAs"

Make an ordinary user an admin using a script ( mac )

How can i generate a script that will open up the terminal, login to the local admin account using username and password then make the non-admin user an admin. Like this link where its done manually but i want it done using a script.
I'm not sure if the terminal will take a password or username from a script, if not could someone tell me? obviously the script wont be possible then.

Entering the password in cmd on Windows Ruby

I'm trying to run runas command in Windows but it asks about password. I use system('runas /user:username cmd') but it needs entering the password manually. Is there any possibility to enter automatically this password in my ruby script? Saving password in any file is forbidden.
--edit: ReggieB suggested to add some more information.
I'm writing a fact for Puppet. We have puppet agents installed on local Administrator accounts and local Administrator can't have access to information about domain users. Because of this I decided to run cmd as domain user that can have access to domain users. The problem is that runas command needs to manually enter the password. It's impossible to do this in facts so I need some method in Ruby that will do this automatically. I need to do
system('runas /user:username cmd')
and some method that enter the password in command prompt instead of me.

executing a command as an administrator in a single line

is there a single line command wherein I can run a command as an administrator from any non-admin account to create a new user using the administrator username and password?
I think you're looking for sudo.

Automatically run as administrator programs on Windows

I want to run some program with other domain users. For example;
Program: X
My domain : Y
Other domain user: Z
I tried " runas /u:Y\Z X " but always I have to enter other domain user password. I want to enter password only one time then program should run same user and password without ask password.
Thanks
create a batch file or similar in a start-up folder with the contents:
runas /user:domain\admin C:\Path\To\ProcessExplorer.exe
Before rebooting, run
runas /savecred /user:domain\admin C:\Path\To\ProcessExplorer.exe
It will prompt you for the password only this one time; note that the admin password will be saved to your Windows profile (not usually a good idea); and this does not work for Win7 Home or Starter editions.

Resources