JS alert & confirm in Windows Scripts

L

Little Pete

I use a simple .js script to shuffle files on my computer to which I'd
like to add alert and confirmation boxes. Unfortunately I haven't been
able to figure out what object I need to create that has these methods.
What is missing from this .js script:

var source = "source.txt";
var destination = "destination.txt";

if (confirm("Make Changes?"))
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
fso.CopyFile(source, destination, true);
alert("Changes made.");
}
else
{
alert("No changes made.");
}

Thanks, Pete.
 
M

Martin Honnen

Little said:
I use a simple .js script to shuffle files on my computer to which I'd
like to add alert and confirmation boxes. Unfortunately I haven't been
able to figure out what object I need to create that has these methods.
What is missing from this .js script:

var source = "source.txt";
var destination = "destination.txt";

if (confirm("Make Changes?"))
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
fso.CopyFile(source, destination, true);
alert("Changes made.");
}
else
{
alert("No changes made.");

WScript.Echo("No changes made.")
will display on the console (when the script is run with cscript) or as
an alert dialog (when the script is run with wscript).
To have a confirm dialog you can use the WScript.Popup method, see the
documentation
<http://msdn.microsoft.com/library/d...n-us/script56/html/wsoriWindowsScriptHost.asp>
<http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/wsMthPopup.asp>

You can also download that documentation and then you have the help on
your pc.
 
L

Little Pete

Thanks, Martin, that looks like what I needed, especially the links to
the docs. Without already knowing the keywords, searching the msdn
library was a nightmare.

Pete.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,775
Messages
2,569,601
Members
45,182
Latest member
BettinaPol

Latest Threads

Top