Link to home
Start Free TrialLog in
Avatar of blowfly
blowfly

asked on

Kix32/.bat files locating local profile path

Hello,

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.
ASKER CERTIFIED SOLUTION
Avatar of sr75
sr75
Flag of United States of America image

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

ASKER

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.
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.  
Avatar of blowfly

ASKER

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. :)