VBScript编译错误
我一直在为学校做剧本,但我遇到了一些问题。。。 如果我的脚本“>”显示错误,则会出现此错误。 完全错误: 第26行 字符:14 错误:语法错误VBScript编译错误,vbscript,compilation,shutdown,Vbscript,Compilation,Shutdown,我一直在为学校做剧本,但我遇到了一些问题。。。 如果我的脚本“>”显示错误,则会出现此错误。 完全错误: 第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(5
' 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
故事:
我已经完成了我的评估,一个电子杂志,在我高中八年级的时候,我一直在摆弄代码,我设法制作了一个visual basic脚本保存所有文件,关闭它,然后关闭,但脚本只对记事本有效。自从我今天回家以来,我一直在扩展脚本,并添加了更多内容,例如经典的“确定”提示。但是我的电脑不同意
我补充说,因为它说:
看起来你的帖子大部分都是代码;请补充更多细节。”
>if ( sResult==6 ) {
'...
end
]
不是VBScript。正确的语法是
If sResult = 6 Then
'...
End If
谢谢,我犯了一个非常愚蠢的错误。很高兴您回答了.var oShell=WScript.CreateObject(“WScript.Shell”)新错误…'对象不支持此属性或方法“我擅长批处理,而不是vbs…”不能在同一行定义和声明变量。要模拟您可以执行以下操作:
Dim oShell:Set oShell=WScript.CreateObject(“WScript.Shell”)
冒号是一个行分隔符。@Joshuahaughes:请每个问题一个问题。如果你有一个新问题,请用相关的代码发布一个新问题,而不是整个程序的转储。