Is there a script "to log remote users off and after log them off to delete their profiles?

1

I found 6 simple scripts (.bat and .vbs) for remote pcs (Win XP and 7) to Clean Profile properly and faultlessly:

  1. Script: sending Ping to check Remote PC On or Off (.bat)

  2. Script: checking who logged in/on Remote PC (.bat)

  3. Script: restarting remote PC with a warning message (.bat)

  4. Script: restrict the Remote Users to log on/in till I finish works (.bat)

  5. Script: deleting Remote Users Profile (folder-subfolder-files) and their Regedit Keys (.vbs)

  6. Script: removing restriction the Remote Users to log on/in till I finish works (.bat)

I don't know how we can combine these 6 scripts.
Is there any script you know (doing 6 scripts job via one script)?
By the way, Windows Remote Desktop really takes a long time compared to 6 scripts, so we need to use a more simple way.

Thank you in advance and sorry for my bad English.

serdar

Posted 2014-06-04T10:01:49.260

Reputation: 515

its trivial to write a batch file or powershell script to simply call the scripts in question, but your biggest issues will be getting those scripts to execute on the logout event while running for the user being deleted, and how to handle the reboot. that pretty much means that you will have to schedule multiple jobs. – Frank Thomas – 2014-06-04T11:47:38.600

I am only smiling :) – serdar – 2014-06-04T14:51:35.547

Answers

0

First, If it's an option, I'd strongly suggest you to move to Powershell. It's a bit hard to learn an migrate, but it pays off.

As to the matter at hand, what are you trying to achieve? it sounds like you're trying to create mandatory profiles by hand...

Anyway, 1. you can either "ping" the user's session, or 2. attach the cleaning task to the user's logoff.

  1. If you want to check repeatedly if a user is logged on, you can use the script you already have inside a loop, until you get an empty result (meaning there's no user logged-on).

  2. If you want to attach it to the logoff event, you can using the event viewer of some group policy, but I think it would be a bad idea - it'll somewhat complicate things and you'll have less control (comparing to the previous solution).

EliadTech

Posted 2014-06-04T10:01:49.260

Reputation: 2 076

We want to combine 6 working script. – serdar – 2014-06-05T06:59:36.493

These 6 scripts work properly seperately! – serdar – 2014-06-05T07:00:37.117

Exactly, they are already working, so where's the problem to combine them? You can make one central script that calls all other scripts, and as I said above, "ping" the user session with your script and only then move on. – EliadTech – 2014-06-05T10:54:06.707

I didnt make 6 scripts, only I found :( – serdar – 2014-06-05T12:05:03.617

And I dont know how I can combine them :( – serdar – 2014-06-05T12:05:29.560

I'll try to rewrite your scripts in powershell (it could also be done with batch, but I realy hate it). – EliadTech – 2014-06-05T12:22:18.753

Oh, by the way, why do you bother check who is logged on before sending a message and restarting the computer? Why not skip that check? – EliadTech – 2014-06-05T12:24:05.250

One more thing you haven't answered - are you trying to create manually mandatory profiles? why do you want to clean remote profiles? where all users' data goes? – EliadTech – 2014-06-05T12:31:26.477

We dont want to use Powershell or Win Remote Desktop (mstsc), It is really very easy to use VBS or BAT scripts. – serdar – 2014-06-05T20:01:40.210

We have to warn USERS before we log them off or restart their pc because they are officer workers and they work for people formal things – serdar – 2014-06-05T20:03:56.700

Totaly, there are nearly 10000 workers (officers)in our network, and sometimes we have to delete a couple of profiles because of some problems – serdar – 2014-06-05T20:07:31.913

So vbs and bat scripts make our jobs easier :) and faster compared to Win Remote Desktop. Now, we can do what we want but via 6 steps :) – serdar – 2014-06-05T20:09:46.397

We had better do what i want via one step by entering an IP or HostName on a script – serdar – 2014-06-05T20:11:55.350

For ex: We want to delete this 10.101.12.52 PC's remote profiles (except local ones) and we learned this PC is on via sending Ping; and one user is using this pc; namely, user is logged on/in this pc. We have to warn the user before we log him/her off, and after then we need to delete all remote profiles including registry keys in ProfileList. So; before deleting the profiles and theirs reg keys, firstly, we have to restrict the users to log on/in again till finishing the deleting profiles. After then we remove concerning restriction. In sum all process i try to describe takes 1 or 2 minutes. – serdar – 2014-06-05T20:24:41.960