Results 1 to 6 of 6

Thread: Command to close Windows

  1. #1
    Join Date
    Jul 2009
    Posts
    140

    Command to close Windows

    Hi,
    I use windows xp as my operating system and I have started programming recently. I was wondering that is it possible to run a command or bat file to close windows. I think there should be one, if so, what is the command? Can any one help me with the command to close a window.
    Last edited by Ameeryan; 29-12-2009 at 01:12 PM.

  2. #2
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Command to close Windows

    Hello
    It is possible! Method:
    1) Create a text file containing your script and give it as a cmd extension. (test.cmd I will use as example below)
    2) Make sure that Windows displays hidden files and folders.
    3) Place the test.cmd in the following directory: C: \ WINDOWS \ system32 \ GroupPolicy \ Machine \ Scripts \ Shutdown
    4) Test test.cmd by double-clicking it to make sure it runs properly.

    You can do the same way to run a script at startup of your machine by placing it in C: \ WINDOWS \ system32 \ GroupPolicy \ Machine \ Scripts \ Startup. I have tested this in windows xp and not on any other operating system.

  3. #3
    Join Date
    Jul 2009
    Posts
    140

    Re: Command to close Windows

    Hello
    Directory C: \ WINDOWS \ system32 \ GroupPolicy \ Machine \ Scripts \ Shutdown.
    I understood it and I created a little code
    Code:
    del C: / example.txt
    in test.cmd in C: \ WINDOWS \ system32 \ GroupPolicy \ User \ Scripts \ Logoff:
    I run the code and it worked, well deleted the file. So I recreated and then reboot , but this time the file was not erased. Any idea about this behavior ? Is there something which I need to change? Thank you!

  4. #4
    Join Date
    May 2008
    Posts
    2,389

    Re: Command to close Windows

    Hello
    Perhaps all con, but there is a lack of syntax in your code: the slash before the "example" is a slash and not a back-slash! That is why the code does not work. The best way to test your code is to first do a double-click on your test.cmd to see if you get the desired result. If yes, then you can test it with a logg-off, then a shutdown.

  5. #5
    Join Date
    Jul 2009
    Posts
    140

    Re: Command to close Windows

    Hi
    I have written the code and yes I did not paid attention to that stuff bu the problem is that the file works when I log off. Regarding the version of Windows that I use, I use xp pro ... but I'd like to get this stuff at XP home edition. I found this topic on how to windows xp pro and in fact it works, this is what you need to activate it but something at the same time is stopping the file to run.

  6. #6
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Command to close Windows

    Hello,
    It's normal that it does not work, that adding a script in% systemroot% \ System32 \ GroupPolicy \ Machine \ Scripts \ Startup does not have to execute.
    It must also configure Group Policy (local or domain) to tell him to run. To do this click Start / Run and type gpedit.msc
    Then go to "Windows Settings" then "scripts" and double click on "Stop system" click Add and then browse , it is your script. In fact, it is simply the default GPOs. So select the script and click ok all you see. That's it, the script runs at the next stop. Hope you got the point.

Similar Threads

  1. How to get back the Command + Q feature to close Google Chrome
    By AshritaS in forum Technology & Internet
    Replies: 6
    Last Post: 25-05-2011, 10:18 PM
  2. How can I close a group of windows?
    By Inception in forum Operating Systems
    Replies: 3
    Last Post: 24-01-2011, 05:53 AM
  3. How to safely close torrent via command line
    By MadhaviS in forum Technology & Internet
    Replies: 6
    Last Post: 26-06-2010, 01:17 AM
  4. command to close ssh
    By _Gentoo_Nile_ in forum Operating Systems
    Replies: 3
    Last Post: 18-08-2009, 07:23 PM
  5. Command prompt "COPY" command not working in brand new Windows Vis
    By CMD COPY command not working in Vista in forum Vista Help
    Replies: 7
    Last Post: 06-02-2008, 02:50 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,588,327.30284 seconds with 17 queries