How to run elevated as different user in AutohotKey? - windows

I try to run osk as a different user in AutohotKey.
RunAs, MyUser, MyPassword
Run osk
=> The requested operation requires elevation, so changed to
RunAs, MyUser, MyPassword
Run *runas osk
=> System verbs unsupported with RunAs
I have checked on this and the forum says I need to install AutohotKey with UAC on, which I did. But still no luck.
Any ideas?
Private remark, related to my post on SU

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"

PsExec works only with "runas /netonly", not with -u and -p parameters

What I mean:
If I...
run runas /netonly /user:computername\username cmd
enter the password for the local admin account "username"
then type psexec \\computername cmd
I now have a working shell and can run commands as the local admin user on the remote machine.
However, trying to run this without the runas... and instead with the username and password arguments of psexec returns an access denied error.
Example below:
psexec \\computername -u username -p password cmd
Access Denied
Note: Others seem to also have this issue. My refined questions:
Is this intended behavior?
Why even have the -u and -p?
I have also tried disabling the firewall on both my machine and the target machine, and adding the registry key listed here.
When you initiate a connection with PsExec.exe, it tries to use the credentials you are currently authenticated with to copy the PSEXESVC to the \\$machine\ADMIN$\System32 share VIA SMB, which enables the communication with your PsExec.exe and the $machine's service.
If your currently logged in user account does not have access to \\$machine\ADMIN$\System32 and the ability to install/start services, then this won't work.
I'm assuming if you have access with your user account that this would work.
Here is a very interesting article from 2004 on reverse-engineering of the original implementation. I am pretty sure it has changed in that time with Windows 7 & Windows 10.

How to initiate my exe file from administrative command prompt

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.

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.

How to run batch file as an elevated user?

I have a batch file that creates another user using this code:
net user /add TheAccount passWORD
net localgroup administrators TheAccount /add
And I did this so that my program would later run commands elevated without the UAC popping up, because it could use its own account...
But I hit a roadblock when I noticed that RunAs doesn't allow elevation.
I really need to be able to run a program elevated without any third-party tools that I would have to include.
Thanks in advance.
Thanks for all the help, but I found an answer with Microsoft Psexec.exe with the -h option or the
-s option.

Resources