How can I log in to my administrator account with cmd? - windows

I have a Windows Server 2012 and want to log in to it remotely.
I know that this possible with the Microsoft Remote Desktop program, but I want to do this with cmd, so that im able to create a script. So far I've build up a ssh connection to my server and I'm able to access the command-line tool but I'm not able to start my desired program. It's telling me that I'm logged in with the "LocalSystem". So my question is, how can I log in to my administrator account with cmd?
Edit:
Basically I want to login with my credentials in my own script.

Related

How to resolve re-login to Remote Desktop Client with Remmina?

I used Remmina to join to remote windows server
But I have a little problem
once I close remote windows, I cannot go to remote windows server again with remmina
for resolving this problem, I have to open Vmware and open "browser console" and login to windows server
enter image description here
and with this activity, my log and cache clear and I can log in again
Now my question is: How can I resolve this problem and close and open repeatedly my windows server in remmina
Notice: I don't have this problem on Linux server with remmina and this problem occurred in windows server with remmina
I resolved this problem
we should use this command in CMD to resolve problems like this
net user administrator /active:yes
then, you have to see users list and if you have two different users remove one of them, for example, if you login with Administrator user, remove another username and reboot your system
thanks for watching this question

Windows 7 login without credential prompt using powershell

I'm trying to automate a task using powershell and I need the computer to restart multiple times. I'm doing this by scheduling a job that runs at startup that executes different scripts, and after that I use Restart-Computer to reboot the pc.
My problem is that I want it to be completely autonomous, but right now I need to input username and password at startup to access my profile. I know that if there is a single user on the machine and if it doesn't have a password it gets logged in automatically, but there are two users on the machine. Is there a way to automatically login after a reboot to a pre-selected windows account with powershell? Thanks
EDIT: I also have to execute programs that have a GUI, so I need authentication anyways.

How can i run an autoit script on Windows server 2016 without the remote desktop turned on?

I have a script that i want to run on a windows vserver (windows server 2016)
but when i close the remote desktop the script doesn´t continue. Is there any way that i can make this script run on that server? Thanks in advance
From your question i assume it is a task that has to run in the background and you do not want to start/stop it frequently, you could register your script application as a service using sc.exe. Take a look at the syntax here.
Note:
You will need administrator privileges for register, so you need to be admin to start and stop a service or an admin have to grant these permissions if it is possible in your case.
You can run your script by Task Scheduler. Create new task and mark these options: "Run whether user is logged on or not", "Do not store password", "Run with highest privileges".
Also you can try to use Psexec tool from PsTools package for remote start.

Start a service from a webapp with administrator privileges passing by a batch file

I'm working on a monitoring app that is running on a vm and I want my colleagues to be able to use it without connecting on the vm. It works fine but I have one problem.
One of my goals is to start/stop services using a batch file or a cmd file (using Class Runtime in my back). The problem is that I need the administrator privileges to do that. All the methods I found (as Runas or some batch files) only works if the user is on the vm and enter the password or click on the "do you want to run this application as administrator" pop up. I would like to not use the task scheduler to always start cmd as an admin. I already know you can use softwares as "Sanur" but I prefer not to.
The only way to make it works is to start the app as an admin and it works fine (I'm using the "net start/stop" command). But I would like to let everyone start this app (in case I'm not here).
It's not a problem to write the login/password in the file.
Is there a way to do so?
The vm runs on Windows 7.
Thank you in advance.
You don't need to be Administrator to start and stop a service, you just need the privilege. With Windows 7 Professional you can do this through the built-in group policy editor.
With Windows 7 Home, there is not policy editor.
I use a tool called SetACL to do this, e.g:
setacl -on "service-name" -ot srv -actn ace -ace "n:betrand;p:start_stop"
Where "service-name" is the name of the service, and betrand is the user which you want to allow to start and stop the service.
A complete list of options is available on the website:
https://helgeklein.com/setacl/documentation/command-line-version-setacl-exe/
Another option is the SubInACL tool directly from Microsoft.

psexec inside visual studio

I've been trying to get psexec to run executables on remote machines from custom build tasks in visual studio. All of these commands work from the command line but running it from an application seems to be a problem. Some commands work, on other psexec hangs and consequently so do msbuild and visual studio 2005. I'm calling SharePoint's stsadm.exe in this case, but this problem occurs with a lot of programs, when running psexec from an application. There are lots of people having this problem, but there seems to be no solution, so my question is: Does anyone know a working alternative to psexec?
I've experienced 'hangs' when executing PSEXEC against a remote system, but I always attributed it to the security context in which the remote process was running under.
From PSEXEC help:
If you omit a username the remote
process runs in the same account from
which you execute PsExec, but because
the remote process is impersonating it
will not have access to network
resources on the remote system. When
you specify a username the remote
process executes in the account
specified, and will have access to any
network resources the account has
access to. Note that the password is
transmitted in clear text to the
remote system.
If your executing a process remotely, that then needs to access the database (stsadm.exe), then it could be failing trying to access the network resource, depending on how PSEXEC was executed. If thats the case, I'd imagine it would eventually time out and give some sort of resource unavailable message.
There are two things that generally done when executing deployment steps against a remote machine to prevent the behavior your describing:
Like rifferte mentioned, make sure all assets needed to
deploy are local to the remote
machine (copy files, etc) before
using PSEXEC to execute the script (*.bat, *.vbs, *.ps, etc) -
so that everything runs 'local' to
the remote machine.
Run PSEXEC using
a domain username/password when
executing it - note that this
information is passed in clear text
to the remote server.
There's always RCE.
RemCom is a small (10KB upx packed)
remoteshell / telnet replacement that
lets you execute processes on remote
windows systems, copy files on remote
systems, process there output and
stream it back. It allows execution of
remote shell commands directly with
full interactive console without
having to install any client software.
On local machines it is also able to
impersonate so can be used as a silent
replacement for Runas command.
You can try to have psexec call a bat program that executes what you need on the remote machine. I ran into this issue with installutil.exe. A simple bat file on the remote machine resolved it.
You should also share your experience on the sysinternals board. There may be something they can do in a future revision.

Resources