Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Complicated Batch Files

Status
Not open for further replies.

SteveAudus

Technical User
Oct 4, 2001
409
0
0
GB
I have a batch file i'd like to run on all my 90 workstations.

The file contains the such lines as
rmdir \\5001\c$\temp
md \\5001\c$\temp
rmdir \\5001\c$\winnt\profiles /S /Q
xcopy \\Server\profiles\replace\*.* \\5001\c$\winnt\ /E /H /C /Q

as you can see \\5001 is the name of the workstation.

I'd like to repeat the commands for each workstation,
is there any quick way of repeating the commands
for all the workstation, without having to copy
the commands and manualy changing the workstation name
on each line?

i.e 5001 to 5002 to 5003 etc..

Any suggestions?

Steve Audus
Chaucer Community School
 
How are the running the batch file? Directly from each machine? from a login script?

Is there any reason why your using a share name? Why not use c:\temp?
 
The script is run from the server each night/week.

I am using the share name to run the commands on each of machines c: drive.

Are you suggesting creating a generic script, copying it onto every C: drive then getting the server to run the scripts on each machine. Would this work?

Steve Audus
Chaucer Community School
 
Why not place it in the logon script so it runs every time that they log in.
 
I think that the solution of ensorg is the easiest one but if you really want to use that batchscript on every computer you can use \\%computername% to have the workstation name for each computer.
Realise that to run your batchfile you need (local or domain) administrator privileges (f.i. for removing the whole profiles folder).
to remove the profiles on the workstations you better use delprof (nt resource kit) where you can delete profiles remotely Wim Vanherp
Wim.Vanherp@belgacom.net
 
ensorg

Would it be possible to mess and delete items from the
%Systemroot%\profiles directory while logging on.

At what point is the user's profile directory created?

wimvanherp

Got a copy of delprof.exe, thanks I had never heard of it.
run it from the server deleting porfile from each workstation or run it on each workstation?

Thanks for all this help, it's great.

Steve Audus
 
we use delprof and this is how;

create a file called delprof.bat and type the following;

set server_name=%1
delprof /Q /I /C:\\%server_name%

Then create another file called dellprofcall.bat and type the following;

for /F %%x in (d:\delprof\server.txt) do (call d:\delprof\delprof.bat %%x) >>
d:\delprof\delprof.txt

Then create file called server.txt and type the names of all your servers etc.

Put all of the above files together with delprof on the same folder and run it as a schedule job on any box.

You could replace the %servername% with %computername%.

Hope this is helpful.
 
As a side note, rather than using a script/batch to remove profiles, I would recommend using the policy that removes profile on logout, you could use this along with your batch. This will prevent you from having to to your rmdir and your xcopy back (I assume you are xcopying the Default and All User profiles back over?)
It also allows you to run the rest of what you want to do at login using a script. Check out there you will find what I use for my login scripts.
 
Dear Jumparound,

Thanks for the message I will have a look at your site.

The delprof.exe with batch files now works great,
deleting the profiles of our users each night.
Leaving the default and All users directory,
there without any copying or replacing.

I have tried using "Delete cached roaming profiles"
in policy editor, but it does not work because our
users do not have raoming profiles, when they log on
they use locked up default profile. So as far as the workstation is concerned they are a local profiles.

Thanks again,
Steve Audus
 
Hi SSay I have read your help on delprof with interest as I have the same problem as Steve, with multiple users on a workstation all creating profiles.. Where you say
"Then create file called server.txt and type the names of all your servers etc." can I take it that I can Name all the computers in the net work here? or can I put DELPROF.exe on each and every computer and get a logoff script to run it? ie: delprof/q/i or is this not possible?
Any help on this would be appreciated by a stressed out school tech, Ta. :)I
Some lead, some follow....I just Hope!
 
itsfisko

Yep, I have called my server.txt file, comnames.txt, cause it makes more sense.

It contains nearly every computer name on my network,
and runs very successfully every night, I add and adjust the script regularly to do overnight tasks for me, mainly to counteract what the little sh*ts (pupils) have been upto on my machines.

I think it would be easier to do it as a log off script, but cause we are still on Win Nt 4 workstations, we don't have that option.

Hope this helps,
Steve Audus
Chaucer School
Sheffield, UK
 
Ditto,

We use roaming profile here and have AD which allows us to remove cached profiles on logoff.

However we are using the above scripts for our NT server to increased security for any hackers trying to retrieve passwords from locally cached profiles.

However the scripts works just as well for workstations. Just run the script from one server or workstation rather than no need to copy it yo all the worksations.

Good luck.
 
Thanks for your reply ssay, However I'am still stuck.. Delprof works if I run it manually on each machine (XP ) but I cannot seem to get it to run as a logoff script.
Any Ideas I am running server 2000 with 80 PCs on XP pro
The AD delete profile does not remove the profiles> Delprof does I just need to get it to run on logoff.
Cheers John Stress tech..:)I Some lead, some follow....I just Hope!
 
John,
sorry I can't help you with log off scripts as we are still stuck on Win NT Workstations, which logoff scripts do not run on.

I would suggest testing the log off funtion with a simple batch file doing somthing like creating a test folder, just to check that it's working. and work from there.

I didn't know delprof worked with XP, it's good to know.

If you still have no luck, I suggest starting a new post about log off scripts.

Steve
 
Thanks for your support Steve. I have started a new thread, heres hoping..... John Some lead, some follow....I just Hope!
 
Sorry, I have been doing a couple of projects.

We don't use logoff scripts, but if you have win2k environment like us, you could set There's a group policy option in Win 2k Server that is titled something like "Don't save cached profiles".

Otherwise, You can create a GPO to run a logoff script and define the location of the logoff script in a GPO Editor MMC. In a Group Policy MMC expand User Configuration\Windows Settings\Scripts.

Normally, a logoff script would be located in a SYSVOL$\DomainName\Policies\PolicyGUID\User\Scripts\Logoff.

alternatively, you could write a logoff script to query the registry key:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer
and look at the REG_DWORD named: "Shutdown Setting" The value is:
1 = during Logoff only
2 = during Shutdown
4 = during Restart

There's also the REG_DWORD named "Reason Setting" that seems to indicate something.... The value is:
0 = during Logoff only
5 = during Shutdown
5 = during Restart

You also need to test this when restart is "forced" by a installation setup.

Good luck.
 
THanks Ssay I will take a look at the things you mention and try them out.
John, Still stressed Some lead, some follow....I just Hope!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top