cmd.exe will not recognize command - vb.net

I have a vb.net application that runs cmd.exe as the following:
Dim Port1 = CreateObject("WScript.Shell")
Port1.Run("cmd.exe")
Port1.Sendkeys("telnet ip address")
Port1.Sendkeys("{Enter}")
System.Threading.Thread.Sleep(6000)
When the cmd runs the sendkeys a error shows
"'telnet' is not recognized as an internal or external command,
operable program or batch file."
I closed the cmd window, opened another cmd, and typed in the command with not problems.
I need cmd to run in the vb.net and not as a separate file.
Running the vb.net in Microsoft visual studio Ultimate 2013.
Update: Can anyone tell me why it is doing the same thing when i move the app to another computer and try to run it?

You have to enable telnet on the computer by going to start > control panel > programs and features > turn windows feature on or off > check telnet client or typing optionalfeatures in run and checking telnet client. The command should execute successfully after that.

Either Telnet is not installed on your computer (it's not installed by default on any modern Windows versions as far as I know), or it its installation directory not in the PATH environment variable.
Either add it's install directory to PATH, or specify the full path to telnet.exe in the arguments to cmd.exe.

CMD runs commands based off of System32 and .bat(batch) or .exe. You would have to create a .exe or a .bat and place it into System32 in order for the command to work.

Related

ssh : The term 'ssh' is not recognized as the name of a cmdlet, function, script file, or operable program

I have tried to connect to a server using ssh but I got the following error ssh :
The term 'ssh' is not recognized as the name of a cmdlet, function, script file, or operable program.
I have followed the tutorial from https://learn.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse#:~:text=Install%20OpenSSH%20using%20PowerShell.%20To%20install%20OpenSSH%20using,the%20following%20output%20if%20neither%20are%20already%20installed%3A
and managed to install OpenSSH.client and server but I get the same error when trying to run ssh.
I am running on Windows 10 Pro.
I have tried uninstalling OpenSSH and reinstalling it back, restarting the computer but nothing changed.
EDIT :
In a strange way, ssh started working the very next day. I guess the solution was to restart the computer after uninstalling and reinstalling ssh back.
Try first the same command in a new Powershell Windows, one which will inherit from the system changes you just did by installing OpenSSH for Windows
Make sure you do see a C:\Windows\System32\openssh\ssh.exe.
As mentioned in "OpenSSH Server Configuration for Windows 10"
First confirm that the OpenSSH installation folder is on the system path.
For Windows, the default installation folder is SystemDrive:WindowsDirectory\System32\openssh.
In my case, OpenSSH was installed properly and the folder structure was also ok.
However, the ssh syntax was not accepted. So, the solution was just to execute the ssh.exe as:
PS C:\WINDOWS\system32\openssh> .\ssh

Sysinternals psexec not running on the remote desktop

I've got two Remote Desktops hosted by a Hyper-V.
On Remote Desktop "A", I've got a .bat file, which I want to execute.
On Remote Desktop "B", I've got a cmd open with psexec cmd ready to invoke .bat file on machine "A".
"path-to\\psexec.exe" \\ip -u domain\username -p pswd -i cmd.exe /c "path-to\\myFile.bat %*"
The script contained in .bat file on machine "A" operates on the UI and thus requires a real screen to be open, so I am connected to two RDs simultaneously. However, when I call psexec command on machine "B", the cmd returns an error, but if I open RD "A" directly through the server's Hyper-V manager's interface, the psexec command works as expected.
Can someone explain please why this happens?
The UI of Windows runs on session 0. To run a program remotely that uses session 0, it will need to run as the System user (-s flag), and you can specify the session to use (-i flag). This answer has a few related tips too.

/sbin/nologin issue with msys2 on Windows 10

I have just installed MSys2 (https://msys2.github.io, msys2-x86_64-20150916.exe) on my Windows 10 computer.
Once installed, the terminal is launched. But as soon as I stop it and relaunch it, I get the error: "Failed to run /sbin/nologin: No such file or directory".
Any idea on what to do?
You should figure out why Bash is trying to run /sbin/nologin. Check your Windows home directory (e.g. C:\Users\Joe) for files like .bash_profile, .profile, and .bashrc. Inspect those files and find which one is calling nologin.
If that doesn't help, try creating an empty file in C:/msys64/sbin/nologin, or wherever you actually installed MSYS2. An empty file would be a valid shell script and run without errors.
If the error is non-fatal you might consider just ignoring it.

'netcfg.exe' is not recognized as an internal or external command, operable program or batch file." when call through vbscript

i am trying to execute netcfg.exe /U ms_pacer etc to uninstall some bindings to the network adapter. now everytime i pass the command through vbscript the command prompt throws an error saying 'netcfg.exe' is not recognized as an internal or external command, operable program or batch file.
if i put it in a batch file and double click on it it runs fine. but again if i execute that batchfile through a .run in vbscript it gives the same error. i read somewhere that it could be environment variable issue, but tried setting environment, looks good but the command keeps throwing the error again and again. tried it in powershell but no go, please someone guide.
Ok found the answer, when running a 32 bit compiled application which needs to access another native windows application there is a catch. though windows has provided a set of 32-bit set of native applications in a 64 Bit OS, but has not changed names of files, and have been relocated in another folder i.e. %windir%\SysWoW64\ , now everytime a 32 bit application tries to access c:\windows\system32 on a 64 bit, it gets redirected to %windir%\SysWoW64\, now if one wants to refer to 64 bit native application then do %windir%\Sysnative

Running batch file on parallels vm with command issued from host mac

I am trying to start a selenium grid node on a local vm (running Windows 7) by using a call from the command line on the host Mac.
The call merely tries to run a batch file on the vm.
When I run the batch file from within the vm, it executes correctly and the node starts, so I know that batch file works correctly.
The path I am using is correct, as I can run it from anywhere on the vm.
It is just that I can't seem to call it from the host Mac.
This worked at one point, but I wonder whether a windows security update might have screwed things up?
I've tried to clear every firewall I could find. I am running parallels 8 on a MacBook Air.
Here is the syntax I am using.
prlctl exec {parallels_vm_name} 'C:\Users\{user_name}\Documents\selenium\startIeNode.bat {IP_address_here}'
The quotes around your
'C:\Users\{user_name}\Documents\selenium\startIeNode.bat {IP_address_here}'
should end at after .bat.
The only reason for those quotes is for the path, not for the command itself. It should look more like:
'C:\Users\{user_name}\Documents\selenium\startIeNode.bat' {IP_address_here}
Otherwise the IP address is being set as part of the pathname instead of a parameter.
I have almost the same setup/use case that you describe: Win 7 VM on Parallels 8. I just set my system up to do exactly what you want.
create .bat file verify it works on VM
create windows shortcut to batch file
drag shortcut onto Mac desktop, folder, Dock etc.
launch batch file from Mac shortcut
In coherence mode, VM settings to enable launching Windows Apps from Mac enabled, Parallel tools installed
Because of the way things are passed in prlctl exec, commands need to be executed double-slashed, so it would be:
prlctl exec {parallels_vm_name} "C:\\Scripts\\myScript.cmd"