On Jan 26, 3:09*pm, AuHuman <AuHu...@newsgroup> wrote:
> Dim shell
> Dim oExec
> Set shell = CreateObject("wscript.shell")
> Set oExec = shell.Exec("cmd.exe")
> oExec.StdIn.Write("exit")
> oExec.StdIn.Write VbCrLf
> Do While oExec.Status = 0
> WScript.Sleep 100
> Loop
> WScript.Echo oExec.Status
> Above code is not executing the exit command in the command prompt openedby
> shell.Exec("cmd.exe").
> Nothing is happening until i close the prompt manually by clicking the close
> button.
> How to execute dos commands in the prompt opened by shell.Exec("cmd.exe")?.
> [i looked into the msdn library but its not clearing my above doubt] This worked for me ...
Dim shell, oExec
Const delay = 5
Set shell = CreateObject("wscript.shell")
Set oExec = shell.Exec("cmd.exe /k echo Will close in " & delay & "
second(s)>con")
for n = delay to 1 step - 1
WScript.Sleep 1000
oExec.StdIn.Writeline "echo " & n & " > con"
Next
oExec.StdIn.Writeline "echo Closing > con"
WScript.Sleep 1000
oExec.StdIn.Writeline "exit"
WScript.Echo oExec.Status
_____________________
Tom Lavedas