DOS Batch File Help

Posted on 2011-05-04
Last Modified: 2012-05-11

Im trying to launch a bat file which clears out a few files from the users terminal server windows directory but Im not sure how to acheive this. Each time the user logs on, I want the batch file to run, I can get the file to run but I cannot get the syntax right to delete the file.

I tried this but its ignoring the %user% bit

del "c:\documents and settings\%user%\windows\start.ini"

Any ideas guys?

Question by:daiwhyte
    LVL 6

    Accepted Solution

    change %user% to %username%

    LVL 43

    Expert Comment

    by:Steve Knight
    If that is the user's profile directory too, you could use this in case something moves or is different for another user perhaps?


    I suggest you do this as one of the users run as "showme.cmd" or whatever from a logon script or cmd.exe etc.

    @Echo off

    If one of the variables is showing nearer the correct path for your users then use that, otherwise try %userprofile% as above, then your hard coded path with %username% like LHT_ST suggested above.


    Author Closing Comment

    thank you

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Numerous times I have been asked this questions that what is it that makes my machine log on so slow, there have been cases where computers took 23 minute exactly after taking password and getting to the desktop. Interesting thing was the fact th…
    Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    779 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

    15 Experts available now in Live!

    Get 1:1 Help Now