2

So, previously I had been using the following in a batch file,

Start http://accounts.google.com/logout  
Timeout /t 3  
shutdown /l

This worked just fine for what I needed it for. It logged the user out of Google, and after 3 seconds, the system.

For some reason, as of 5/8/19, this hasn't worked. It still logs the user out of chrome, but does not log them out of the system. Instead it just repeats this over and over until it is closed.

C:\Users\Class\Desktop>shutdown /l

I know this is probably something super simple that I am looking over, but It is really confusing me. Granted, I'm no professional by any means.

I have tried it on other systems, and even tried different variants of the shutdown command, /l, /r, and, /s.

The system has not been updated since 4/10/19. No one else has had the time to tamper with the system. What do.

4
  • Take a look at my edits to your code. Is it posted exactly as your batch file is written? Note, I removed the quotes and put it in a code block. May 9, 2019 at 12:56
  • Thank you. I pasted it directly from my batch and added the quotes.
    – Joshua W
    May 9, 2019 at 13:03
  • What happens when you run these commands one by one from the command line? It has to be something about your environment. The script is too simple to be otherwise. Is this script located on the user’s desktop? Try running it from a different location as well. May 9, 2019 at 13:51
  • Sorry for the late response, I tried running it from a different location, and It worked just fine... It ran for months just being ran off of the desktop but for some reason decided to just not. Thanks for the help, I apologize for wasting your time.
    – Joshua W
    May 10, 2019 at 12:43

1 Answer 1

1

Based on your comments,

I tried running it from a different location, and It worked just fine.

I suspect something has changed in your environment that is causing it to not work properly from this location. Multiple things come to mind, but leave some guesswork as to why you see the specific behavior that you do.

My guess is one of a few things:

  • You have a shortcut or file on your desktop called "timeout", or "shutdown." So, instead of your batch file running the executable command called shutdown, it is executing the file on your desktop.
  • You recently enabled folder redirection, and something strange is happening there.
  • Your PATH environment variable has changed, causing a file / shortcut called "timeout," or "shutdown," in a different location on your drive to execute rather than the proper one that is located usually in c:\windows\system32.

I think the most likely solution to solve this problem is to insure the right shutdown and timeout command is being run. To do so, use an absolute path instead of a relative path in your scripts.

Your final script should look like this:

start http://accounts.google.com/logout  
%systemroot%\system32\timeout.exe /t 3  
%systemroot%\system32\shutdown.exe /l

The environment variable %systemroot% resolves to where you have Windows installed which is typically c:\windows. Using an environment variable like this is a technique to make sure your batch file is portable and works properly on any Windows computer, instead of only ones that have Windows installed at C:\Windows.

This change to using absolute paths forces the batch file to run the specific commands located in the Windows folder.

One final note, adding the /f parameter to the shutdown command will ensure the logoff is forced by terminating any open applications that try to prevent the logoff or shutdown of the computer. This comes with a risk of data loss, if the user hasn't saved something.

1
  • Thank you for putting this into English. I not only understand what you said, but also now why what I had didn't work consistently. Works great now, thanks tons!
    – Joshua W
    May 13, 2019 at 12:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .