I play a lot of Xbox live and always have to disable the internet on my computer because it hogs bandwidth. Mainly because I am downloading or uploading things all the time. The problem isn't shutting it off but it is turning it back on that I forget, making it to where I loose out on all that upload/download time.
So I decided to create a program to do it for me. I was going to write it in Vb.net but I just recently had to nuke and pave my operating system on my computer because of a bad storm frying my hard drive, and haven't reinstalled VB.net yet so I just figured this would give me a reason to play with vbscript.
I also made an image in paint to display in the background so i knew it was running.
Remove these ads by
Signing UpStep 1: Figure out what you want to do.
What do I want the program to do?
A) I want to be able to open the script and it will automatically shut off the connection.
B) I want it to display a giant display in the background so there is no mistake that the internet is off, this way I don't forget to turn it back on.
C) I want it to give me a choice to turn it back on and then wait for a response.
D) I want it to make sure i turn it back on so i don't forget.
E) Then once I actually do say yes to turn it back on, the script turns it back on and then closes the background.
F) Exit everything.








































Visit Our Store »
Go Pro Today »




I was going to answer this with a long drawn out answer but then i realized I could just do this...
http://www.scriptlogic.com/Kixtart/htmlhelp/Functions/sendkeys.htm
This site should answer both your answers in one site. Hope it helps and if it doesnt answer your question message me and I will try to help you further.
If I had to wager a guess I would have to say It may have something to the way the comment is nested in the line of code. You can't have a set of "" nested inside another like you have it. The computer sees the second " and thinks it is the end of the line and regards the rest as a comment or something.
If I had to guess I would say it should be like this
"shutdown.exe -s -t 60 -c 'Hard drive dump complete. Please contact your administrator'"
Notice the differentiation between ' and " in the strshutdown line. I think it may work but you have to make sure you have correctly nested the comment or it will either ignore it or skip the line completely. Which I believe is the problem now.
Have you tried the code without the comment and see if it works. Also try putting in a force close command (-f). It may be that you are not forcing the programs that are running to close and it aborts because it can't shutdown without them programs closing.
But like I said to begin with I think it has to do with the way it is nested. I think also that if you are using the sendkeys command to do this it may give you lots of problems nesting, even with the use of single quotes nested in doubles.
If that's the case you should be able to use it in as string and the direct to the string something like this.
Dim objShell
Dim strShutdown
strShutdown = "shutdown -s -t 60 -f -c 'Hard drive dump complete. Please contact you administrator'"
set objShell = CreateObject("WScript.Shell")
objShell.Run strShutdown
Wscript.Quit
If none of these help let me know and I will see what I can figure out. I haven't actually tested any of these codes but in theory they should work. I have been doing them mainly from memory and don't really have time to test them properly. But it should at least give you some ideas on where to look.
Hope this helps.