2

I was hoping I could have some help with this. I have about 300 computers that I have to clear all the temporary internet folders on and separately do a logoff on them.

Currently I have a file located on the C: drive that has the following command:

  • Clear temporary internet folders:

    RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 255
    
  • log off

    shutdown /l /t 0 /f
    

Here is the PSexec command I use to remotely execute that command on every computer:

@echo off

psexec @C:\_\complist.txt -u Admin -p PASSWORD -i.    c:\clearcache.cmd

The problem I am having is that it is taking really long, about 30 - 35 minutes because it does one at a time. Is there anyway I can speed this up? Maybe instead of doing 1 at a time I can do all at once?

If anyone can help improve the speed or help me find a better way I would be so grateful.

Thanks

Error I am getting when executing: Execute error

swstrau118
  • 181
  • 4
  • 7
  • 15

2 Answers2

2

the other way round: instead of doing all at once, do them separately. Sounds contraproductive? Parse complist.txt with batch and start psexec for each single computer instead of a list of computers:

for /f "delims=" %%i in (C:\_\complist.txt) do (
  start "%%i" psexec \\%%i -u Admin -p PASSWORD -i.  c:\clearcache.cmd
)

start creates a new process for executing psexec on every single computer and doesn't wait for it to finish, so they all run (nearly) parallel.

Stephan
  • 53,940
  • 10
  • 58
  • 91
  • What does it mean to parse complist.txt with batch? sorry I am a beginner at this. every which way I try to run the code it pops up with several screens but never executes the code. – swstrau118 Feb 14 '16 at 16:42
  • parsing means basically reading the file line by line. The `for` construct assigns each line of the textfile to the variable `%%i` (one after the other). You can then do something with `%%i` (in other words: do the same thing with every line) – Stephan Feb 14 '16 at 18:34
  • oh ok got ya - so I don't have to do anything to the actual complist.txt, if I understand correctly. So when I execute the script you wrote above - it doesn't actually execute the script on the computer itself . See the picture I took when running the script. – swstrau118 Feb 14 '16 at 18:45
  • I have no `psexec` installed, so I can't try. But the dot after `/i` looks quite suspicious to me. May that lead to a syntax error? – Stephan Feb 14 '16 at 18:50
  • would there be a better way other than using psexec? – swstrau118 Feb 14 '16 at 22:12
  • @swstrau118 there should not be a period in your code. Does the batch file exist in the root of the C: drive on each computer? – Squashman Feb 14 '16 at 22:18
  • The switch is `-i` to run the command interactively, think CMD.exe not a script so it's not needed in my opinion. – user4317867 Feb 15 '16 at 01:55
  • @Squashman II got it to work.. for the comp list I had \\HOSTNAME\c$ but I changed it to only show the hostname and now it works perfectly. Thanks all for your help! – swstrau118 Feb 15 '16 at 12:49
0

You could look at SCCM to run a script like this, lot of overhead if its not in place yet. But could be worth looking at for larger deployments in the future.

I have used PDQ Deploy in the past works well, they have a few levels of licensing including a free one depending on your business. DPQ Modes

Also have you considered pushing out a scheduled task that clears the IE favorites on a set date, this could also run the log off command but that could get messy. With a scheduled task in place could just run the log off command like you have in the past which wont be waiting for the clean command to finish.

If you have a domain you can use Group Policy to push out the scheduled task to the PCs saving you from making a import script and deploying that with psexec.exe.

Just a few Ideas for you.

Nat Thulke
  • 95
  • 2
  • 11