Copy link to clipboard
Copied
Hi everybody,
I probably have a very simple problem but I can't find any answer over the internet. From what i undersand wscript is a basic object from windows including a lot of script functions like sleep, echo, etc... Why isn't it working when I run my script in Illustrator ?
In most of the samples i read, calling wscript.echo seems to work without any other settings. But when i execute it, i have an "object required : wscript" error, and if i try to create it with "set wscript = createobject("wscript.application")" then I have a "ActiveX component can't cerate object : wscript.application". Any ideas to initialize it and access wscript commands ?
Copy link to clipboard
Copied
Illustrator uses its own scripting engine to run vbs scripts, you might not be able to create the wscript object and use its properties and methods.
When you run the script in Windows, the WSH creates the object automatically, so it's always ready to use.
you can however create all other objects that the "Scripting" and "WSH" expose
Set fso = CreateObject("Scripting.FileSystemObject")
Set shellRef = CreateObject("Wscript.Shell")
Copy link to clipboard
Copied
Thanks you Carlons for your answer...
I tried this basic script :
Set fso = CreateObject("Scripting.FileSystemObject")
Set shellref = CreateObject("Wscript.Shell")
set app = createobject("Illustrator.application")
set doc = app.activedocument
shellref.echo "hello"
it doesn't work. The shellref object is successfully created, but doesn't have the echo method...
I mainly need to create a menu, use the sleep function, the msgbox... Maybe there is another way to do it in illustrator, but I haven't find it !
Copy link to clipboard
Copied
echo is a method of the wscript object, whis is not available to the Illustrator scripting engine,
if you still want to use it, you can...but you can not run your script from Illustrator->File->Scripts, you must double-click the script in an explorer window.
try this, open illustrator, open an AI document, and double click on the script to run
set iapp = CreateObject("Illustrator.Application")
msgbox "hello from Illustrator - " & iapp.documents.count & " document(s) open"
wscript.echo "hello from wscript " & iapp.activeDocument.name & " - active document's name"
Find more inspiration, events, and resources on the new Adobe Community
Explore Now