I've been making a script for school, but I've encountered a few problems... This if my script ">" shows the error. Complete error: Line: 26 Char: 14 Error: Syntax Error
' Macro starter script -- basically for any teachers or students to understand and or improve my script.
'oShell.AppActivate("Paint"); // Set focus to a program
'WScript.Sleep(500); // Delay for 1/2 second
'oShell.Run("notepad c:\\temp\\somefile.txt", 1, false); // launch a program
'----------------------------- can add ,2 to run minimized, true=wait for exit
'oShell.SendKeys("%F"); // Alt+F ----- SendKeys strings to jog my memory
'oShell.SendKeys("^C"); // Ctrl+C
'oShell.SendKeys("{ENTER}"); // Send Enter key (also tilde {~} )
'oShell.SendKeys("{{TAB} 2"); // Send Tab key twice )
'oShell.SendKeys(" "); // Send a space
'var nResult= oShell.Popup("Do you want to continue?", 0, "My Macro", 4+32 );
'if ( nResult==6 ) { // 6=Yes, 7=No,
' WScript.Echo( "you said 'Yes!'" );
'}
'WScript.Echo( "done!" );
'Script Starts Here
var oShell = WScript.CreateObject("WScript.Shell")
WScript.Echo( "Script made by Joshua Hughes" )
var sResult = oShell.Popup("Do you want to save all work and shut down?", 0, "Shutdown", 4+32)
>if ( sResult==6 ) {
WScript.Echo( "Starting, do not press any buttons or click!" )
oShell.AppActivate("Word");
WScript.Sleep(500);
oShell.SendKeys("^S");
oShell.SendKeys("{ENTER}");
WScript.Sleep(500);
oShell.SendKeys("%F4")
oShell.AppActivate("Notepad");
WScript.Sleep(500)
oShell.SendKeys("^S");
oShell.SendKeys("{ENTER}");
WScript.Sleep(500);
oShell.SendKeys("%F4")
oShell.AppActivate("Powerpoint");
WScript.Sleep(500)
oShell.SendKeys("^S");
oShell.SendKeys("{ENTER}");
WScript.Sleep(500);
oShell.SendKeys("%F4")
oShell.AppActivate("Paint");
WScript.Sleep(500)
oShell.SendKeys("^S");
oShell.SendKeys("{ENTER}");
WScript.Sleep(500);
oShell.SendKeys("%F4")
end
]
WScript.Echo( "Program Complete! Shutting Down..." )
'Script Ends Here
The story: I had finished my assessment, an E-Zine, for grade eight at my high school, and I've been fiddling with code, I managed to make a visual basic script save all files, close it, then shutdown, the script only worked for notepad though.Since I've gotten home today, I've been expanding the script, and adding in a bit more, such as the classic 'Are you sure' prompt. But my computer is disagreeing...
I added that because it said: 'It looks like your post is mostly code; please add some more details.'
>if ( sResult==6 ) {
'...
end
]
is not VBScript. Proper syntax is
If sResult = 6 Then
'...
End If