Foro de elhacker.net

Programación => .NET (C#, VB.NET, ASP) => Mensaje iniciado por: jlewis09 en 17 Noviembre 2015, 18:06 pm



Título: Problema de ejecucion de .bat y de scripts
Publicado por: jlewis09 en 17 Noviembre 2015, 18:06 pm
Hola,

Tengo un problema quiero ejecutar un script VBS que abre puertos en un modem:

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "telnet 192.168.1.254", 9
WScript.Sleep 500
WshShell.SendKeys "TELMEX"
WshShell.SendKeys "{ENTER}"
WScript.Sleep 500
WshShell.SendKeys "0F15AF5A01"
WshShell.SendKeys "{ENTER}"
WScript.Sleep 500
WshShell.SendKeys "wireless ifconfig state=enabled"
WshShell.SendKeys "{ENTER}"
WScript.Sleep 500
WshShell.SendKeys "saveall"
WshShell.SendKeys "{ENTER}"
WScript.Sleep 500
WshShell.SendKeys "exit"
WshShell.SendKeys "{ENTER}"
WScript.Sleep 500
WshShell.SendKeys "Timeout 15"
WshShell.SendKeys "{ENTER}"

Esto lo hago a traves de un archivo .bat

cscript "Modem.vbs"

Timeout 20

y lo llamo en visual con

Dim psi As New ProcessStartInfo("Modem.bat")
psi.WorkingDirectory = "J:\Sourcesafe 2\Sentinel SMI\SentinelSMIManager\SYS_PR_SentinelSMIManager.C V\bin\Debug\ScriptsSentinelSMI"
psi.WindowStyle = ProcessWindowStyle.Maximized
Process.Start(psi)

el problema es que me sale que no encuentra el archivo especificado dentro del bat, ya intente poniendo la ruta completa del script y aun así no funciona ya probé mi script desde cmd con cscript y funciona bien, tambien ya probé dando doble click en mi archivo bat y funciona bien el problema solo es en visual no se si alguien sepa a que se debe esto.


Agradezco su tiempo por leer esto y ojala me puedan ayudar


Título: Re: Problema de ejecucion de .bat y de scripts
Publicado por: _TTFH_3500 en 17 Noviembre 2015, 19:19 pm
Código
  1. cscript "Modem.vbs"
Cuando ejecutas el .bat, Modem.vbs debe estar en la misma carpeta que este o en una ruta de entorno o dar la ubicacion completa.
Aunque creo que ese no es el problema ya que dices que funciona al darle doble click.

El problema debe estar en:

Código
  1. Dim psi As New ProcessStartInfo("Modem.bat")
  2. psi.WorkingDirectory = "J:\Sourcesafe 2\Sentinel SMI\SentinelSMIManager\SYS_PR_SentinelSMIManager.C V\bin\Debug\ScriptsSentinelSMI"
  3. psi.WindowStyle = ProcessWindowStyle.Maximized
  4. Process.Start(psi)

En lugar de eso puedes intentar ejecutar directamente el .bat:

Código
  1. Set WshShell = wscript.CreateObject("WScript.Shell")
  2. WshShell.Exec("J:\Sourcesafe 2\Sentinel SMI\SentinelSMIManager\SYS_PR_SentinelSMIManager.C V\bin\Debug\ScriptsSentinelSMI\Modem.bat")

O no usar el .bat y ejecutar directamente es script:

Código
  1. Set WshShell = wscript.CreateObject("WScript.Shell")
  2. WshShell.Exec("patch\Modem.vbs")
  3. WScript.Sleep 20000

O meter el contenido de Modem.vbs en el script que llama al bat.

Por ultimo el problema puede estar en
Citar
...SYS_PR_SentinelSMIManager.C V\bin...
, en el espacio entre ".C V\" o que este mal escrita la direccion.