toad locks folders from editing - toad

Say I have test.sql opened in Toad and I close it. It seems Toad still 'looks' at the location of this file. Namely, after closing it, I can edit the file itself, but not the folder it is in, as attempts to do so result in the error message "The action can't be completed because the folder or a file in it is open in another program".
Closing the file doesn't help, ending the connection in which I opened it doesn't help. But closing Toad does the trick, so I'm guessing Toad still has the location of the file memorized.
My issue is that I do not want to close Toad to edit the name of the folder. Does anyone know if this is possible? Is there for example an overview of which locations are in use/looked at by Toad?

You can't delete the folder if it is Toad's current directory. As a workaround you can browse to a new folder location in a Toad open dialog. You may need to actually open a file from that new location. As I Google it there's a property of the open dialog used to not change the current directory. It's too late to change for the release underway (12.10), but I'll log a bug report to revisit this for the next release of Toad.

I had the same issue in 12.0.0.61 after exporting a data set. I tried opening a random file from another location, but that did not work in my case.
One workaround that I did find to be successful is to open the FTP utility and manually change the current folder. When opening the FTP utility in TOAD, the "local system" location will default to the current folder. In my case, I just went up a level and that releases the hold on the folder I'm trying to modify.

Related

Open SAS program in new instance

I'm trying to figure out a way to open SAS programs in new instances of the Enhanced Editor by default on click.
The question has been asked before but no luck.
This paper describes the way a program is opened with the Enhanced Editor. The full command is :
"C:\PROGRA~1\SASHome\SASFOU~1\9.3\core\sasexe\SASOACT.EXE" action=Open
datatype=SASFile filename="%1" progid=SAS.Application.903
The author explains that:
The sasoact.exe program is used to launch an OLE automation session of SAS.
Automation
is a mechanism through
which one Windows application can control another application programmatically. When you double-click a SAS file
type, sasoact.exe checks to see if an existing OLE automation session of SAS is running. If not, it then invokes an
OLE automation session of SAS. Once there is an active
SAS automation server session, any further calls from
sasoact.exe are handled by the existing SAS session instead of in a new
SAS session.
I guess having only one OLE session is usefull in some way or another but it's really annoying when you have to manually open a new EE instance every time you want to run multiple jobs. Not to mention that sasoact targets the first session initiated and if a job is already running on that session well your program is not going to open.
Is there a way to directly request a new instance of the OLE session or perhaps "trick" sasoact.exe into not seeing the opened sessions ?
[EDIT] Well too bad it's been closed as duplicate because the answer is substantially different than the other question's. Also it might help others who do not want to run their programs from a batch file.
Here is the registry key that works:
"C:\Program Files\SAS\SASFoundation\9.2(32-bit)\sas.exe" -initstmt "dm 'whost;include ''%1'' ';"
I added it in HKEY_CLASSES_ROOT\SAS.Program.701\shell\Open New\command so now I have a neat little extra option in my drop-down menu that effectively opens programs in new sessions on click:
A similar thread showing the use of a batch file to open a SAS program in a new session is available here.
If you want to open a .sas program in a new session by simply clicking the program here is how to do it:
You have to add an entry to the registry. Be careful when messing around with registry files, always back up your entries.
Open the registry editor (WIN+R > regedit).
In the directory HKEY_CLASSES_ROOT\SAS.Program.701\shell\ create a sub-directory with a meaningful name(right-click on shell > New > Key). I named mine "Open New". In this new sub-directory create another sub named command. You should now have a path that looks like:
HKEY_CLASSES_ROOT\SAS.Program.701\shell\Open New\command
In here, right-click on the file on the registry file on the right > Modify and add the following in the Value data field (change the path of sas.exe if needed)
"C:\Program Files\SAS\SASFoundation\9.2(32-bit)\sas.exe" -NOTUTORIALDLG -initstmt "dm 'whost;include ''%1'' ';"
Close the editor. You should now have the new option specified in the drop-down menu of the right-click on a .sas program:
This option will open your program with the Enhanced Editor in a new SAS session.
Now if you want it to work for double-clicking I suppose you'd have to replace the value in the Open sub-directory with the one from above. I haven't done it and I don't recommend it, the extra option in the drop-down is enough for me.

Where in the process is a file open?

I have an application suite that I maintain for Windows platforms. I recently added some code to a shared library to remove a directory after the app is done with it. In one app, the deletion is successful; in the other, I receive a message telling me the file is in use by another process.
After downloading Process Explorer, I learned what I had already expected, that the process holding the folder is the one trying to delete it.
When I google for an answer, all I see is, "You need to download XYZ to find out what process is holding the file, then close that process," where "XYZ" is Unlocker, Process Explorer, etc. I know the process that is holding the file, but if I terminate it, how can it delete the folder?
Does anyone have any idea about how to locate the code that is holding the folder open? Of the tools that are available for finding which processes are using which files, can any be used to find where in the process the folder is open?
There is no concept of a "location in the process" where a file is open. E.g. a very common cause of unintentional open files are leaked handles. That means the file is open precisely because there is no location for the file handle in the process anymore.

Cannot access INI files in "Program Files"

