VBScript编译错误



我一直在为学校制作脚本,但遇到了一些问题。。。如果我的脚本">"显示错误。完全错误:线路:26字符:14错误:语法错误

' 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

故事:我已经完成了高中八年级的E-Zine评估,我一直在摆弄代码,我设法制作了一个可视化的基本脚本——保存所有文件,关闭它,然后关闭,尽管这个脚本只适用于记事本。自从我今天回家后,我一直在扩展脚本,并添加了更多内容,比如经典的"你确定吗"提示。但我的电脑不同意。。。

我添加它是因为它说:看起来你的帖子大部分都是代码;请添加更多详细信息

>if ( sResult==6 ) {
   '...
end
]

不是VBScript。正确的语法是

If sResult = 6 Then
    '...
End If

相关内容

最新更新