login to remote using "mstsc /admin" with password - batch-file

I want to use mstsc /admin to login to a server silently. My batch file reads the code as
mstsc /v:xxx.xxx.xxx.xxx /admin
But it ask me to enter password. Can anyone help me to skip this step?
I went on to Google and found this site. But I am very new to this stuff (scripting) and could not understand what to do with given code. Is it a vbscript file? Can I do the same thing with a batch file. Please elaborate and I request you to spoon feed. This is not my arena but still I am pushed to fight without weapons.
My basic need is to kick off all users from a remote desktop except mine to perform some maintainable work. Thanks.

Re-posted as an answer:
Found an alternative (Tested in Win8):
cmdkey /generic:"<server>" /user:"<user>" /pass:"<pass>"
Run that and if you run:
mstsc /v:<server>
You should not get an authentication prompt.

the command posted by Milad and Sandy did not work for me with mstsc. i had to add TERMSRV to the /generic switch. i found this information here: https://gist.github.com/jdforsythe/48a022ee22c8ec912b7e
cmdkey /generic:TERMSRV/<server> /user:<username> /pass:<password>
i could then use mstsc /v:<server> without getting prompted for the login.

to be secured, you should execute 3 commands :
cmdkey /generic:"server-address" /user:"username" /pass:"password"
mstsc /v:server-address
cmdkey /delete:server-address
first command to save the credential
second command to open remote desktop
and the third command to delete the credential for security reason
all of these commands can be saved in a batch file(bat).
(if you save these command in a batch file, third command will not be executed until you close the remote desk)

Same problem but #Angelo answer didn't work for me, because I'm using same server with different credentials. I used the approach below and tested it on Windows 10.
cmdkey /add:server01 /user:<username> /pass:<password>
Then used mstsc /v:server01 to connect to the server.
The point is to use names instead of ip addresses to avoid conflict between credentials. If you don't have a DNS server locally accessible try c:\windows\system32\drivers\etc\hosts file.

It became a popular question and I got a notification. I am sorry, I forgot to answer before which I should have done. I solved it long back.
net use \\10.100.110.120\C$ MyPassword /user:domain\username /persistent:Yes
Run it in a batch file and you should get what you are looking for.

Save your username, password and sever name in an RDP file and run the RDP file from your script

The Command mentioned above didn't work for me (Windows 11)
cmdkey /generic:"server-address" /user:"username" /pass:"password"
When i listed the cmdkeys using the commad:
cmdkey /list
I saw, that a legacy target was added. Adding a specific TERMSRV-Target worked for me:
cmdkey /add:Domain:target=TERMSRV/<SERVER> /user:<DOMAIN>\<USER> /pass:<PASSWORD>

Related

Call webservice from batch file calling in scheduled task

It's several days I search for a problem. I've create an Intranet (Authenticate mode windows allow member of domain) and I a webservice can be called by asmx file
I create a bat file to be use in scheduled task
#echo off
start /MIN iexplore.exe http://server/WS.asmx/Importation
Timeout /T 80 /NoBreak>NUL
taskkill /F /IM iexplore.exe /T
Until now it was good. But from severals days now I don't see the calling asmx correctly (I create a log file and it's empty.
When I call this WebService from my Intranet : it's Ok
I notice now when I run my batch file manually it's ask me a username and password
I look several sample but don't find the good option.
Why Ask me a password when my task have the goods credentials. And How open this asmx with a username/password from scheduler?
Thanks for your help
Finally, I found a way...
In Internet option u have a checkbox "activate the protected mode" uncheck it
And I add my Intranet to Intranet Site
Like this server isn't use directly (only resquest by Excel) and like it's inside protected struture. The risk are very limited.
I hope that can help

Azure Active Directory Server 2016 Group Policy Startup Applications (Chrome) not loading on client workstations

