Run a program from command prompt as a different user and password - windows

How do I run a program from command prompt as a different user and password
This command not good :
runas /user:test cmd
Enter the password for test:
I need a single line order, whit password included
Thank you

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"

Can't force psexec to use the given user account

I used to use runas for running my app under another user account. Now I need to pass the password through as well. I found that psexec is an easy way to do it.
So the batch file contains:
#echo off
psexec my.exe -u hostname\user -p password
The problem is my.exe is still being initiated under the user I'm currently logged onto the system with and not under the one declared in the cmd above.
the program must be the last argument
try this :
psexec -u hostname\user -p password my.exe

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.

run command as other user in unix shell script csh

Assume I am user A(not root user) and I want to run a c-shell script which will execute command in User B(password for B is known to me) and will use the result of that command here.
How can I run a command in User-B.
sudo -u username command1
Above command may prompt for password but I want this to be done in script only.
Thanks for all your suggestions.
you could use a ssh key to allow your user A to log in as user B using user A's private key (and with user A's public key in ~B/.ssh/authorised_keys)
then you simply execute the script as B with:
ssh B#localhost "/path/to/script and maybe some arguments here"
you have following options,
run your command with root so that su - username wont prompt for password
create passordless login for user like passwordless ssh,remove password for user etc. and then run your command
for getting output here to work,
write it in a file and access it in code
store it in a variable and access it in code

Single line command for Run as a different user on Windows 7 that contains a password also

Is there any single line command for Run As Different User in Windows 7.
I am using following command but then it ask for password
runas /user:USER-NAME "C:\full\path\of\Program.exe"
Is there any way to supply password also in above line ? Actually i am launching application from other application so I don't want any user interaction But in above command it ask user for PASSWORD
PsExec in the MS SysInternals suite:
psexec -user Administrator -p Passwd "xcopy a.xml \\server_over_there\c$\A.xml"
In case the local user is NOT what you need and a specific DOMAIN user is, use:
/user Username in form USER#DOMAIN or DOMAIN\USER
(USER#DOMAIN is not compatible with /netonly)

Resources