Kix32/.bat files locating local profile path


I have a log off script running through  the GP. Every time a user shutdown/logs off specific parts of their profile are backed up.

The only problem is I have hard coded the profile path.

In some instances windows changes the profile path, eg,

Windows will concatenate a .000 onto the profile path, or it might concatenate the domain onto the end of the persons profile name.

The concatenation of these values above causes my statically coded values to become redundant.  I am now looking for a dynamic solution.

Can anyone suggest a way where I can obtain the profile path of a person through "Kix32" or at very least a .bat file.
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.

%userprofile% is the DOS environmental variable that gives you a user's profile path

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
blowflyAuthor Commented:
I have tried that before but failed.

I was using this in my batch file:

copy %userprofile%\FILE1.txt C:\File.txt

I get the following after:

The system cannot find the file specified.

Can anyone help me with this.
you should have used

copy "%userprofile%\FILE1.txt" C:\File.txt

because %userprofile% has spaces that copy cannot handle.  The quotes extend it to a proper file path.
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

To make it "sweet" do this:

echo @copy /y  "%userprofile%\FILE1.txt" C:\File.txt >routine.bat

This will create a file called "routine.bat" and it will contain a command (copy /y "%userprofile%\FILE1.txt" C:\File.txt) and will execute it silently (@).  Stick this in the shutdown process (or startup process) and all you'll see is the dos-box-flash.  
blowflyAuthor Commented:
I just realised  that I forgot the "  "
Yes, help can be found. :)
What forrestoff said is absolutely true and using the quotes should correct the "...cannot find the file..." errors.

Beyond that however;

The concatenation of .000 or the domain name to the users profile folder may indicate that the user no longer has full permissions to ALL files within their folders. This often happens when a script copies a file into the users profile or is running under other credentials and creates a new file. At least thats one possibility.

In general terms; what is the script intended to accomplish?

You've indicated you are using XP Operating System. I'm guessing it is probably XP Pro SP2 and is in a Domain environment since you indicated the script is driven by Group Policy. Please correct my assumptions if they are not accurate.

Guess I should have refreshed page before posting. :)
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
Microsoft Legacy OS

From novice to tech pro — start learning today.