Sign in to follow this  
Followers 0
Jkeith247

Telnet into pc to shut it down

27 posts in this topic

So, I am pretty new to Auto It. From what I understand though, AutoIT has the capability to open a socket and send telnet commands. What I am looking to do is login to a machine via telnet, send login and password, give the pc the command to shutdown /s and close the connection. I think the whole process would be much more stable doing this without having auto it open a command line window. Is this possible with autoit?

Share this post


Link to post
Share on other sites



So, from my reading, this is what I have put together, seems like it should work, but it doesn't...

Can someone tell me what I am doing wrong?

Thank you!

TCPStartup()

$Socket = TCPConnect("192.168.2.100", 23)

Sleep (1000)

TCPSend($Socket, "Username"&@CRLF)

Sleep (1000)

TCPSend($Socket, "Password"&@CRLF)

Sleep (2000)

TCPSend($Socket, "shutdown /s"&@CRLF)

Share this post


Link to post
Share on other sites

So, from my reading, this is what I have put together, seems like it should work, but it doesn't...

Can someone tell me what I am doing wrong?

Thank you!

TCPStartup()

$Socket = TCPConnect("192.168.2.100", 23)

Sleep (1000)

TCPSend($Socket, "Username"&@CRLF)

Sleep (1000)

TCPSend($Socket, "Password"&@CRLF)

Sleep (2000)

TCPSend($Socket, "shutdown /s"&@CRLF)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Why you are not using the switch /m \\computer to shutdown remote system?

Example: shutdown /m \\192.168.2.100 /s /f /t 0

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Can't test myself but are you sure you want to send CRLF or just LF ?

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

So, from my reading, this is what I have put together, seems like it should work, but it doesn't...

Can someone tell me what I am doing wrong?

Thank you!

TCPStartup()

$Socket = TCPConnect("192.168.2.100", 23)

Sleep (1000)

TCPSend($Socket, "Username"&@CRLF)

Sleep (1000)

TCPSend($Socket, "Password"&@CRLF)

Sleep (2000)

TCPSend($Socket, "shutdown /s"&@CRLF)

I am guessing the computer you are sending those delightful little packets to is not listening. Look at TCPAccept(),TCPListen().

Share this post


Link to post
Share on other sites

I am guessing the computer you are sending those delightful little packets to is not listening. Look at TCPAccept(),TCPListen().

The Telnet Server is windows 7 home premium. I have tested the connection by manually telneting into it and shuting it down via "shutdown /s", so I know the server is listening. Its just a matter of getting autoit to send the commands. I am gonna try using @LF now, but I believe I have tried that already.

Thank you all!

Share this post


Link to post
Share on other sites

So i tried it with LF only and it didnt work. :-(

Share this post


Link to post
Share on other sites

The Telnet Server is windows 7 home premium. I have tested the connection by manually telneting into it and shuting it down via "shutdown /s", so I know the server is listening. Its just a matter of getting autoit to send the commands. I am gonna try using @LF now, but I believe I have tried that already.

Thank you all!

Like UEZ said why telnet in to shut it down?

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Why you are not using the switch /m \\computer to shutdown remote system?

Example: shutdown /m \\192.168.2.100 /s /f /t 0

Br,

UEZ

Im sorry, excuse my noobism... I was looking at this, but could not figure out how to use it. I tried it looking for some documentation on it but couldn't find any.

Edited by Jkeith247

Share this post


Link to post
Share on other sites

Maybe this'll help in the future - http://www.google.com/search?q=shutdown+command.


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

sorry to keep beating a dead horse.... but the situation at hand is, I have multiple machines that I need to shutdown on a scheduled nightly basis. I have been looking at the shutdown \\name command and i have a couple issues with it. I cant have any visible window and I have other devices that are not pc's that need the same telnet script to work.

In light of the issues that I am having, I think I need a little more AUTOIT education. Does someone have a link to a more comprehensive guide to autoit language? Thanks!

Also, does anyone have any other ideas why my simple script doesnt work?

Thanks again!!! :x

Share this post


Link to post
Share on other sites

I use this program to "telnet" to my ISP's mail server, and delete my email. Its called "Telnet Scripting Tool a.k.a TST10.exe". As the title says, you can script with it. I hope this is what you were looking for.

Good luck.

http://jerrymannel.com/blog/2008/11/11/telnet-scripting-tool-aka-tst10exe/

http://blog.cleannet.co.th/?p=165

From what I gather is it is freeware. Though I could be wrong.

Share this post


Link to post
Share on other sites

What I really need for to make this program work the way I intend it to is for autoit to telnet in to these machines in the background (without being seen is key) so they can be shutdown. The people that will be using this are not the most technologically inclined people and another window will just create more problems down the road. Is it even possible for autoit to telnet into windows? I saw mention on another post that autoit could not natively telnet into windows....

Share this post


Link to post
Share on other sites

(without being seen is key)....

Wonder why though if this is scheduled nightly!

Have you looked at the shutdown parameteres /m /p /f


Share this post


Link to post
Share on other sites

As far as I know, the telnet protocol is more complex then just opening a socket on port 23.

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

Well, I dont want this to open other windows, because it opens up the oportunity for other people to mess things up. It is being used in an environment where people are technologically illiterate and the random opening of windows would freak them out. Is there even a way to open a telnet connection to a windows machine and send commands? I have looked at the shutdown parameters and it has its own set of issues. If I had telnet it would open the door to give me other controls and abilities that would definitely be helpful in the future for using peripheral devices that respond to telnet. This is key. If someone has some insight as to where I could do some homework on autoit/telnet connections working in tandem I will be forever grateful. Thanks!

Edited by Jkeith247

Share this post


Link to post
Share on other sites

Just have to ask - your users are "technologically illiterate" as you put it, to the point that "opening of windows would freak them out", yet you think an abrupt reboot of the machine will NOT "freak them out"?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

No, they are meant to be shut down at a scheduled time.

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

Could you not write an autoit program to run at startup on the machine to be shut down and simply shut down at a scheduled time?

Does the time the PC have to shut down change each night?

If it's the autoit icon in the corner that bothers you, you can hide it...

Opt("TrayIconHide", 1)          ;0=show, 1=hide tray icon

;insert code here using Date.au3 to monitor the time, then...

Shutdown(15)  ;Force a shutdown and power down
Edited by Affe

[center][/center]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0