1.

Solve : Batch to close window?

Answer»

Hi

I am a TOTAL batch n00b so be easy on me!
I have a batch file that will open some mapped drives on a computer.

The format is simple:
start G:\
start H:\
start I:\
start J:\

The batch works OK so far, but I am left with these windows open. Is there some more code I can put on the end that will close the windows and return to a clean desktop?"exit" CLOSES cmd windows

uliI don't need to close the cmd window, that closes automatically.

I mean I need to close the Explorer window, the one I opened with the batch file in the first place!

in other words, G:\ window contents is now open, I want to close it with a batch command.Oh.
Killing the explorer task might be an option. "kill".
Why do you open the explorer? Is there no way to avoid it?
Dumb question I know, but...

uliYou would need to send keystrokes to each of the open windows. Batch coding cannot do this, but VBScript can:

Code: [Select]Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.AppActivate "[highlight]Window Title[/highlight]"
WScript.Sleep 100
WshShell.SendKeys "{F4}"

The highlighted area contains the Window title NOT the executing program name which presumably is explorer. You can repeat the last THREE statements as needed.

After saving the script with a VBS extension, run with cscript scriptname.vbs

There is also a program called AutoIt that can be helpful in this SITUATION but VBScript is already installed on your machine.

8-)



Discussion

No Comment Found