Logon Script

Hi There,
please excuse my ignorance but how do you write a logon script that will do the following:


1/ Delete the folder - c:\Program Files\RealDownload
2/ Delete the folder - c:\Program Files\RealRealJukebox
3/ Delete the folder - c:\Program Files\RealPlayer
4/ Do this without notifying the user - i.e no dialogue boxes appear asking if it's alright to delete the files
5/ Sorry it should check if the folders in 1-3 exist first then delete them if they do, else exit script if they don't

Win NT4 Servers
Win98 Workstations

Many Thanks in advance

Michael
LVL 10
daleoranAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jjernstCommented:
Hi Michael,

Two parts:

First, you need to write a batch file containing the commands. Jus in case, here's a short 'how to' on writing batch files:

- Create a new text document.
- Edit the document and add the commands which need to be executed by the script. In your case the commands should be:

IF  EXIST "c:\program files\realdownload" RD "c:\program files\realdownload" /y
IF  EXIST "c:\program files\realrealjukebox" RD "c:\program files\realrealjukebox" /y
IF  EXIST "c:\program files\realplayer" RD "c:\program files\realplayer" /y

- Save and close the file
- Change it's file extention from .txt to .bat. You need to have the display options in your explorer configured to display all file extentions, even the known ones.
- Copy the script to the following folder on the NT4 Server: c:\winnt\system32\repl\import\scripts
Once the script is there, it should replicate to the other servers.

Second, in the user administration window on the server, you need to add the script to each user on whose PC you want it to run at login.
Open the user's properties window and, i think on the second tab, you should find a text field labled 'logon script'. You need to add the path to the logon script there. Once done, confirm with ok. As soon as all the replications have been completed successfuly between the servers, the settings should take effect.

One thing I'd like to point out: in windows 98, the login script runs visibly, meaning a command prompt will open and execute the commands and the user will see that command prompt. The user can also close it by clicking on the 'x' button, thus interrupting the batch file... It is a little problem, to which i don't know if there are any solutions under win 98.
All I know is that from win 2k up, you can use group policy to hide the login script and even tell it to not load the user's desktop and settings before the script has finished.

Hope this helped you. Tell me if it worked.

Regards, Christian
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
cmsJustinCommented:
It might be a good idea to add the following lines to the beginning of the script:

@echo off
cls

This will make it so that the user cannot see the process at all

-Justin
0
jjernstCommented:
Thanks Justin! Good idea.

So that makes:

@echo off
cls

IF  EXIST "c:\program files\realdownload" RD "c:\program files\realdownload" /y
IF  EXIST "c:\program files\realrealjukebox" RD "c:\program files\realrealjukebox" /y
IF  EXIST "c:\program files\realplayer" RD "c:\program files\realplayer" /y

Regards
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

daleoranAuthor Commented:
Hi All,
Many thanks for the replies. So what am i I doing wrong? :(
jjernst - I've done exactly as you have described in you post (ignoring the 'echo off' for now - will add later)
But nothing seems to be happening. When I log in as the test user I see the message 'Please wait to your login script is executed' (or words to that effect). But when I check the C: drive the folders are still there.
If I copy the .bat file onto the C: drive and execute it there the same thing happens - the folders remain.

Any ideas?

Michael
0
Sham HaqueSenior SAP CRM ConsultantCommented:
are you sure your users log in with sufficient priveleges to be able to remove these folders?

if so, then i wonder what the prob is apart from the bat jjernst suggested.
i'm not sure why you're bothering to do the check if they exist - it ignores if they're not there anyway.

try this instead:

del "c:\program files\realdownload\*.*" /q /s
del "c:\program files\realrealjukebox\*.*" /q /s
del "c:\program files\realplayer\*.*" /q /s
RD "c:\program files\realdownload" /q /s
RD "c:\program files\realrealjukebox" /q /s
RD "c:\program files\realplayer" /q /s

the /q switch operates in "quiet" mode, meaning in the background without your users seeing anything.

instead of adding it to the login script, try adding it to the startup folder for the user - maybe something like "c:\windows\profiles\start menu\startup"
this then runs AFTER logon but before they can use the PC.

suck it and see.....

Shammy
0
daleoranAuthor Commented:
Hi Shammy,
Nearly there - I think
The script runs if I put it in the startup but I get an 'Invalid switch' error message for both the /q & /s
If I remove these switches I'm asked if I want to delete the files - I want to avoid this.

Any ideas?

Michael
0
Sham HaqueSenior SAP CRM ConsultantCommented:
your workstations running Win98?
it's been a while since i used that baby - what options do you get when you type "del /?" in a command window?
0
Sham HaqueSenior SAP CRM ConsultantCommented:
ok - remove the /q /s switches - weren't introduced for DOS 7.1!

with no switch you should get no confirmation (only available switch for DEL is /p - which is force confirmation)

you could also try adding a >nul redirector - output does not go to screen then
del "c:\program files\realdownload\*.*"

another alternative is to use DELTREE with a /y switch - this does away with the need to use DEL then RD.
eg

deltree "c:\program files\realdownload" /y
deltree "c:\program files\realrealjukebox" /y
deltree "c:\program files\realplayer" /y

it's been a while since i was down that road.....

0
Sham HaqueSenior SAP CRM ConsultantCommented:
the middle bit should've read:

del "c:\program files\realdownload\*.*" >nul

[mods: could you not look at answerers being able to edit posts pls?]
0
daleoranAuthor Commented:
Hi gbshahaq
many thanks for the replies. Unfortunately I'm not back to work until Monday, so if you can hang fire 'til then I'll let you know how it goes.

Michael

0
cmsJustinCommented:
Maybe try to replace RD with RMDIR. I think the sytax may have been different on NT4.
Or try the other suggestions above.
I dont think DEL will delete directories, only files.

-Justin
0
daleoranAuthor Commented:
Hi All,
sorry, but all the above suggestions still leave me being asked to confirm the deletion of the files (which I don't want). Whats the command to see the version of dos that's running?

Michael

0
daleoranAuthor Commented:
have found this switch - if I create a txt file containing just the letter y and a carriage return and then use the switch <yes.txt as shown below the files are deleted with no confirmation :)

rem
rem delete RealPlayer
rem
del "c:\program files\realplayer\msg\*.*" <yes.txt
del "c:\program files\realplayer\setup\*.*"  <yes.txt
del "c:\program files\realplayer\*.*"  <yes.txt

Once this is done how do I close the command window - I thought putting 'exit' (without the quotes) at the end of the .bat file would do it but it doesn't

Michael

0
Sham HaqueSenior SAP CRM ConsultantCommented:
WIN NT, 95, 98, ME:

use deltree with a /y parameter - to suppress prompts
eg. deltree "c:\program files\realdownload" /y

Win 2000, XP:

use RD / RMDIR with a /s /q parameter - to suppress prompts
eg. RD "c:\program files\realplayer" /q /s

if you have the redirector >nul on, it will suppress showing the files removed.
as long as you have this set as is, and save as a bat file, the DOS window definitely should close after deleting

Shammy
0
daleoranAuthor Commented:
Sorry for the delay - I've been side-tracked and will get back asap.
Thanks for you patience

Michael
0
daleoranAuthor Commented:
Again I apologise for not getting back to you on this one. I have been side tracked but will get back to this asap - the joys of being a one man IT dept :)

Thanks for your patience

Michael

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Networking

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.