Options

Scheduled Task Question

the_erickeethe_erickee Member Posts: 74 ■■□□□□□□□□
This doesnt pertain to the test but to something I have been assigned here at work...

I have to come up with some way to schedule a massive system reboot every night for about 50 of our new workstations. What i have came up with was making a scheduled task for the reboot using shutdown.exe -r -f and everything goes great on my machine. but when i copy the task to a shared folder on the network, and i put it into other people's pc's, the username and password changes to theirs and they dont have the rights assigned to them to run the task.

So what I'm asking is if there is a way to push out a mandatory restart everynight at midnight other than the way im doing it. BTW all the pc's use XP Pro. Thats why i put it in this section.

Thanks in advance!
Erick Marshall - @erickbm

MCSE,MCITP x2,vExpert 2015,VCAP,VCP5 x2,MCSA x2,MCTS x3,MCP x2,UCP,Network+,A+

Comments

  • Options
    EssendonEssendon Member Posts: 4,546 ■■■■■■■■■■
    Nightwatchman does it at my company. It's not free but it does its job. Without using 3rd party software, perhaps a GPO for the new PC's that forces a shutdown after logon hours expire or something. Here's the link for Nightwatchman,

    http://www.1e.com/softwareproducts/nightwatchman/
    NSX, NSX, more NSX..

    Blog >> http://virtual10.com
  • Options
    astorrsastorrs Member Posts: 3,139 ■■■■■■□□□□
    Since its only 50 clients, why not use "shutdown -r -m \\computername" to reboot them all from a single computer. Use a VBScript (or a batch file with a for loop) to execute it for each of the computers (stored in a text file perhaps?). It will be much easier to administer from one machine than 50.

    If you need some help in figuring out the details, just let us know.
  • Options
    EssendonEssendon Member Posts: 4,546 ■■■■■■■■■■
    astorrs wrote:
    Since its only 50 clients, why not use "shutdown -r -m \\computername" to reboot them all from a single computer. Use a VBScript (or a batch file with a for loop) to execute it for each of the computers (stored in a text file perhaps?). It will be much easier to administer from one machine than 50.

    If you need some help in figuring out the details, just let us know.

    I'll probably let the experts take over icon_wink.gif
    NSX, NSX, more NSX..

    Blog >> http://virtual10.com
  • Options
    the_erickeethe_erickee Member Posts: 74 ■■□□□□□□□□
    We are actually trying to keep it local on each machine. Any other ideas?
    Erick Marshall - @erickbm

    MCSE,MCITP x2,vExpert 2015,VCAP,VCP5 x2,MCSA x2,MCTS x3,MCP x2,UCP,Network+,A+
  • Options
    astorrsastorrs Member Posts: 3,139 ■■■■■■□□□□
    We are actually trying to keep it local on each machine. Any other ideas?
    If you insist on having each machine perform its own automatic reboot, I would use schtasks.exe to create the scheduled tasks on each of the machines (it can just run "shutdown -r") from a single machine. Again you can either manually type the command to create the scheduled task, or you can use the aforementioned FOR loop or script to create them.
  • Options
    ranjitcoolranjitcool Member Posts: 80 ■■□□□□□□□□
    just un plug the fuse circuit of the room and put it back in :P

    oh wait u guys might have ups.. damn it.. ok unplug the ups then :D

    rj
    Cleared Network+, MCTS.
    Want to clear - CCSA, CCNA, VCP for now.

    Spending time @ www.itgrunts.com - Tech Juice, Not from Concentrate!
  • Options
    the_erickeethe_erickee Member Posts: 74 ■■□□□□□□□□
    ^^ Lol. yeah that might work. :)

    I think we are going to have to just go around to everyone's pc and set it up manually. Oh well. Thanks for the responses!
    Erick Marshall - @erickbm

    MCSE,MCITP x2,vExpert 2015,VCAP,VCP5 x2,MCSA x2,MCTS x3,MCP x2,UCP,Network+,A+
  • Options
    ranjitcoolranjitcool Member Posts: 80 ■■□□□□□□□□
    or u can write a script that will sent a force reboot .

    remember before sp2 was out we used to have some problem with the shutdown thingy in windows xp where u get a message with a 1 minute timer.

    it was fixed by sp2 and even now when i use my univ lab, the lab admin, who is a jack a** (will let u know why) bugs me by sending me that count down.

    i run a command sometimes like shutdown -f or something of that sort to stop it. mostly it fails!

    he has a way to stop it too.

    i will ask him how to do it and the right terminology.

    i hope u got the idea. i think its called rpc shutdown, however it wud reboot the system.

    so u wud have to write that command in a script either loop thru it 50 times or write it 50 times (if u r single loop thru it and get home quick, other wise spend time and type it 50 times :D)

    makes sense ?

    rj
    Cleared Network+, MCTS.
    Want to clear - CCSA, CCNA, VCP for now.

    Spending time @ www.itgrunts.com - Tech Juice, Not from Concentrate!
  • Options
    ranjitcoolranjitcool Member Posts: 80 ■■□□□□□□□□
    this is what i am talking about

    rpc_shutdown.jpg
    Cleared Network+, MCTS.
    Want to clear - CCSA, CCNA, VCP for now.

    Spending time @ www.itgrunts.com - Tech Juice, Not from Concentrate!
  • Options
    astorrsastorrs Member Posts: 3,139 ■■■■■■□□□□
    ^^ Lol. yeah that might work. :)

    I think we are going to have to just go around to everyone's pc and set it up manually. Oh well. Thanks for the responses!
    Maybe you missed my previous post. Run the following from a single computer and it will create local scheduled tasks on each of them. You will need to set the /U and /P switches to a domain administrator account (or at least one with admin privs on each of the clients), for the /RU and /RP switches you want to set the service account you want to use actually run the scheduled task under.

    Then just change <Computer> to the name of each client, run it from a command prompt, hit the up arrow, change the client name, hit enter, repeat x 50. Much faster.

    schtasks /Create /U <DOMAIN\Administrator> /P <Password> /RU <DOMAIN\Account to run task under> /RP <Password> /SC DAILY /TN "Daily Reboot" /TR "shutdown.exe -r -f" /ST 00:00:00 /S <Computer>
  • Options
    ranjitcoolranjitcool Member Posts: 80 ■■□□□□□□□□
    lmao i got it..

    ok this is what u shud do, assuming u have rights to execute on the 50 systems

    the shutdown -r

    gives the rpc shutdown/reboot timer of 30 seconds

    and after that the system will reboot

    i think thats the best solution.

    BUT... ok theres always a big BUT.. if u have an admin or some smart user on the system. he can issue shutdown -a to stop it

    UNLESS..ok theres a big unless also... if u have a group policy object that does not allow users to issue commands or execute commands in the cmd, he will be power less

    i think this will be a perfect solution to u r problem.

    now think of a script to type in teh shutdow -r (try it on ur own pc)

    if it were in linux, i wud write a shell script /ip/ shutdown -r and so on.. and put it as a cron job to execute every mid night

    thanks and hope this helps and no offends about my stupid jokes.. i try to be funny

    rj
    Cleared Network+, MCTS.
    Want to clear - CCSA, CCNA, VCP for now.

    Spending time @ www.itgrunts.com - Tech Juice, Not from Concentrate!
  • Options
    ranjitcoolranjitcool Member Posts: 80 ■■□□□□□□□□
    astorrs wrote:
    We are actually trying to keep it local on each machine. Any other ideas?
    If you insist on having each machine perform its own automatic reboot, I would use schtasks.exe to create the scheduled tasks on each of the machines (it can just run "shutdown -r") from a single machine. Again you can either manually type the command to create the scheduled task, or you can use the aforementioned FOR loop or script to create them.

    oh dear.. i didnt read this that he had already mentioned about this..

    oopsy! and now i did , its a pretty good explanation of what was on my mind..

    thanks
    rj
    Cleared Network+, MCTS.
    Want to clear - CCSA, CCNA, VCP for now.

    Spending time @ www.itgrunts.com - Tech Juice, Not from Concentrate!
  • Options
    bjaxxbjaxx Member Posts: 217
    ranjitcool wrote:
    astorrs wrote:
    We are actually trying to keep it local on each machine. Any other ideas?
    If you insist on having each machine perform its own automatic reboot, I would use schtasks.exe to create the scheduled tasks on each of the machines (it can just run "shutdown -r") from a single machine. Again you can either manually type the command to create the scheduled task, or you can use the aforementioned FOR loop or script to create them.

    oh dear.. i didnt read this that he had already mentioned about this..

    oopsy! and now i did , its a pretty good explanation of what was on my mind..

    thanks
    rj

    ranjitcool -

    how many redbulls or cups of coffee did you have this am?


    Stick with astorrs solution - he's giving it to you on a platter.
    "You have to hate to lose more than you love to win"
  • Options
    ranjitcoolranjitcool Member Posts: 80 ■■□□□□□□□□
    had tea with some honey in it, but got that honey from starbucks..

    oh wait, cafinated honey.... oh dear!

    :)
    Cleared Network+, MCTS.
    Want to clear - CCSA, CCNA, VCP for now.

    Spending time @ www.itgrunts.com - Tech Juice, Not from Concentrate!
  • Options
    the_erickeethe_erickee Member Posts: 74 ■■□□□□□□□□
    astorrs wrote:
    ^^ Lol. yeah that might work. :)

    I think we are going to have to just go around to everyone's pc and set it up manually. Oh well. Thanks for the responses!
    Maybe you missed my previous post. Run the following from a single computer and it will create local scheduled tasks on each of them. You will need to set the /U and /P switches to a domain administrator account (or at least one with admin privs on each of the clients), for the /RU and /RP switches you want to set the service account you want to use actually run the scheduled task under.

    Then just change <Computer> to the name of each client, run it from a command prompt, hit the up arrow, change the client name, hit enter, repeat x 50. Much faster.

    schtasks /Create /U <DOMAIN\Administrator> /P <Password> /RU <DOMAIN\Account to run task under> /RP <Password> /SC DAILY /TN "Daily Reboot" /TR "shutdown.exe -r -f" /ST 00:00:00 /S <Computer>

    I did read it but we dont want to place the admin pw in plain text. we are a nonprofit government agency and this script is going on government systems to comply with security agreements. sorry for leaving out so much detail.
    Erick Marshall - @erickbm

    MCSE,MCITP x2,vExpert 2015,VCAP,VCP5 x2,MCSA x2,MCTS x3,MCP x2,UCP,Network+,A+
  • Options
    astorrsastorrs Member Posts: 3,139 ■■■■■■□□□□
    I did read it but we dont want to place the admin pw in plain text. we are a nonprofit government agency and this script is going on government systems to comply with security agreements. sorry for leaving out so much detail.
    No problem. As this isn't a script, the admin password will not be stored in plain text, you just enter the above line from a command prompt and it will create the scheduled task on the remote computer in the exact same method as you had logged into the machine as an admin and set the task to run as a specific service account (the one defined by the /RU switch). Nothing is stored (just close the command prompt window on your own system when you're done).

    P.S. I would never suggest you leave an unencrypted username/password anywhere, don't worry. ;)
  • Options
    sprkymrksprkymrk Member Posts: 4,884 ■■■□□□□□□□
    astorrs wrote:
    Then just change <Computer> to the name of each client, run it from a command prompt, hit the up arrow, change the client name, hit enter, repeat x 50. Much faster.

    schtasks /Create /U <DOMAIN\Administrator> /P <Password> /RU <DOMAIN\Account to run task under> /RP <Password> /SC DAILY /TN "Daily Reboot" /TR "shutdown.exe -r -f" /ST 00:00:00 /S <Computer>

    Or rather than change the <Computer> name and enter the command 50 times, use a "for" loop with a text file of the computer names, or even easier, the IP Addresses. Let's say your IP addresses are 192.168.1.10-50, use this from a cmd prompt:
    for /L %C in (10,1,50) do schtasks /Create /U <DOMAIN\Administrator> /P <Password> /RU <DOMAIN\Account to run task under> /RP <Password> /SC DAILY /TN "Daily Reboot" /TR "shutdown.exe -r -f" /ST 00:00:00 /S 192.168.1.%C
    

    Type that once and you're done. The numbers in parentheses above (10,1,50) are your start, step, end numbers for the last octet of the ip scheme. Starting at 10, then incrementing by 1 up to 50. If you have an easy way to create a text file fo computer names and want to use that rather than an IP address use something like this:
    for /F %C in (C:\temp\computernames.txt) do schtasks /Create /U <DOMAIN\Administrator> /P <Password> /RU <DOMAIN\Account to run task under> /RP <Password> /SC DAILY /TN "Daily Reboot" /TR "shutdown.exe -r -f" /ST 00:00:00 /S 192.168.1.%C
    
    All things are possible, only believe.
  • Options
    undomielundomiel Member Posts: 2,818
    I was waiting for sprkymrk and his love of the FOR loop to jump in on this. :)
    Jumping on the IT blogging band wagon -- http://www.jefferyland.com/
  • Options
    the_erickeethe_erickee Member Posts: 74 ■■□□□□□□□□
    Thanks for the replies again. I will try the above solution. if i was going to make the *.txt file, would i list the computers like this:

    PC1
    PC2
    PC3

    or like this:

    PC1,PC2,PC3
    Erick Marshall - @erickbm

    MCSE,MCITP x2,vExpert 2015,VCAP,VCP5 x2,MCSA x2,MCTS x3,MCP x2,UCP,Network+,A+
  • Options
    undomielundomiel Member Posts: 2,818
    PC1
    PC2
    PC3
    Jumping on the IT blogging band wagon -- http://www.jefferyland.com/
  • Options
    astorrsastorrs Member Posts: 3,139 ■■■■■■□□□□
    undomiel wrote:
    I was waiting for sprkymrk and his love of the FOR loop to jump in on this. :)
    Yup, FOR loops are great things, they work on every Windows O/S (I care to support).

    If you want to quickly **** a list of all the computers in your domain to a text file you can use for this (prune it after if there are machines you don't want to include) you could always use another FOR loop to generate it:

    for /f "tokens=1,*" %c in ('net view') do @echo %c >> computers.txt
  • Options
    the_erickeethe_erickee Member Posts: 74 ■■□□□□□□□□
    IT WORKS!!

    Thanks guys. You made my job easy again. lol. This site is amazing. I love it!
    Erick Marshall - @erickbm

    MCSE,MCITP x2,vExpert 2015,VCAP,VCP5 x2,MCSA x2,MCTS x3,MCP x2,UCP,Network+,A+
  • Options
    sprkymrksprkymrk Member Posts: 4,884 ■■■□□□□□□□
    IT WORKS!!

    Thanks guys. You made my job easy again. lol. This site is amazing. I love it!

    Great news, and thanks for the update.

    To further complicate the issue though (which is always fun) if you want to save the above command as a batch file so you dont have to retype it every time you want to reboot the computers, make sure to use double percent symbols in front of your variables like this:
    for /F %%C in (C:\temp\computernames.txt) do schtasks /Create /U <DOMAIN\Administrator> /P <Password> /RU <DOMAIN\Account to run task under> /RP <Password> /SC DAILY /TN "Daily Reboot" /TR "shutdown.exe -r -f" /ST 00:00:00 /S 192.168.1.%%C
    

    The "for" command is funny about that. Type it at a cmd prompt, you use single %, save it as a batch file, use double %%.
    All things are possible, only believe.
  • Options
    sprkymrksprkymrk Member Posts: 4,884 ■■■□□□□□□□
    undomiel wrote:
    I was waiting for sprkymrk and his love of the FOR loop to jump in on this. :)

    I couldn't resist! icon_lol.gif

    And astorrs made it easy for me; copy, paste, add about 10 seconds worth of editing and *poof* my job was done. :D
    All things are possible, only believe.
  • Options
    BeaverC32BeaverC32 Member Posts: 670 ■■■□□□□□□□
    Just out of curiosity, what is the reason behind rebooting 50 workstations every night??
    MCSE 2003, MCSA 2003, LPIC-1, MCP, MCTS: Vista Config, MCTS: SQL Server 2005, CCNA, A+, Network+, Server+, Security+, Linux+, BSCS (Information Systems)
  • Options
    the_erickeethe_erickee Member Posts: 74 ■■□□□□□□□□
    ^^

    rebooting will prevent small problems most of our users run into. and government is making us. lol :P
    Erick Marshall - @erickbm

    MCSE,MCITP x2,vExpert 2015,VCAP,VCP5 x2,MCSA x2,MCTS x3,MCP x2,UCP,Network+,A+
Sign In or Register to comment.