Python os.system & subprocess do not recognize Microsoft's ie4uinit.exe - subprocess

I'm trying to call ie4uinit from a python script so that I can update the icon in my task bar. ie4uinit.exe -ClearIconCache does just that, however whenever python calls it, either with subprocess.call or os.system, the following error comes up and the program is not called.
"ie4uinit.exe" is not recognized as an internal or external command,
operable program or batch file.
I have tried giving the full path location i.e.
"C:\Windows\System32\ie4uinit.exe"
Same result.
I have even made a .bat to abstract the call.
I suspect the problem is stemming from a difference in permissions between calling the command from the command line, and calling it through python.
But I don't know how.

Related

Installing files via Composer via Command Line | "'$' is not recognized as an internal or external command, operable program or batch file."

So I am attempting to install some files from Send Grid via Composer usind the CommandLine.
I am following a tutorial with the link here https://www.youtube.com/watch?v=fEobqi3N7zw
The guy in the video has no problem using Composer via the Command Line in the Windows Command Prompt, but when I input the command $ go_www, my PC whines and stamps it's feet, giving me the following line:
'$' is not recognized as an internal or external command,
operable program or batch file.
In a nutshell, why?
System Information:
Windows 10 64x
I have looked at other posts on here, to no avail, I have tried opening the Command Line too as System Administrator, but to avail. I have tried restarting the system, to no avail, I can confirmed I have composer installed into the correct directory, to no avail .
$ in a shell indicates the shell is not owned by a superuser, it is not part of the command. Try running go_www. Also, the video you linked seems to be using a bash shell, whereas you appear to be running a Windows command prompt from the error message you included in your question, which might be a problem too.
In any case, go_www is an alias the video author uses to quickly navigate to the folder of interest. Try manually navigating there using cd.

Set environment variables by batch file called from perl script

Let's consider the following perl script:
#!/usr/bin/perl
system("C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/Tools/VsDevCmd.bat");
system("msbuild");
The batch file invoked with the first system call is supposed to set up some environment variables so that the msbuild executable in the second system call can be found.
When I run this perl script I get the following error:
'msbuild' is not recognized as an internal or external command,
operable program or batch file.
So it looks like the environment variables set in the batch file are not made available to the context of the perl script. What can I do to make this work?
Note 1
Running first the batch file from a console window and then running msbuild works fine. So the batch file works as expected and msbuild is actually available.
Note 2
My real-world perl script is much longer. This example here is a massive simplification which allows to reproduce the problem. So I cannot easily replace the perl script with a batch file, for example.
Note 3
The funny thing is: I've been using this perl script for one or two years without any problems. Then suddenly it stopped working.
Your process has an associated environment which contains things like the search path.
When a sub-process starts, the new process has a new, separate, environment which starts as a copy of the parent process's environment.
Any process (including sub-processes) can change their own environment. They cannot, however, change their parent's process's environment.
Running system() creates a new environment.
So when you call system() to set up your environment, it starts a new sub-process with a new environment. Your batch program then changes this new environment. But then the sub-process exits and its environment ceases to exist - taking all of the changes with it.
You need to run the batch file in a parent process, before running your Perl program.

Powershell Function Not Recognised

I've been putting my first powershell scripts together for the last couple of hours and I keep seeing an error that I can't seem to get to the bottom of.
I'm using the Powershell ISE tool to write and run the scripts.
To see if its something in my script I've created a super simple test script and I'm seeing the same problem. The entire test script is:
Test;
function Test
{
New-Item C:\Users\jgreen\Desktop\jammer\ -type directory
}
When I hit the Run Script button the error produced is:
Test : The term 'Test' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct
and try again.
If I simply hit the Run Script button again, it work and does the job. I simply do not understand what is wrong. I simply don't get it. Is there a problem with my script or not?
Why would a script that works bomb out the first time after opening the script in PS ISE?
You are calling the function before it is defined. The reason it works the second time, is a result of the first run. When it is ran the first time it's defining the function, so when you run the script the second time it knows what the function is.
You need to declare your function before you invoke it. It works the second time because then it's been declared. Think of how this would work if you were just at a powershell command line and you typed: "Test;" What would you expect to happen?

Sending Windows Terminal Commands Via Perl

I am trying to use the query terminal server command, but Perl keeps coming back with this error:
'query' is not recognized as an internal or external command,
operable program or batch file.
If I enter the query command directly into the command prompt I am able to use it, however all of these attempts via Perl result in the above error:
exec("query /help");
system("query /help");
`query /help`;
I'm guessing it has to do with the way Perl creates a new shell to send commands. Is there a way to have it send directly within the same command shell I am executing the Perl script in?
Well, I've just tried it on my system with:
print system ( "query /help" );
And that works. So my guess might be - query isn't in the path when you're using perl.
Failing that though - I'd suggest trying cmd /c query /help

Compiling error with MATLAB function

I have always been able to use the MATLAB function block on simulink without problems, but ever since yesterday it has been giving me the message
Unable to locate a C-compiler required by Stateflow and MATLAB Function blocks.
Use 'mex -setup' to select a supported C-compiler.
After some search I tried installing Windows SDK, and reinstalling Microsoft Visual C++ 2010 Express, but the error persists.
When I run the simulink model the following message appears on MATLAB's main window, before the first message appears on simulink
Warning: ''MySQL' is not recognized as an internal or external
command,
operable program or batch file.
'MySQL' is not recognized as an internal or external command,
operable program or batch file.
VSINSTALLDIR'
exceeds MATLAB's maximum name length of 63 characters and has
been truncated to
''MySQL' is not recognized as an internal or external command,
o'.
I don't know if it they are connected, but the only recent change I made in this computer was installing MySQL in it.
Assuming you're using windows (which it looks like from the question), type !where mysql on the Matlab command prompt. If the result is blank, you've got a path issue. Let's fix it.
First off, locate where your mysql executable lives -- either type where mysql.exe in a command shell, or just find it on the filesytem. Let's assume it's in C:\Path\To\Mysql\. Then, on the Matlab command prompt, change the PATH system variable by running:
setenv('PATH', [getenv('PATH') ';C:\Path\To\Mysql\']);
Hopefully, that will work.