call main()
sub main()
Dim scmd
Set scmd = \"c:\\windows\\system32\\cscript.exe //nologo c:\\s.vbs\"
createobject(\"wscript.shell\").run scmd,0,false
end
As
>> WScript.Echo CreateObject("WScript.Shell").CurrentDirectory
>>
E:\trials\SoTrials\answers\trials\AlgoTaBu\SuSo\wsf
proves, there is no rule or law at all that "Your Set scmd
should be instantiating the WScript.Shell". Putting the command to execute in string variable scmd (or perhaps better sCmd) and not creating a variable for an only-once-used value are good practices.
The revised version (minus the stupid Set):
call main()
sub main()
Dim scmd
scmd = "c:\windows\system32\cscript.exe //nologo c:\s.vbs"
createobject("wscript.shell").run scmd,0,false
end sub
will work just as well as Lankymart's version.
To spell everything out:
"site:stackoverflow.com vbscript "object required" Set"
results in 1500 hits. Even if much of those hits do not concern the "Set x = 'non-object'
blunder, that's clearly too much. To explain/excuse those IEDs you have to consider that BASIC is a stone age language."Set x = 'non-object'
mistake twice. If it happens trice (or more often), he/she should be ashamed (and keep silent about it). Above all that problem should not pollute this site.wtf
Set x = " ---- stop or be damned!!!
Set x = obj.getNumber() + 4 ---- oh no!!!