Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Little help. am missing something here 1

Status
Not open for further replies.

monsterisht

Programmer
Jun 11, 2015
3
KE
dim X

dim Y

set oShell=createobject("wscript.shell")

set sapi=Wscript.CreateObject("SAPI.Spvoice")

X=MsgBox("Would you like to shut down your pc? answer:Yes/No","AUTOMATIC SYSTEM SHUTDOWN BY MONSTERISHT")

if X="Yes" then,

Y=MsgBoxx("Enter time left for shutdown(time in minutes...):","AUTOMATIC SYSTEM SHUTDOWN!")

sapi.speak Y+"minutes left to SHUTOWN"

oShell.Run "shutdown.exe -s -t "&(Y*60)&" -f -c""system is now set for automatic shutown GOOdBYE"

endif

what's the problem with this code. any suggestions?
 
Wow, there is quite a bit wrong with that code. I've commented out your lines that were in error so you can compare. Note that you were using a messagebox in place of an inputbox to request user feedback. No commas after Then in If/Then statements. Also you need to use End If not EndIf. To concatenate you need to use & and not +.

Code:
Dim X,Y

Set oShell=CreateObject("wscript.shell")
Set sapi=CreateObject("SAPI.Spvoice")

[COLOR=#4E9A06]'X=MsgBox("Would you like to shut down your pc? answer:Yes/No","AUTOMATIC SYSTEM SHUTDOWN BY MONSTERISHT")[/color]
X = MsgBox("Would you like to shut down your pc?",vbYesNo,"AUTOMATIC SYSTEM SHUTDOWN BY MONSTERISHT")
[COLOR=#4E9A06]
'if X="Yes" then,[/color]
If X = vbYes then

	[COLOR=#4E9A06]'Y=MsgBox("Enter time left for shutdown(time in minutes...):","AUTOMATIC SYSTEM SHUTDOWN!")[/color]
	Y = InputBox("Enter time left for shutdown(time in minutes...:","AUTOMATIC SYSTEM SHUTDOWN!")
	[COLOR=#4E9A06]'sapi.speak Y+"minutes left to SHUTOWN"[/color]
	sapi.speak "Warning" & Y & "minutes left to shutdown"
	[COLOR=#4E9A06]'oShell.Run "shutdown.exe -s -t "&(Y*60)&" -f -c""system is now set for automatic shutown GOOdBYE"[/color]
	oShell.Run "shutdown.exe -s -t " & (Y*60) & " -f -c" & Chr(34) & "System is now set for automatic shutown goodbye." & Chr(34)
End If

I hope that helps.

Regards,

Mark

No trees were harmed in posting this message, however a significant number of electrons were terribly inconvenienced.

Check out my scripting solutions at
Work SMARTER not HARDER.
 
Skip, thanks. Looks like he is a first time poster. I somehow think I just helped him fix his homework and he will never be seen again. [sadeyes]

I hope that helps.

Regards,

Mark

No trees were harmed in posting this message, however a significant number of electrons were terribly inconvenienced.

Check out my scripting solutions at
Work SMARTER not HARDER.
 
Well it wasnt home work just some work i thought i would indulge myself in, its been long just a bit rusty with my VBscript
 
@monsterisht, please read my pprevious post, for the benefit of other members who browse looking for "Great posts"

Skip,

[glasses]Just traded in my OLD subtlety...
for a NUance![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top