Messages Using Command prompt in Windows 7 - command-line

How to send message over network using command prompt in windows 7 ?

"net send" is a command using a background service called "messenger".
This service has been removed from Windows 7. ie You cannot use 'net send' on Vista nor Win7 / Win8.
Pity though , I loved using it.
There is alternatives, but that requires you to download and install software on each pc you want to use, this software runs as background services, and i would advise one to be very very very very careful of using these kind of software as they can potentially cause seriously damage one's system or impair the systems securities.
winsent innocenti /
winsent messenger
****This command is risky because of what is stated above***

Type "msg /?" in the command prompt to get various ways of sending meessages to a user.
Type "net send /?" in the command prompt to get another variation of sending messages across.

You can use the net send command to send a message over a network.
example:
net send * How Are You
you can use the above statement to send a message to all members of your domain.But if you want to send a message to a single user named Mike, you can use net send mike hello!
this will send hello! to the user named Mike.

Open Notepad and write this
#echo off
:A
Cls
echo MESSENGER
set /p n=User:
set /p m=Message:
net send %n% %m%
Pause
Goto A
and then save as "Messenger.bat" and close the Notepad
Step 1:
when you open that saved notepad file it will open as a file Messenger command prompt
with this details.
Messenger
User:
after "User" write the ip of the computer you want to contact and then press enter.

Related

Powershell how to run a external application and respond to it's prompts

