Creating Folder behind session id # script

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

Our users who log onto our RDP farm (server 2008 r2) are unable to print from i.e 8, they just get a blank page with a file location printed across the bottom.  I know the reason for this, the \Low folder is not being created in the %temp% folder.  After researching I have found this bat fix from microsoft.

Mkdir %TEMP%\Low
Icacls %TEMP%\Low /setintegritylevel Low

If I log onto the farm as a user and run this bat, it works 100% fine and fixes the issues people are having with the printing.  However I want this to automate the procedure as each time they log off that folder is deleted, so I tried a logon script, I also tried a scheduled task in the GPO, as well as trying a folder creation.  None of these work.  Trying to automate the process meant the Low folder is created before the session ID.  

For example

Appdata\Local\Temp\Low\session id number\

However it should be

Appdata\local\Temp\Session id Number\Low

I tried adding a delay to a scheduled log on task of 30 seconds to see if the system needed to assign a session ID # before continuing.  But this does not work either.

Ive tried the following additions to the script..
Mkdir %TEMP%\%SESSIONNAME%\Low (this creates a RDP_TCP#session id folder)
Mkdir %TEMP%\%ID%\Low

All that these do is make a folder called the additions..

I just want to create the Low folder behind the numbered session ID folder!

Any ideas.. assistance ?
Question by:lost_in_data
    LVL 8

    Expert Comment

    not sure if i get this question correctly.

    You can get the session Id by using below command..


    now, use mkdir to create a folder with the session id number it gives as output in temp..

    Author Comment

    No I dont think that answers the question at all.  Session ID is assigned at login, I know how to get that information.  I need to make a folder in the user %TEMP% directory behind the session ID named folder it makes when you log on.

    As an example ( I've choosen a random number),

    User\%USERNAME%\Appdata\local\Temp\  this directory always exists

    when the user logs onto any of the RDP farm servers, it creates a folder with a session id in the last directory


    I am trying to create the low folder after that session id folder is made, like i said before, if the user clicks the bat file everything works fine, using the cmd above.  However if I prompt the gpo to run this script during login, or set it as a task on a delay of 30 seconds, which I want, it places the low folder in the temp directory and not in the session id folder that is made when the user logs on.  It seems like that folder is made last or something.
    LVL 8

    Accepted Solution

    how about putting the script in to startup folder of all users. instead of running through GPO or startup script

    Author Closing Comment


    Not sure why it works over a script or scheduled task through the GPO but I am not complaining.  

    Just fyi.. Starup on Server 2008 is here!
    C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup

    Thanks alot man !
    LVL 8

    Expert Comment

    you welcome, Did it worked  ?

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    We were having a lot of "Heartbeat Alerts" in our SCOM environment, now "Heartbeat" in a SCOM environment for those of you who might not be familiar with SCOM is a packet of data sent from the agent to the management server on a regular basis, basic…
    Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
    This tutorial will walk an individual through the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…
    The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

    732 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

    24 Experts available now in Live!

    Get 1:1 Help Now