I'm trying to write a script that has to access a DLL file (MySql.Data.dll) from a folder in the Desktop(New Folder). I use the variable $DLLFilePath = $home + '\Desktop\New Folder\MySql.Data.dll') to set the path. But it's not working with [void][system.reflection.Assembly]::LoadFrom($DLLFilePath) giving the error Exception calling "LoadFrom" with "1" argument(s): "Illegal characters in path.".
Is there someway to get the DLL file loaded in LoadFrom?
Looks like PowerShell doesn't allow strings or variables in LoadFrom(). So I used a simple workaround:
Copy the DLL file to a new location like C: drive
Hardcode the path to the DLL file in LoadFrom()
Delete the copied file in C: after use.
Related
I'm developing a solution based on Word and Access.
In an Access mask, the user click a command and a Word file is automacilly created and inserted in a BoundObjectFrame via the following command:
With OleDoc
.Class = "Word.Document"
.OLETypeAllowed = acOLELinked
.SourceDoc = strFullNameFile
.Action = acOLECreateLink
End With
Everything is fine if the file named strFullNameFile is in a normal folder on my computer. But if is in a subfolder inside my OneDrive folder in my computer, I get a
Run-time error 2737
Impossible to find file with OLE object linked...
Do you have any idea why?
Thanks, Lauro
You need to pass the path with subfolder too.
It's searching the file in main folder.
I'm having an issue with a TCL hook script.
There's a *.vhd file that I need to open using this line of code:
set f [open C:/Users/myusername/Desktop/myfile.vhd]
this file is set to be part of xil_defaultlib and I try to access it using the library, since the TCL script should be for others to use and they won't be able to access the file using the path I mentioned above.
I've tried choosing the work library instead and referencing the file the following way:
set f [open work.myfile.vhd]
but the TCL console writes:
couldn't open "work.myfile.vhd": no such file or directory
What would be the correct way to open the file using the work or xil_defaultlib libraries as the path to it?
Thanks in advance.
Before we start: Yes, I have to use 2005. No, I can't upgrade, it's not my decision.
I have an SSIS package that is suppsed to perform the following tasks:
1. Zip a text file using 7-zip
2. FTP the file to a specified site
3. Move the zipped file to an archive folder
Steps 1 and 2 work fine, but when it comes time to move the folder it fails. The error message says, "Could not find a part of the path '\Shares2\clntrial\DataMgt\C1460\DataTransfer\Data\Sent\TXT\archive\ABC701_XXX_2015-09-30.zip\ABC701_XXX_2015-09-30.zip'." As you can see, it has the zip file name in the path twice.
That file destination path is set by a connection manager with the connection string populated by an expression that uses variables. When I edit the expression, it evaluates to the correct path with the file name appearing only once, that is, "\Shares2\clntrial\DataMgt\C1460\DataTransfer\Data\Sent\TXT\archive\ABC701_XXX_2015-09-30.zip".
Why is SSIS adding the file name a second time when the package runs?
Never mind, I'm an idiot. By including the zip file name "ABC701_XXX_2015-09-30.zip" in the destination I'm telling the file system task to consider that the target folder. Duh.
I have a tcl script named main.tcl in a folder called App. One of the lines in the script uses a command from the twapi module (that line is actually in a proc and I'm trying to minimize the app to system tray when a user closes the app through the 'X' window button):
package require twapi
# ... code here
set hand [twapi::load_icon_from_file tclkit.ico]
# ... code here
The file tclkit.ico is in the same directory as the script (i.e. in the folder App).
When main.tcl is run through wish, the script works without any issues, but after wrapping it into an executable through command line,
> tclkit sdx.kit wrap App -runtime tclsh863.exe
the executable raises an error, notably that the icon file could not be found:
The system cannot find the file specified.
The system cannot find the file specified.
while executing
"LoadImage $hmod $path $type $opts(width) $opts(height) $flags"
(procedure "twapi::_load_image" line 18)
invoked from within
"twapi::load_icon_from_file tclkit.ico"
(procedure "min_to_tray" line 2)
invoked from within
"min_to_tray"
(command for "WM_DELETE_WINDOW" window manager protocol)
The current workaround right now is to have a copy of the tclkit.ico file in the same directory as the .exe but I want to avoid that as much as possible and only have the standalone .exe file. I tried using the full path with:
set hand [twapi::load_icon_from_file [file join [pwd] App.exe tclkit.ico]]
which normally works when I want to read a file (.txt, .png files, etc.) within the .exe, without success.
So basically, is there a way to enable the .exe to load the .ico file from within itself or another workaround that will not require some dependence on a file outside the .exe app?
The core issue is that the relevant Windows API actually takes a filename, and not something that it's more easy to wrap loading-from-archive around (such as a buffer). This means that you have to copy the file out of the archive somewhere and then pass that name to the system call. This is in fact what Tcl does internally for load when it's pulling the DLL from a source that isn't directly visible to the OS; it doesn't do it automatically for TWAPI though, as that library takes the philosophical position of being just a thin wrapper and letting the caller handle the consequences (which does mean you can easily do more tricks, provided you're inventive).
I suggest copying the file to a temporary file somewhere (i.e., the standard location for these things; Tcl 8.6 has file tempfile to help with this sort of trick) and then passing the full filename into the TWAPI call. I think everywhere in the Windows API that you could pass a simple filename in, you can also pass a full filename. (That's actually very convenient…)
currently in my test scripts for automated file upload to browser, the paths are already defined in the value column
command type
target //input[#type='file']
value /Users/.../.../.../filename.extension
in such cases, this script is unable to run on other computers because the path would be different.
my question will be is
is there a way to locate the file in a general folder (for example file is downloaded and in the "download" folder), by using selenium ide can we get the path of the file (/Users/.../downloads/filename.extension)
store the path of the file with its extension into a notepad which i will be using it for multiple test of file uploads later on.
right now if my colleague needs to run the script from his computer, he have to manually change the value to his path.
You could use a suite file that contains a "setup" file to only change the file name in 1 place and the variable is shared across tests in the suite. You could also select an agreed up on place to store the files: c:\test_info\image.jpg.
Or you can make the file available by URL & not local, Unfortunately javascript prevents that for security: How to get the current file path in javascript
Unfortunately I can't think of any other good way unless you all have the same path in a home directory and could do something like ~/test_dir/photo.jpg