How to retrieve the value from local exe file - powershell

I've got the file "updates.exe", which runs a program. When this file is executed, I might see the next info:
Program Started 101.0.4951.41 version. etc.
How to get the version value '101.0.4951.41' ?
I need to put it to a variable and use it in my further actions.
$CurrentVersion = 101.0.4951.41
Like this.
Thanks!

Related

Matlab does not recognizes function

I'm using preaty old Matlab (version 7.1.0.246 (R14) Service Pack 3) :(
I have some toolbox I was provided which I'd like to use. When I try to execute the function, I'm getting Undefined command/function 'test' (my function is test and stored in test.m and the file located in my current working directory).
If I place the file in C:\Temp\ and execute which test, I'm getting the complete file path (C:\Temp\test.m).
If I place the file in C:\Temp\MyMap\ and execute which test, I'm getting the complete file path('C:\Temp\MyMap\test.m') and additional comment %Has no license available.
If I use following one
if exist('test')
test(...)
end
It solves the issue. However, as mentioned previously, its a toolbox and contains many functions. I don't have time (and want to) apply the workaround on all the files/functions.
Any suggestion how this could be solved?

No such file or directory

I am coding a hashing program in ada and using direct io to read and write to/from a file. I am trying to read from a file that is in the same folder as the executable as it should be but still raising the exception. Any ideas as to why its still raising this exception?
adb showing exception driver ads file
The location of the executable has no impact on the interpretation of the names of files to be opened or created. The relevant issue is the current working directory (or folder, if you will) of the process that executes the program. In the common OSes, for a file to be found based on its file-name alone (without any directory path), the file must lie in the current working directory.
You seem to be executing the program from within some IDE, right? Then the IDE probably defines the current working directory to be used when the IDE executes the program. Do you know how the IDE does that, and can you override the default within the IDE? If not, I suggest that you execute the program from the shell command line and manually set the current working directory as needed, in that shell window, using the "cd" command before executing the program.
You could use Ada.Directories (ARM A.16) to work out the location of the data file from the location of the executable:
use Ada.Directories;
Program_Name : constant String := Ada.Command_Line.Command_Name;
Complete_Name : constant String := Full_Name (Program_Name);
Full_Directory : constant String := Containing_Directory (Complete_Name);
Source_File_Name : constant String
:= Compose (Containing_Directory => Full_Directory,
Name => "foo",
Extension => "txt");
Note, the use Ada.Directories meant I had to be a bit 'creative' about variable names; without it, I could say e.g.
Full_Name : constant String
:= Ada.Directories.Full_Name (Program_Name);

file for saving cookie data not found when using HTTP::Cookies in Perl script

all. I had some questions about the Perl module HTTP::Cookies. The example on CPAN is like below:
$cookie_jar = HTTP::Cookies->new( file => '$ENV{\'HOME\'}/lwp_cookies.dat', autosave => 1);
The lwp_cookies.dat file is used to save cookie data on my local machine as I understand. On my machine, '$ENV{\'HOME\'}' is an empty path. The script runs good, even after execution I can't find any file named "lwp_cookies.dat" on my machine. I changed '$ENV{\'HOME\'}' to '$ENV{\'TMP\'}', which is a path really exists after I verified by Perl print. Still I can't find the "lwp_cookies.dat" in my TEMP folder. My first question is how the HTTP::Cookies is working with the "lwp_cookies.dat" file.
On the other hand, on one of my systems(all're Windows system as mentioned here), the same code produce error message below:
Can't open $ENV{'HOME'}/lwp_cookies.dat: No such file or directory
So it's strange to me. On my good system, even file or path not exists, the script runs well, which I suppose the file is created on some temp memory instead; on bad system, the code example doesn't work at all.
If you want the $ENV{'HOME'} variable to interpolate into the string, you need double quotes; single quotes don't interpolate variables:
`file => "$ENV{'HOME'}/lwp_cookies.dat",`

Error while try to rename a file name in matlab

This is my code:
filename_date = strcat('Maayanei_yeshua-IC_',file_date,'.pdf')
filenamepdf = strcat(filename,'.pdf')
rename(['C:\Users\user\Desktop\' filenamepdf],['C:\Users\user\Desktop\' filename_date]);
And i get the error:
<??? Error using ==> movefile The system cannot find the path specified.>
or
<??? Undefined function or method 'rename' for input arguments of type 'char'.>
I checked hundreds of times and the file is there... i don't know why it can't find it, any help ?
Use the command
doc rename
to discover that rename is for working with ftp servers, which you are not doing here. What you want is the command movefile
Use the help window brought up by helpwin to look up all the commands you are using.
Also, from the command prompt try
dir(['C:\Users\user\Desktop\' filenamepdf])
to verify the file you want to move exists.

Environment.CurrentDirectory in C#.NET

The property Environment.CurrentDirectory always returns the path of system directory instead my application directory. In my colleague's PC, it returns application directory.
What is the problem? How can I solve it?
The following code is working for me
ePCRSettings = XMLParser.XmlParser.Deserialize<PCRGeneratorSettings>(string.Format("{0}\\ePCRPDFSettings.xml", AppDomain.CurrentDomain.BaseDirectory));
AppDomain.CurrentDomain.BaseDirectory - Returns the directory E:\MyApplications\.
The following code is not working for me
ePCRSettings = XMLParser.XmlParser.Deserialize<PCRGeneratorSettings>(string.Format("{0}\\ePCRPDFSettings.xml", Environment.CurrentDirectory));
Environment.CurrentDirectory - Returns c:\windows\system32.
This .dll file can be used in VB 6 and ASP.NET applications
set current directory
Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory); //or set executing Assembly location path in param
Environment.CurrentDirectory //now returns your app path
Use
System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
You shouldn't be using the Environment.CurrentDirectory value as a base for file lookups because it can change and may not always be under your control. e.g. a File Save As to a different folder may change the 'current folder' value. As you can see it can yield unpredictable results.
Use a value that you can control better. e.g. a ResourcesFolderPath value in a configuration (xml?) file that is updated when you install your app.
I suspect that this could have something to do with the current user id that the app is running under, for example if you are running the app in a user session (e.g. debugging in VS) then this may return your current directory, but if you were running it under IIS then this could be why it is defaulting to the system folder?