Win XP: If NET SEND is disabled, is there still a way to send messages across network via cmd? - windows-xp

I'm working on a project that will popup on a logged in network computer, but hit a stall when I realized that NET SEND isn't enabled on the network. Is there another viable option (assuming regular user privileges on the network)?

Net send doesn't exist anymore since Win XP.
I've done some research recently and this is the alternative I found:
MSG.EXE
usage: msg /server:servername *(=all sessions) /time:timeout message
If you get an "error 5" you need to change this registry key on the receiver's computer:
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server]
"AllowRemoteRPC"=dword:00000001
(I don't know if AllowRemoteRPC is also used for other things, so use at own risk)
If you still get an "error 5" you need to add the receiver's credentials to the sender's Credential Manager, under "Windows Credentials"
This is an easy-to-use batch file I made for the use of MSG.exe
#echo off
:server
cls
set /p server=Computer name of receiver:
:delay
cls
set /p time=Message time-out (sec), 0 is none:
:start
echo Enter "exit" to stop. "Delay" to change delay. "Receiver" to change receiver.
set /p message=Enter message:
if "%message%" == "exit" goto stop
if "%message%" == "delay" goto delay
if "%message%" == "receiver" goto server
cls
msg /server:%server% * /time:%time% %message%
echo Message sent: %message%
goto start
:stop
Hope this helps!

Related

Exit Telnet Through Batch File

I've been asked to write a script in work that will send an email to our support email if an IP stops allowing us access to telnet on port 23. I've got the gist of what I need, but when the IP doesn't deny access, the script opens telnet and I can't get it to close using a command in the batch file.
This is what I've got so far. Sorry if there is already a question which answers this, I haven't been able to find it.
#ECHO OFF
set IPADDRESS=1.2.3.4
set INTERVAL=5
telnet %IPADDRESS% 23
if errorlevel 1 GOTO LOG
:LOG
ECHO %DATE% %TIME% %IPADDRESS% Could Not Be Reached >> failurelog.txt
GOTO MAIL
:MAIL
blat -install smtpserver
blat failurelog.txt -to email -subject "%IPADDRESS% Is Down"
timeout %INTERVAL%
exit

Messages Using Command prompt in Windows 7

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.

Need to run a powershell script every time system wakes up from Sleep

I just finished writing a script with PowerShell and I need it to run every time my system wakes up from sleep or Hibernation.
I tried the gpedit.msc -> User Config -> Windows Settings -> Scripts -> Logon but this does not work when my system Wakes up from 'Sleep'... probably because 'Sleep' - > 'Wake -up' is not technically new logon (As a user I am already logged-on).
Either a Sleep-Wake event or Login (User Login) event should trigger my script.
Any ideas on how I can do this?
More Info on what my script does: It checks if internet/network is connected. If yes, it will attempt to run the Cisco VPN connection command line utility with required arguments and logs me into VPN. Every time I wake my system up from sleep and login I need the damn VPN to connect me automatically.
I figured it out. I used the Task Scheduler as Richard indicated above.
I set the Trigger as..
On an Event -> System -> Kernel-Power -> 42
If anyone is interested... here is the script (I am a beginner with PowerShell scripts, so welcome your inputs)
$strComputerName = gc env:computername
$strVPN = 'c:\Program Files (x86)\Cisco Systems\VPN Client\vpnclient.exe'
$vpnArgs = 'connect', 'ProfileName', 'user', 'XXXXXXXX', 'pwd', 'XXXXXXXXXX'
[int]$count = 6
Write-Host "Checking for Internet Connectivity"
While (!([Activator]::CreateInstance([Type]::GetTypeFromCLSID([Guid]'{DCB00C01-570F-4A9B-8D69-199FDBA5723B}')).IsConnectedToInternet))
{
Write-Host "Sleeping for 10 seconds before checking for internet again"
Start-Sleep -s 10
$count--
if ( $count -eq 0)
{
Write-Host "Breaking from loop"
break
}
}
if ( $count -ne 0) { Invoke-Command -ScriptBlock { & $strVPN $vpnArgs } }
else { Write-Host "No Internet Connectivity, so not attempting VPN connection" }
You can accomplish this by scheduling a task to run the script, triggering on event "Power-Troubleshooter" with Event ID 1. This is the event that's logged by the system when it resumes from sleep. When the system is entering sleep, the "Kernel-Power" event is called with Event ID 42 (unlike what another answer here suggests).
Hope that helps :)
Task Scheduler would seem to be a better fit.
If a task trigger of "At Startup" doesn't work in this case (I suspect it won't) then identify an event log entry posted on wake from sleep and trigger on that.
On Windows 11 the Event Id we can use for this is 566
I set the Trigger as> On an Event -> System -> Kernel-Power -> 566
Here is my configuration
Scheduled task triggers
In my case I run a powershell script that turns on my keyboard backlight on my laptop. The backlight now turns on after windows has resumed from sleep (open the lid on laptop) but before I have logged in.
You also might want to uncheck: conditions > Power > "start the task only if the computer is on AC power"

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.

write a batch script for managing password required on login

I want to write a batch script that toggles between requiring password on login and NOT requiring password on login for my personal laptop computer.
When I'm at home I want to be able to access the machine if it goes to standby, etc. WITHOUT the password.
Before I leave for school or work I want to be able to run a batch script that re-enables "require password on login"
Does anybody know what kind of command I would need for that?
To configure your system to not prompt when it wakes from sleep/standby you can use these PowerShell functions. If you are new to PowerShell and don't know what to do with them let me know in the comments...
For XP:
function Enable-PasswordProtectedWakeup {
& POWERCFG /GLOBALPOWERFLAG on /OPTION RESUMEPASSWORD
}
function Disable-PasswordProtectedWakeup {
& POWERCFG /GLOBALPOWERFLAG off /OPTION RESUMEPASSWORD
}
For Windows 7:
function Set-PasswordProtectedWakeup {
param ([switch] $Enabled)
& powercfg -SETACVALUEINDEX SCHEME_CURRENT SUB_NONE CONSOLELOCK ([int]$Enabled.ToBool()) # AC Power
& powercfg -SETDCVALUEINDEX SCHEME_CURRENT SUB_NONE CONSOLELOCK ([int]$Enabled.ToBool()) # DC Power
& powercfg -setactive SCHEME_CURRENT
}
# Enable Password On Wake.
Set-PasswordProtectedWakeup -Enabled:$True
# Disable Password On Wake.
Set-PasswordProtectedWakeup -Enabled:$False
If you want to configure your machine to not prompt for a password when it boots up and have it auto log you in you can use this PowerShell function to enable auto logon securely. This calls the same Win32 API to store your credentials as the auto logon utility from Sysinternals :
http://andyarismendi.blogspot.com/2011/10/powershell-set-secureautologon.html
Check out AutoLogon from Sysinternals.
http://technet.microsoft.com/en-us/sysinternals/bb963905