Solved

Logon Script

Posted on 2004-10-29
367 Views
Last Modified: 2010-04-10
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
0
Question by:daleoran
    16 Comments
     

    Accepted Solution

    by:
    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
     
    LVL 3

    Assisted Solution

    by:cmsJustin
    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
     

    Expert Comment

    by: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
    0
     
    LVL 10

    Author Comment

    by:daleoran
    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
     
    LVL 18

    Expert Comment

    by:Sham Haque
    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
     
    LVL 10

    Author Comment

    by:daleoran
    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
     
    LVL 18

    Expert Comment

    by:Sham Haque
    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
     
    LVL 18

    Assisted Solution

    by:Sham Haque
    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
     
    LVL 18

    Expert Comment

    by:Sham Haque
    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
     
    LVL 10

    Author Comment

    by:daleoran
    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
     
    LVL 3

    Expert Comment

    by:cmsJustin
    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
     
    LVL 10

    Author Comment

    by:daleoran
    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
     
    LVL 10

    Author Comment

    by:daleoran
    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
     
    LVL 18

    Expert Comment

    by:Sham Haque
    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
     
    LVL 10

    Author Comment

    by:daleoran
    Sorry for the delay - I've been side-tracked and will get back asap.
    Thanks for you patience

    Michael
    0
     
    LVL 10

    Author Comment

    by:daleoran
    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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    The DSL Parameters part of this article is valid and can be considered with any brand of internet router and modem (Dlink, 3com, Alcatel, Usrobotics, Parks), by accessing the configuration interface available by the manufacturer eg: http://10.1.1.1 …
    Don’t let your business fall victim to the coming apocalypse – use our Survival Guide for the Fax Apocalypse to identify the risks and signs of zombie fax activities at your business.
    Viewers will learn how to connect to a wireless network using the network security key. They will also learn how to access the IP address and DNS server for connections that must be done manually. After setting up a router, find the network security…
    After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…

    913 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now