I wrote this C++ application that needs to check an INI file (“preference.ini”), and eventually modify it (e.g. if the user does not want to see the introduction form anymore). I created it in WinXP, and it works fine on the system where I compiled it (in many locations, including “Program Files”).
Problem:
In Win 7, it works fine if I put the complete program folder under “C”:\” (e.g. “C:\MyProgram”), but if I put it in “C:\Program Files (x86)\MyProgram”, it just retrieves some mysterious data (values not present in my INI file). When I change some settings and save them to file, it (apparently) save the changes (get no errors, but the changes are not there when I go and open the file...
I had some similar issue on a system with another WinXP system (not the one where I compiled it.
I used 'getcwd' to define the path at runtime, and I verified that it is getting it right, even under "Program Files (x86)":
char currentPath[MAXPATH];
getcwd(currentPath, MAXPATH);
std::string licensePath(currentPath);
licensePath.append("\\dat\\preference.ini");'
Any ideas? Thanks in advance for your help.
The answer is as #Kirill has already said - Win7 won't let you write data into Program Files unless you have higher than normal permissions (Run as Administrator). In this case it may be redirecting your file writes so that they still apear to work, but the data itself is not stored in Progam Files.
To add to his answer: In general (unless you want to run your app as an administrator), you should not write any program data to the Program Files folder.
Application settings should be stored in one of the AppData folders. You can get to your user's appdata manually by going to your start menu Search box (Vista/Win7) and typing %appdata%.
To find this location in your code, use SHGetFolderPath with CSIDL_APPDATA (current user) or CSIDL_COMMON_APPDATA (all users).
It could be related to that Windows use virtualization of the file system. You could read here about it. Check if your INI file is located in <root>\Users\<User_name>\AppData\Local\VirtualStore.
Seems to me that the licensePath: getcwd() + "\\dat\\preference.ini" is not what you would expect.
Log this value (console or in a log file) and see what exactly is the value of licencePath is when running you program from different folders.
This article is about game development but has the best description of how and why this happens that I've been able to find
http://msdn.microsoft.com/en-us/library/ee419001(VS.85).aspx
This paragraph from the article describes what is happening most likely -
Attempting to create or write a file
or directory under a folder which does
not grant write permission to the
process will fail under Windows Vista
if the application does not have
administrative privileges. If your
32-bit game executable is running in
legacy mode, because it did not
declare a requested execution level,
its write operations will succeed, but
they will be subjected to
virtualization as described in the
section "UAC Compatibility with Older
Games" later in this article.

Open an html page on an install CD with the default browser

I am trying to build an install CD with a custom MFC application set to autorun when the CD is inserted.
The instructions are included as a simple html page with images and links to PDF documents, all of which are located on the CD.
In the past I'd used the following to open the html page with the default browser:
ShellExecute(NULL, "open", <full path to .htm file including CD drive letter>, NULL, NULL, SHOWNORMAL);
But when testing with IE8 under vista I've encountered the following:
Explorer launches
The tab says 'Connecting'
Explorer dissappears
This has to do with protected mode, since if you turn off protected mode for the internet zone, the problem goes away.
The strange thing is that the problem only shows up once everthing is burned onto a CD. If I just run the autorun executable manually from my hard drive, the html page comes up just fine.
So I'm asking if there is anything specific I can do to fix this?
Or if there is another mechanism for opening URLs with the user's default browser that might not have this problem?
Since you can be reasonably sure that IE is installed you might want to execute
iexplore.exe [URL]
in your shellex call.
In case IE is not installed, check the return value to see if it isn't not found. If so do your original shellex call directly on the .htm file.
Alternatively, You can copy the .htm to a %TEMP%, and run the shellex call from there. That way it gets around the protected aceess from a "risky" location.
Can you capture and display the return code from the ShellExecute? That might give us a clue as to what is happening.
result = ShellExecute(...
Possible return codes are listed here:
http://support.microsoft.com/kb/238245
It says in your question that you are hard-coding the CD-ROM drive letter. Does the machine you are testing on have a different drive letter than the one you created the CD on?

Virtual Files are opened from Temporary Internet Files

I have created a namespace extension that is rooted under Desktop. The main purpose of the extension is to provide a virtual list of ZIP files that represent a list of configurable directories. When the user clicks one of the those items the contents of the related directory are zipped in place and the resulting ZIP file is stored in a cache folder.
All this works well aside a minor issue. If we go to Windows Explorer, open the extension and double click an item the opened file is the one from the cache. [CORRECT]
If on the other hand we open it by an Open Dialog the opened file is one from a Temporary Internet files directory. [INCORRECT]
What do I have to change for the Open Dialog (when used for example trough notepad.exe) to open the file from the cache folder and not from Temporary Internet files. I have tried to send allways the qualified file name in IShellFolder::GetDisplayNameOf but without any luck.
It sounds like you are not passing in the correct initial directory (in the lpstrInitialDir or lpstrFile parameter of your OPENFILENAME struct).
Enter your cache directory in lpstrInitialDir and leave lpstrFile blank and it should work.
The problem was fixed by masking SFGAO_FILESYSTEM in the attributes returned by implementation of interface method IShellFolder::GetAttributesOf.