Link to home
Start Free TrialLog in
Avatar of daleoran
daleoranFlag for United Kingdom of Great Britain and Northern Ireland

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of jjernst
jjernst

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jjernst
jjernst

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
Avatar of daleoran

ASKER

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
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
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
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?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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?]
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

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
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

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

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
Sorry for the delay - I've been side-tracked and will get back asap.
Thanks for you patience

Michael
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