From a Powershell script I would like to run another application, which in this case is a Java app, and when that app asks a question via stardard in prompt I would like PowerShell to give it a response.
The Java app don't accept this data via command line arguments 😥, instead it must be run interactively and expects responses to it's prompts. When run interactively the it goes through the following questions:
Question: Select your application? Answer: 7
Q: Are you sure? A: Y
Q: Online[1] or offline[2] A: 1
I've been able to get this to work automatically using 'echo' only for the first question via this script:
echo 7 | java -jar javaapp.jar
But attempts to get it to send to the subsequent prompts are ignored: commas between the options, `n [new lines] between the letters, or spaces, are all ignored.
Can anyone suggest an alternative way of doing this?
Thanks

Evince application on Windows 2012R2 RDP not printing

I have an Windows 2012R2 server. I connect to that server using RDP. When I start Evince.exe (a pdf viewer program) everything works fine, except for printing to the redirected printer. If I print, I get the standard printer dialog and it shows my redirected printer. When I print a pdf document using the redirected printer, I can see the job appearing in the printer queue for just a second and then disappearing again. But no printing occurs.
If I print to the Microsoft XPS printer, a .xps file is created properly. If I print a notepad using the redirected printer, it works fine. So the problem is purely with the redirected printer and Evince.
What could be the cause of this issue? I have tried to reset the printer spooler already using this in een elevated command prompt :
net stop spooler
DEL /F /S /Q %systemroot%\System32\spool\PRINTERS\*
net start spooler
But it still does not print. The Windows event logs show no errors or warnings.
Anyone have an idea how to solve this issue? Could it be a permissions issue?
Thank you for your reply. In the meantime I found that this issue is only with my personal account or pc. All my users can print using Evince and they have no admin privileges like me. The weird thing is, the print queue gets emptied on the server, but my pc does not receive the print job in the queue somehow. This only happens for Evince print jobs and not for any other print jobs. I tried to reboot both the server and my personal pc. There are no weird log entries on the server nor on my pc.
I tried to redirect another printer (Microsoft print to PDF printer) and that works fine. So the problem is with my HP laser printer. But why only for Evince print jobs??? I really have no clue what is causing this. Maybe my printer driver is corrupt somehow. I can try to reinstall my printer on my PC, maybe that will do the trick. I will try later this week because currently I am too busy to make time for this.
BR, Emphyrio

Opening a file in a Metro app from command line

I need a way to open a file in a Metro app from command line.
So far I've figured out how to start the app from command line without any third-party scripts
explorer shell:AppsFolder\Microsoft.Reader_8wekyb3d8bbwe!Microsoft.Reader
but I haven't been able to figure out how to include a file name yet.
Launching
explorer shell:AppsFolder\Microsoft.Reader_8wekyb3d8bbwe!Microsoft.Reader example.pdf
just opens up a default explorer window.
Any idea from Windows 8 experts on how to accomplish this without any third-party tools/cmdlets/etc.?
Note: In fact I'm using Windows 10 but I guess if there's a Windows 8 / 8.1 way to do it, it'll work for 10, too.
If you're still looking for the answer, the best way to open a file in a metro app is to use an execution string like a normal app protocol does. The execution string looks like this:
bingnews:[arguments, can be left blank.]
microsoftvideo:[arguments, can be left blank.]
netflix:[arguments, can be left blank.]
So, to start up netflix, it's as simple as typing in Start netflix: into the command line.
To find the execution string for an app, go here: Control Panel\Programs\Default Programs\Set Associations
More info and examples can be found here.
http://windowsitpro.com/windows-8/opening-windows-8-apps-command-prompt-or-script
http://www.itsjustwhatever.com/2012/10/28/launch-windows-8-metro-apps-from-a-desktop-shortcut-or-command-line/
PLEASE NOTE: To open an app WITHOUT A PROTOCOL (One not listed in the registry or under "Set Associations") use OP's method:
explorer shell:AppsFolder\[appuid]![appfullname]
The app UID is the folder name without the version number. For example,
4DF9E0F8.Netflix_2.11.0.8_x64__mcm4njqhnhss8
becomes
4DF9E0F8.Netflix_mcm4njqhnhss8
The app fullname is the [App author].[App name] For example, 4DF9E0F8.Netflix. 4DF9E0F8 is the author, and Netflix is the name.
Put it all together to get
explorer shell:AppsFolder\4DF9E0F8.Netflix_mcm4njqhnhss8!4DF9E0F8.Netflix
Store Apps can only be started by the shell. So try this:
explorer.exe shell:AppsFolder\Microsoft.WindowsAlarms_8wekyb3d8bbwe!App
Or from run (Win+R):
shell:AppsFolder\Microsoft.WindowsAlarms_8wekyb3d8bbwe!App
If the app is the default handler then you can just launch the file or protocol. There isn't a good in-box way to launch a file into a non-default handler from the command line.
Windows Store apps aren't designed to run from the command line and there isn't a straightforward way to launch them from the command line. Apps which handle specific files or protocols receive them through FileActivatedEventArgs or ProtocolActivatedEventArgs rather than command line arguments
You could write a launcher app which uses CLSID_ApplicationActivationManager's IApplicationActivationManager to ActivateForFile a specific app.
The best way I've found to pass command-line arguments to the executable targeted by the shell command is via the Windows start command.
Using your example, you would end up with this:
start "" shell:AppsFolder\Microsoft.Reader_8wekyb3d8bbwe!Microsoft.Reader example.pdf
I don't have Microsoft.Reader installed, so I can't test that. However, I can verify that this pattern works with Windows Terminal. In this case, I pass it a command-line argument to tell it which profile I want to open.
start "" shell:AppsFolder\Microsoft.WindowsTerminal_8wekyb3d8bbwe!App new-tab -p "GitBash"
The first argument to the start command here — the empty string — is just the title of the window.
You can also pair this with cmd /c, which I've found is necessary for some launcher applications, such as my personal favorite, SlickRun:
cmd /c start "" shell:AppsFolder\Microsoft.WindowsTerminal_8wekyb3d8bbwe!App new-tab -p "GitBash"
I have a blog post with more info on running Modern apps from the command line, which you might find helpful in constructing these ridiculously obtuse commands.
Not sure if it works on Windows 8, but on Windows 10 I use this:
cmd /C start <app-name>:
For example, to start Slack:
cmd /C start slack:

Restarting PC's and writing to the event log with a custom message

I have written a script in PowerShell that will remotely restart a list of PC's using the 'Restart-Computer' command.
Is there a way of adding a custom message to the systems event log, to explain that the computer has been restart by my script.
Here is the PowerShell code that I used to solve this problem as suggested by the user C.B. above.
Shutdown /r /f /m ComputerName /d P:0:1 /c "Your comment"
This code will force (/f) a shut down and reboot (/r) of a given PC and write to the event log with a custom comment (/c). Note that to write a custom comment a reason code will need to be supplied using the (/d) parameter. Also note that the order of parameters matters.
For a list of reason codes and syntax follow the links below.
http://ss64.com/nt/shutdown.html
http://technet.microsoft.com/en-us/library/cc732503(v=ws.10).aspx

Email an alert when sFTP connection cannot be reached?

I have a very small office environment, and my team sends created pdfs to an sFTP server daily.
Occasionally, I will get a call that someone can't log in to upload the files.
My normal course of action is to connect to the sFTP server myself, run a commmand like ls to determine it is responding.
I would like to be able to automate this with notification if there is a failure:
Login to the sFTP server (with credentials).
Run an LS command
Email if connection times out or login fails.
I have limited experience with writing Batch files, but I can't seem to figure a way to get only a 'failed' / no response to send an email.
Could anyone help with ideas? I'd like to run this as a VB or Batch in Scheduled Tasks, as I have a Server 2000 machine this could run on. I know batch has issue sending emails, but i have another batch file that uses Blat.exe to send an email with passed variables, so i could use that if i could get batch to send failed responses...
You should be able to do this with a batch file.
Create a file called logon.ftp. This file contains the FTP logon script. Mine contains:
open Ftp_server
ftpuser
ftppassword
ls -l
quit
The testftp.bat file:
ftp.exe < logon.ftp | grep "Not connected" > nul && call :alert_someone
#echo Logon successful
goto exit
:alert_someone
#echo %date% %time% > alert.txt
#echo ftp_server appears to not be taking logins. >> alert.txt
blat alert.txt -to you -from ftp_watcher -subject "alert %date% %time% ftp_server not taking logins"
:exit
You'll need to get blat, and grep so you can do the string checking. My winxp ftp doesnt support errorlevels, so I'm using the errorlevel returned from grepping the 'Not connected' string to figure out if this worked or not.
You can get wget or curl to do this as well, and they do support errorlevels.
Batch files can be a bit too basic for this kind of thing.
If you were able and willing to experiment with the Python programming language ( http://www.python.org ) and additionally install the Paramiko module ( http://www.lag.net/paramiko/ ) then it would be possible to write a script along the lines of...
import paramiko
try:
t = paramiko.Transport(('TheHostname', 22))
t.connect(username='MyUsername', password='MyPassword')
sftp = paramiko.SFTPClient.from_transport(t)
dirlist = sftp.listdir('.')
except:
print "It's Broken"
#Send e-mails and such here
that you could then schedule to run on a regular basis.