Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Close a window with a batch file?

Status
Not open for further replies.

Turb

Technical User
Feb 11, 2003
154
US
Can anyone help with this?
I am trying to figure out how to close a window (not a DOS or command window) using a batch file.
 
lwcomputing,
Thank you for your response!
I'll try that now.
 
lwcomputing,
No dice.
This is my code:
Code:
TASKKILL /F /FI "WINDOWTITLE eq netlogon on Dunlap-dc"

This is the exact name of the window, but it will not close.
If I use task manager to view this "application" and select go to process, I get explorer.exe (of course).
If I use the task manager to close this window, it works like a charm everytime.

Any ideas?
 
You are getting to fancy.

Instead of:
TASKKILL /F /FI "WINDOWTITLE eq netlogon on Dunlap-dc"

Try any of these:
TASKKILL /F /FI "WINDOWTITLE eq netlogon*"
TASKKILL /F /FI "WINDOWTITLE eq Dunlap*"
TASKKILL /F /FI /im netlogon.exe









____________________________
Users Helping Users
 
Hm....
Still nothing.
TASKKILL /F /FI "WINDOWTITLE eq netlogon*"
TASKKILL /F /FI "WINDOWTITLE eq Dunlap*"
I didn't try the ".../im netlogon.exe" as this isn't a program running; this is a window from the netlogon share from our domain controller.
 
I see, then taskkill is not what you want. It is designed to close processes, not windows.

If the Window is left open after logon, the issue is either a mistake in the logon script; or, a mistake in the RUN entry for a startup item. For example, in non-Domain settings that last folder pointed to at logon is often System32:

You can use either of these to close the share or session with Dunlap-DC:
NET SESSION /d
or
NET USE /d

But I suspect you just want to close the Window that is left open. Again, this is a logon scripting error or a startup item run entry error.

For the latter, you might find the Microsoft/Sysinternals utility AUTORUNS helpful as a diagnostic tool:


____________________________
Users Helping Users
 
bcastner,
Thank you! I'll look into both those items.
 
FYI - I have finally got this window to close (yes, I agree that it is probably a scripting error on a GPO, but it isn't my script so I can't change it).
This was the answer, in a vbs file:
Code:
Set objWord = CreateObject("Word.Application")
Set colTasks = objWord.Tasks

If colTasks.Exists("netlogon on Dunlap-dc") Then
    colTasks("netlogon on Dunlap-dc").Close
End If

objWord.Quit

Thanks for everyone's help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top