Remote Desktop Connection Manager - batch-file

I am using Remote Desktop Connection Manager 2.2
Do u guys know if there's a way to run a .bat/.cmd script (e.g. vpn script) before connecting to a VM?
I have a bat script to connect to Juniper VPN. I wish rdcman run it automatically before connecting so that I wouldn't have to run it every time manually.
Thank u.

You could start Remote Desktop Connection manager from the "VPN" batch file, by appending the following command to your batch file:
mstsc /v VMNAME
This will launch a session with VMNAME.

Related

How to launch pgadmin4 and open a sql file in windows cmd?

I would like to be able to open PGadmin4, connect to a server/database and open an sql file using only command line (Windows).
Is there a way to do that ?
Opening pg admin is fairly simple :
start "" /B "C:\Program Files\PostgreSQL\12\pgAdmin 4\bin\pgAdmin4.exe"
but I don't seem able to find a way to connect to the appropriate server/database and open the sql file I want
I'm writing a .bat file to automate the initial opening of a bunch of application for a development project (django)
Try running following command:
Connect to a specific database:
\c database_name;
For example, the following command connects to the dvdrental database:
\c dvdrental;
You are now connected to database "dvdrental" as user "postgres".
For other commands, visit: https://www.postgresqltutorial.com/postgresql-cheat-sheet/

Using PsEXEC via SQL Server agent job

I have a need to add a step (a batch file that needs to run on the application server) once my backup from db server is complete. I am thinking of using the PsEXEC. For whatever reason the command I am testing via the query window executes the batch file at the app server just fine but when I add the same command as step in SQL server agent job it is giving me the error "The process could not be created for step 1 of job 0x318474904D93B54A81BA8B1AEE891A13 (reason: The system cannot find the file specified). The step failed."
Here is the command line running just fine from the query window
EXEC XP_CMDShell 'psexec -accepteula -u domain\user -p psswordhere \appserverip -s -d cmd.exe /c "F:\MovefFilesTest\TheJob\MoveTest.bat"'
FYI: domain\user is local admin on both servers and the sql service and agent are running under this account. It is also a sysadmin on the sql server itself.
Your help is appreciated.
Also F:\ is a local drive on the app server. I am puzzled why it is working on the query window but not when added as agent job

PSExec to execute sql scripts in SQL server of Remote machine

How to create a batch file to connect to Remote desktop and launch Microsoft Sql server and run some scripts.
I tried creating a batch file to connect to using
#ECHO OFF
mstsc /v:"SERVERNAME"
But i was not able to pass username and password
Can anyone advise on this.
EDIT
psexec \\remotemachine-u username -p password ipconfig
Above one connects me to the remote machine and prints its Ip details.
Now I am trying to execute SQL script which is in D:\ of remote machine to execute in Microsoft SQL server (connection) in the remote machine.
Is that possible.
You can use MSTSC to create the connection, with credentials (be sure to check the box that says "Allow me to Save Credentials"), then save that information to an .RDP file
After you should be able to launch:
mstsc "MyConnectionFile.rdp"
In the connection configuration, there is also a tab: "Programs / Start the following programs on connection", which should get your scripts going.
In general, the issue is to set up everything via the GUI, save it to an RDP file, and use that file in the future.

How to run batch file on remote server

I am using 2 machine one local and other remote from local I have used SSIS package to execute batch file on remote server using wmi process but my problem is that batch file is executing locally instead of remote
Check out System Internals which was bought by Microsoft in the mid 200X.
I used the psexec command to run remote batch files via VB script. I am sure you can do the same with SSIS.
http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx
You need rights of course on the remote machine (RM1) and a local copy of psexec.
psexec \\RM1 cmd
This test code runs a command prompt on the remote machine. Parameters like user/pwd will have to be passed.
Good luck in you coding efforts.

restarting service on a remote server

I'm creating a .bat file to restart a windows service on a remote server. I did some research on this and found 2 ways of executing this.
1. Using NET START "service"
2. Using SC //server START service
My question is, how do i supply the username and password that's required to login to the remote server? TELNET accepts server and the username, but the password doesn't work.
Any pointers on this?
Got the answer! . Use this before using NET START or SC.
net use \\server password /USER:user
Verified..and it worked flawlessly!
More info here: Start And Stop Windows Service remotely using PSEXEC
For things like these I normally install an SSH server on the remote host: Bitvise has one that works wonderfully on windows called WinSSH (They have a free Personal Edition). You then use Putty to execute the command remotely.
I don't think Telnet can execute commands remotely without an interactive shell.
Another option is to use Powershell Remoting, but someone else will have to help on that.

Resources