Hello Guest, Welcome to Apnea Board !
As a guest, you are limited to certain areas of the board and there are some features you can't use.
To post a message, you must create a free account using a valid email address.

or Create an Account


New Posts   Today's Posts

what's wrong with this fragment of windows batch code?
#1
This logoff code does not work. It's a fragment I want to use at the end of a longer batchfile that runs unattended; and for security, I need it to logoff when done. It's a single user Win 7 machine where I am the only user. But, I have a password on the account; and from GUI, I can logoff.
The TIMEOUT command seems to set a delay and work (I want remote disc writes to finish); but, no logoff occurs.

@ECHO OFF
REM LOGOFF BATCH FILE
REM WAIT 30 SECONDS
TIMEOUT /T 30 /NOBREAK
C:\Windows\System32\shutdown /l /f /t 30

=============
This fragment doesn't work either:

ECHO SHUTDOWN BATCH FILE
ECHO WAIT 30 SECONDS
TIMEOUT /T 30 /NOBREAK
C:\Windows\System32\shutdown /s /f /t 30

Perhaps, I need to set it to run as "admin"???
[Image: 1F4m9Ift.jpg]
Post Reply Post Reply
#2
You need to be an admin to run shutdown.

rundll32.exe user32.dll,LockWorkstation

might lock it. Not sure what permission that needs.

Terry


(05-01-2015, 01:59 PM)justMongo Wrote: This logoff code does not work. It's a fragment I want to use at the end of a longer batchfile that runs unattended; and for security, I need it to logoff when done. It's a single user Win 7 machine where I am the only user. But, I have a password on the account; and from GUI, I can logoff.
The TIMEOUT command seems to set a delay and work (I want remote disc writes to finish); but, no logoff occurs.

@ECHO OFF
REM LOGOFF BATCH FILE
REM WAIT 30 SECONDS
TIMEOUT /T 30 /NOBREAK
C:\Windows\System32\shutdown /l /f /t 30

=============
This fragment doesn't work either:

ECHO SHUTDOWN BATCH FILE
ECHO WAIT 30 SECONDS
TIMEOUT /T 30 /NOBREAK
C:\Windows\System32\shutdown /s /f /t 30

Perhaps, I need to set it to run as "admin"???

Post Reply Post Reply
#3
JustMongo,
Try using this syntax: shutdown -l

Before I posted this and looked like a total idiot, I put it in a batch file and it worked. Now I'm just a half an idiot.
______________________
Useful Links -or- When All Else Fails:
Posting SleepyHead Charts in 5 Easy Steps
Robysue's Beginner's Guide to Sleepyhead
Apnea Helpful Tips
Post Reply Post Reply


#4
Reformat your drive, install Linux, and use /etc/shutdown Smile
Post Reply Post Reply
#5
(05-07-2015, 08:25 PM)GeoffD Wrote: Reformat your drive, install Linux, and use /etc/shutdown Smile

Best answer! LOL
I use my PAP machine nightly and I feel great!
Updated: Philips Respironics System One (60 Series)
RemStar BiPAP Auto with Bi-FlexModel 760P -
Rise Time x3 Fixed Bi-Level EPAP 9.0 IPAP 11.5 (cmH2O)
Post Reply Post Reply
#6
Consider using CrapCleaner to do your shutdown. The following line will run CC, which will execute however you last set it, and then shut down your system.

"C:\Program Files\CCleaner\CCleaner64.exe" /auto /shutdown

Two birds, one stone.
Post Reply Post Reply


#7
I got it to work with shutdown -L
Everything I read says to preface switches with / not -

Mongo
[Image: 1F4m9Ift.jpg]
Post Reply Post Reply
#8
That doesn't make any difference, either - or / should work. You just can't use the /t switch with the /l. I've never had any program squawk when using shutdown /l and letting the system handle the rest.
Post Reply Post Reply
#9
BTW, If you really need the wait time before logging out, you can use a simple public domain executable called logout.exe which I have had good luck with. http://sourceforge.net/projects/logout/f...t/download

Put that somewhere on your path (e.g., Windows\system32 folder) or in same directory as your batch file.

Example batch script line to use instead of C:\Windows\System32\ shutdown /l /f /t 30:

logout.exe 1

That gives a one-minute delay before logging you off.

Post Reply Post Reply


#10
Nice one.
I downloaded logout.exe and tried it.
Works like a charm.

:-)
Post Reply Post Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  December 2016 security monthly quality rollup for Windows 7 justMongo 8 896 12-31-2016, 07:51 AM
Last Post: JonC
  Still want Windows 10 for free? AlanE 1 441 09-23-2016, 07:23 PM
Last Post: AlanE
  a little help with PHP code for logins justMongo 12 730 09-19-2016, 06:08 PM
Last Post: eseedhouse
  Windows 7 and 8.1 Users Crimson Nape 20 1,148 08-25-2016, 08:10 PM
Last Post: FrankNichols
  Windows 10 - Install Heads-Up and a Vent Crimson Nape 11 644 07-24-2016, 02:51 PM
Last Post: justMongo
  It's Windows update Tuesday justMongo 8 1,377 02-10-2016, 07:04 PM
Last Post: AlanE
  Sysinternals Suite update (Windows) AlanE 1 480 01-12-2016, 07:38 PM
Last Post: DariaVader

Forum Jump:

New Posts   Today's Posts




About Apnea Board

Apnea Board is an educational web site designed to empower Sleep Apnea patients.

For any more information, please use our contact form.