Start a session in MobaXterm from batch script - batch-file

When I had Windows 7, the following batch command opened MobaXterm, and inside, it opened a new tab (in addition to the home tab) that connected to a VM ('linux-server'):
start "" "C:\Program Files (x86)\MobaXterm\MobaXterm.exe" -newtab linux-server
Now, in Windows 10, the command does not work well. It opens MobaXterm, but does not open a session to the VM.
I tried to run the command from command-line, the result is the same.
My requests are:
Opening a session to the VM in MobaXterm using batch command (the "home tab" that was opened in the past is unnecessary)
I use private key to connect this session, for some reason, Moba does not save the passphrase for the private key, only the user's password. I would like to save the passphrase as well.
Thanks in advance!

From the MobaTek Blog
MobaXterm.exe -newtab ["<Command>"]:
This command can be used to start a new tab inside a running instance of MobaXterm (or start a new instance of MobaXterm if no other instance is running) and immediately execute a given MobaXterm command
So you would need to specify a ssh command to connect to your virtual machine.
You could also save the ssh connection (or any other connection type) as a "first level" bookmark and use the bookmark-command instead:
MobaXterm.exe -bookmark "<Bookmark_name>":
This command can be used to start a bookmark by specifying its name.
In your case, the command would look like this, if your bookmark would be called "linux-server"
start "" "C:\Program Files (x86)\MobaXterm\MobaXterm.exe" -bookmark linux-server

I'm providing example usage for opening mobaxterm with specific command. Below is an example of opening a MobaXterm portable Personal edition in a newtab mode with SSH and a specified username.
MobaXterm_Personal_20.6.exe -newtab "ssh -l username 192.168.1.99"

Related

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.

Using WebDav & RoboCopy to copy docs between Document Libraries

I am trying to automate the process of copying documents between SharePoint 2013 document libraries using a RoboCopy job which calls WebDav.
Batch only works if first manual connection operation was conducted on the intranet. As long as the user's session is active, does it work .
This is the command I am running:
robocopy "Source" "Destination" "Log File" /MOV
And these are the error messages I'm receiving:
-Exception Message :Access Denied. Before opening files in this location, you must first add the web site to your trusted sites list, browse to the web site, and select the option to login automatically.
StackTrace : at system.IO.__Error.WinIOError(Int32, errorCode, String maybeFullPath)
at system.IO.Directory.InternalCreateDirectory(String fullPath, String Path, Object dirSecurityObj, Boolean checkHost)
at system.IO.Directory.InternalCreateDirectoryHelper(String Path, Boolean checkHost)
at system.IO.Directory.CreateDirectory(String Path)**
Any ideas how this can be done?
I had slimier issues with mapping network drives over the internet using WebDav in both Explorer and Robocopy: It would work after a user session was started and the username/password was entered, but it wouldn't save the passwords even when asked to, so would stop working at the next logon. The root cause was two-fold:
1) By design on Windows, You can't save webdav credentials to non-local sites (See this MS KB)
2) You need to add the URL to the local sites list.
As an attempted fix, try this:
1) Create a Multi String Value at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WebClient\Parameters called AuthForwardServerList
2) Add the URL's you are trying to connect to - using SharePoint, that may be a bit trickier for you to figure out than in my case, but as an example, here's the string I needed to enter:
https://*.[Website].com
http://*.[website].com
*.[Website].com
Optional: while in the WebClient Parameters, you may want to adjust FileSizeLimitInByte (To enable longer downloads before timeout) and [FileAttributesLimitInBytes][Can't link more than two URL's, but it's KB912152] (To support large numbers of files in a folder) - I set mine to:
"FileSizeLimitInBytes"=dword:80000000 (Hex)
"FileAttributesLimitInBytes"=dword:00989680 (Hex)
3) Open Internet Explorer, and click Tools, Internet Options
4) Click the Security Tab, then click Local Internet, then sites
5) Click Advance on local internet settings
6) Enter the full https URL of the site, and click Add, then click Close
7) Click OK, Click OK, then close Internet Explorer
8) Restart the WebClient Service
9) Open Windows Explorer, and click Map Network Drive
10) Pick a drive letter, Enter the folder as the URL, tick Re-connect at Sign-in, and tick Connect using different Credentials. Click OK.
11) Enter the username and password, and tick the remember my credentials box, and click OK
Hope some of that helps.

login to remote using "mstsc /admin" with password

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>

silverlight asking to install when it's already installed

Does anyone else have difficulty with this problem? SL is already installed on each of my browsers but, sometimes (not all the time), the browser shows the SL logo asking to install it. Is there a reason this happens even though the website works perfectly at times? When I re-load the page the logo usually goes away and solves the issue.
Thanks!
Often this is a version issue, in that if the silverlight app was compiled against a newer version than what is on your machine, you will get that SL logo. However that doesn't explain why a reload of the page solves your problem.
HKEY_CLASSES_ROOT\AgControl.AgControl does not have READ access fix
Run regedit (start->run->regedit)
Navigate to HKEY_CLASSES_ROOT\AgControl.AgControl (if you get a message that says "AgControl.AgControl cannot be opened. An error is preventing this key from being opened. Details: Access is denied." proceed to the "Taking ownership of the key" section)
Right click and choose "Permissions"
Click "Add"
Either add your windows username or your network username in the the "Enter the object names to select" and click "Check Names". Your name should take the proper format. If it does not try clicking "Advanced" and searching for your username. My windows username was the one I used.
Click OK
Select your new username in the top pane and in the lower pane (Permissions for ) check the Allow box next to Read.
Click OK
Check Silverlight installation in IE by going to http://www.silverlight.net/
Taking ownership of the key (If you're getting access denied errors while trying to set permissions)
You can download the following tool from microsoft to open an
instance of regedit as system:
http://technet.microsoft.com/en-us/sysinternals/bb897553
The following command line will open a "system" regedit:
psexec -s -i regedit
(Note: You have to execute this command line from an "administrator" command
prompt [right-click command prompt and click run as administrator])
Return to step 3 above

Resources