Hi I'm trying to implement a Group Policy in our domain that forces Google Chrome to be added to client startup applications. I've added a GPO and added the key:
Computer Configuration > Administrative Templates > System > Logon > Run These Programs at User Logon
In the "Items to run at logon" I've added the path to chrome.exe (with quotes) like so:
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
I've then linked to the Object in our Domain's User and Computer OUs.
I've also pushed the update out to clients and confirmed they have updated GP.
However Chrome does not start when users boot into their laptops.
I'm hoping someone can shine a light on what I've done wrong/what I've forgotten to do - any help much appreciated!
Summarize the comment link as a reply to close this issue.
Per duenni1's comment it looks like the most successful way people are reporting is to use the startup folder instead of the logon group policy. "In my opinion the correct solution: use GPP to manage shortcuts in startup menu folder. Simply create a startup shortcuts."
Could throw it in this directory:
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup
This will launch the program when they login, we do this to force users into our IM client
https://community.spiceworks.com/topic/1369848-run-these-programs-at-user-logon
If you really want this method to work, I'd start troubleshooting here:
1) is there already a GPO in place that will perform Run These Programs at user logon? That may be the winning GPO
GPO Run these programs at user logon not taking effect
2) According to the official docs, no error is a path issue ( I think your usage of quotes is correct but out of curiosity I'd be curious if removing the quotes has a change).
NOTE: If the program does not run, make sure the path is correct. The program does not run (and no error message is displayed) if the path is not found.

Pre populating host, username, and password for WinSCP login using .cmd file

I have created a .cmd file that allows the user to select a number that corresponds to a different set of login credentials for WinSCP thus eliminating the need to memorize login credentials for WinSCP.
In my .cmd file I have set host, username, and password according to the following:
SET UID=exampleusername
SET PWD=examplepassword
SET HOST=examplehost
I then proceed to call WinSCP using
start WinSCP.exe
This opens the login interface:
The WinSCP interface is called correctly but I am having issues coding in my .cmd file to populate the Host Name, User name, and Password fields using the variables defined in my .cmd file.
You cannot populate the WinSCP login dialog from a command-line.
All you can do is to have WinSCP open the session directly by calling it like:
start WinSCP.exe sftp://%UID%:%PWD%#%HOST%/
References:
Opening a session from a command-line
Session URL syntax
Anyway, I do not see why you implement batch-file menu for opening sessions on WinSCP. Did you consider pre-configuring stored sites for WinSCP instead?
Btw, you are using some really ancient version of WinSCP (5 years old at least). You need to upgrade urgently.

Deleting files within a directory through remote 3rd party service

I am trying to use a service called LogMeIn to delete folders within a user profile's directory. When run locally, this obviously works. Very simple, as I am fairly new to batch files.
pushd %homepath%\Tracing
Echo Y | DEL *.*
Now, where I run into the problem is when I run it through LogMeIn. This service is for deployment and sends it to all the machines linked to it. It has me put in credentials that will work on all of the machines (network admin) so it can deploy the batch file and there is no way to work around it. Instead of going to C:\Users\tirefire, it now goes to C:\Users\Admin. Any thoughts as how to efficiently navigate to the desired user profile that is currently logged in? Every system is identical. Windows 7 Service Pack 1.
Couldn't find anything online regarding this issue directly. Thanks in advance!
Logmein will only log onto the profile that you have setup to access that computer. For example if your credentials are admin/pass you will get the admin profile, for tirefire/pass you will log on as TireFire.
Prior to logging in you will not be able to see who is logged in.
This is not the answer your looking for but it is the limitation of the software.
You could use a batch like:
CD..
FOR /D %%P IN (*.*) DO DEL /S/Q %%P\TRACING\*.*
This will look in the folders under c:\users (/D) and assign all user folders to the variable (%%P) and delete (DO DEL) anything in the tracing folder (%%P\TRACING*.*) for all users on the machine.
Source: I use logmein daily to log onto machines that we service.

bulkupload without username/password prompt

I have a process which generates daily some data, which I would like to update to a java app running on the appengine using bulkupload, using the command:
appcfg.py upload_data
--url=http://your_app_id.appspot.com/_ah/remote_api --kind= --filename=
It works perfectly, but it always asks me for my username/password.
Is there any way to save the credentials, use certificates, to avoid the username prompt?
Add these options:
--email=
--passin
and at the end : < "your password file.txt"
Seems this technique no longer works with SDK 1.9.17. The updated docs include some new oauth2 command line options, but the instructions are rather confusing. Anyone able to use either the old passin or the new oauth2 techniques? How?

Resources