Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I am trying to make this batch file because all the company's PC's are turned on in the morning. We have a lot of hot desks so I want to make a batch file which will shut them down if no one is logged on.
This is it so far:
for /f %%a in (d:\shutdown\shutdown.txt) do (
psloggedon \\%%a > D:\Shutdown\shutdown.tmp
if %errorlevel% EQU 0 (
TYPE d:\shutdown\shutdown.tmp | find /i "xxx"
)
IF %errorlevel% NEQ 0 (
shutdown -s -m \\%%a
)
)
)Now this works fine up until "IF %errorlevel% NEQ 0" because it does not shut the sytem down.
Any idea's please, this has been bugging me for ages

Sorry, im new to the forum and i just realised that this should be in the programming section. :).
P.S Not back seat moderating but if mods want to delete :D

I work at a public Library and we have a Public Lab where users didn't seem to want to get off at closing time. We solved the problem using a shutdown utility program called Poweroff.
Poweroff is a program that lets you shutdown, log off, reboot, etc. even remotely.
Check it out here:
http://users.pandora.be/jbosman/pow...Also read this on how to set it for multiple PCs.
http://www.webjunction.org/do/Displ...You can even create a batch file that you can set up as a Scheduled Task to run at a set time.
Who knows, knows and who doesn't know, dosen't know jack!
El que sabe, sabe y el que no sabe, no sabe nada!

Hey there, thanks for that. Its a good program but doesnt do all i want it to do :(. I need to set it so that it does it when the pc is not logged on. I know if has the function where it can see if a process is running. But i dnt want to do a mass install :(.
Thanks tho

"... if NO ONE is logged on..."
In this scenario of yours, what happens if "userN" just walks away from his/her workstation without bothering to log off? All workstations stay powered up?
Then your 2nd post:"...when THE pc is not logged on..." suggests that you need to poll each individual workstation repeatedly and shut each down as the users log off... Confusing issues.
Presumably, you would execute that batch file on a fixed schedule (end of work shift, regardless of circumstances)?
A simple/cheap electrical timer might be just as useful/effective, depending on any other of your other what-IFscenarios...

I might use an autolog off and then use power settings to shutdown after set time.
I read it wrong and answer it wrong too. So get off my case you peanut.

With regards to "justcuz (by whitevalley)" post, I would run the batch file every night at end of the day from my pc using a Scheduled Task.
This is part of a .bat which I have made. I got another .bat which calls this which tells me how long the pc and user have been on and i read the report every day to see if it is just some one walking away from their PC all the time.
I would only run the bat file once. This is just a case of shutting down the hotdesks, not an automated shutdown for users. Thanks for the reply.
And in response to jefro, that would be so much easier I agree but my boss wont allow, saying they might have unsaved data. Thanks for the response

Solved it:
for /f %%a in (d:\shutdown\shutdown.txt) do (
psloggedon \\%%a > D:\Shutdown\shutdown.tmp
if errorlevel 0 ((
TYPE d:\shutdown\shutdown.tmp | find /i "server"
)
IF errorlevel 1 (
shutdown -m \\%%a -f -s
)))
regards
Strick80

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |