Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: RE: RE: RE: RE: RE: RE: RE: global macro for system directory?


From   Eric Booth <[email protected]>
To   [email protected]
Subject   Re: st: RE: RE: RE: RE: RE: RE: RE: global macro for system directory?
Date   Sun, 10 Jan 2010 12:25:15 -0600

>

I think changing the paths in the do-files (either by using find/replace, as Martin suggested, or across a lot of do-files at once using something like what I posted) has some advantages over the OS mklink solution.  
Systematically changing the paths in the do-files can be done by any machine despite the platform (ex: my move from Windows to Mac) or the administrator rights.   Though David is using the Administrator directory, this doesn't mean that he has full admin rights, some of his admin tasks might be restricted in active directory by a network admin  (Also, I agree with your point that David should change his account from administrator).  
Besides, learning & implementing a find/replace solution is useful if you work on various machines (ex:  one at home, the office, and one in the computer lab, all with different filepath structures and levels of admin access), or if you want to send a set of do-files to colleagues and you want to change all the paths so that they can run the file.
If you were changing the directory to mounted drives or network locations, as I needed to do in my example, a symbolic link wouldn't work in a pre-Vista version of Windows (only Vista/Win7 have NTFS symlinks that can point to smb).  
Finally, I think your warning about doing a lot of damage is on point.  I once did an immediate delete (or shift+delete) of a symlink in Windows and it deleted all the target files, not just the shortcut...while symlinks look like shortcuts, they operate differently & the user needs to be mindful of how you remove or relocate the files with symlinks.

~ Eric
__
Eric A. Booth
Public Policy Research Institute
Texas A&M University
[email protected]
Office: +979.845.6754


On Jan 9, 2010, at 5:55 PM, Hoffman, George wrote:

> This is a windows problem.
> It sounds as if your username was DW, and now is administrator. This is the default windows admin account. I would strongly suggest that you set up a new username that is not administrator. But you may think it is too late for that.
> 
> There is a way to create a junction link to the administrator home directory. In vista and win7, junction links are used to map the xp-style directory structure to newer vista structure.
> As an example "c:\documents and settings" is actually a symbolic link to "c:\users"
> 
> You 'could' create a junction directory "c:\users\dw" that maps to "c:\users\adminstrator" (which would also map "c:\documents and settings\dw" to "c:\documents and settings\administrator") using the 'mklink' command from an elevated-privilege command prompt.
> 
> Here is the windows explanation:
> 
> mklink
> Creates a symbolic link.
> 
> MKLINK [[/D] | [/H] | [/J]] Link Target
> 
>        /D      Creates a directory symbolic link.  Default is a file
>                symbolic link.
>        /H      Creates a hard link instead of a symbolic link.
>        /J      Creates a Directory Junction.
>        Link    specifies the new symbolic link name.
>        Target  specifies the path (relative or absolute) that the new link
>                refers to.
> 
> To do this:
> 
> 1. Open an elevated command window (right-click c:\windows\system32\cmd.exe and select 'run as administrator')
> 
> 2. Change to the c:\users directory:   
> 
>     cd c:\users
> 
> 3. Make a directory junction from a directory 'dw' to the 'administrator' directory:
> 
>   mklink /j  dw   administrator
> 
> 4. check the directory listing to make sure it worked correctly:
>   'dir' and you should see something like:
> 
> Volume in drive C has no label. 
> Volume Serial Number is C4D0-XXXX
> 
> 01/09/2010  05:30 PM    <DIR>          .
> 01/09/2010  05:30 PM    <DIR>          ..
> 01/09/2010  05:29 PM    <DIR>          Administrator
> 07/14/2009  01:48 AM    <DIR>          Public
> 01/09/2010  05:30 PM    <JUNCTION>     dw [C:\Users\Administrator]
> 
> 
> Be careful. You can do a lot of damage this way. But it will work to fix your problem.
> george
> 
> 
> 
> 
> 
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On Behalf Of [email protected]
> Sent: Saturday, January 09, 2010 5:20 PM
> To: [email protected]
> Subject: RE: st: RE: RE: RE: RE: RE: RE: RE: global macro for system directory?
> 
> Sounds more like a case for a search and replace operation in your favorite text editor than a Stata problem.
> HTH
> Martin
> 
> -original message-
> Subject: st: RE: RE: RE: RE: RE: RE: RE: global macro for system directory?
> From: David Wallace <[email protected]>
> Date: 09-01-2010 23:59
> 
> 
> I have a similar issue with migrating Stata to a new laptop and running my .do file.  Can I change my hardcoded file paths in all my old .do files by specifying a macro that can reroute the filepaths used in a .do file?  So if my .do file says   " use "C:\Documents and Settings\DW\My Documents\thesis.dta", clear " can I specify an macro that will reroute all the "C:\Documents and Settings\DW\My Documents" part in .do files to something like "C:\Documents and Settings\administrator\Documents\"  ????
> 
> 
> 
> 
> 
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Hoffman, George
> Sent: Samstag, 9. Januar 2010 05:33
> To: [email protected]
> Subject: st: global macro for system directory?
> 
> I recently reinstalled stata 10 on my computer with a new os (windows 7). On my old computer, I had installed in "c:\program files\stata". On the new computer, it was in "c:\program files\stata10" by default. I had previously written a bunch of ado and do files for data and log file manipulation that referenced hardcoded directories under "c:\ptogram files\stata".
> 
> I know that the sysdir command will reveal the STATA directory to be the install directory. Is there a way to retrieve that into a macro or tempvar that I can then reference from a do or ado file?
> 
> Yes, it would all work fine if I just renamed my stata install dir - but I'd rather not hardcode if possible.
> 
> Thanks,
> George Hoffman
> 
> 
> 


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index