Abrir archivos

Estoy aprendiendo... Pero no se dar la ruta del archivo
<script type="text/javascript"><!--
//LaunchArchivoByScriptman
function launch(archivo) {
var theShell = new ActiveXObject("WScript.Shell");
theShell.run("C:/WINDOWS/notepad.exe "+archivo, 1, true);
}
// --></script>
Este es con ruta..que no funciona.
<script type="text/javascript"><!--
//LaunchArchivoByScriptman
function launch(archivo) {
var theShell = new ActiveXObject("WScript.Shell");
theShell.run("C:/WINDOWS/notepad.exe "+archivo, 1, true);
}
// --></script>
<script language=JScript>
//LaunchArchivoByScriptman
function launch(archivo) {
var theShell = new ActiveXObject("WScript.Shell");
theShell.run("C:/WINDOWS/notepad.exe "+"C:\\prueba.txt", 1, true);
}
</script>
¿Cómo hago para abrir fichero?

1 respuesta

Respuesta
1
A mi este codigo me funciona:
<html>
<head>
<script>
function launch(fichero){
var theShell = new ActiveXObject("WScript.Shell");
theShell.run("C:/WINDOWS/notepad.exe " + fichero, 1, true);
}
launch("c:\\prueba.txt");
</script>
</head>
</html>
Puede que te esté dando problemas de seguridad. Tienes que aceptar todos los alerts que te de, porque ejecutar un ActiveX es potencialmente muy peligroso. Puede que incluso en la configuración de tu navegador tengas bloqueada la ejecución de ActiveX y ejecucuón de scripts. Revisalo.
Gracias por la respuesta.
la seguridad no se me habia ocurriodo.
para terminar y si no es mucha molestia cuando tengo varios archivos es correcto con esta lineas...me dan problema. Tengo un manual pero no lo tengo claro.
var theShell1 = new ActiveXObject("WScript.Shell");
theShell1.run("C:/WINDOWS/notepad.exe " + fichero1, 1, true);
var theShell2 = new ActiveXObject("WScript.Shell");
theShell2.run("C:/WINDOWS/notepad.exe " + fichero2, 1, true);
var theShell3 = new ActiveXObject("WScript.Shell");
theShell3.run("C:/WINDOWS/notepad.exe " + fichero3, 1, true);
GRACIAS
No hace falta que te crees tres ActiveX. Con uno te vale:
var theShell = new ActiveXObject("WScript.Shell");
theShell.run("C:/WINDOWS/notepad.exe " + fichero1, 1, true);
theShell.run("C:/WINDOWS/notepad.exe " + fichero2, 1, true);
theShell.run("C:/WINDOWS/notepad.exe " + fichero3, 1, true);

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas