Script doesnt run from another script - powershell

I compiled an AutoIt script and uploaded it to a server. I then wrote a PowerShell script which downloads the compiled AutoIt script and runs it locally.
When I run the PowerShell script on Windows 7 it runs without issues. But when I run the PowerShell script from an application, the compiled AutoIt script does get downloaded but does not run to completion. It does appear in task manager.

Without seeing the script it is hard to say for sure. However, it might be a rights issue. Try adding this to the top of your script and see if it fixes the problem.
#RequireAdmin

Related

PowerShell (x64) stops working after trying to download EXE files (Windows 7)

CONTEXT:
Found a script on SO to download files from URL in PowerShell v2.0 (I am using Windows 7)
PowerShell.exe -ExecutionPolicy Bypass -Command "(New-Object System.Net.WebClient).DownloadFile( 'site.com/file.txt', 'file.txt' )"
Used a batch file .bat to run this script inline.
Works great -- for zip and images!
PROBLEM: Once I try downloading an .exe from URL, the batch file runs WITHOUT executing Powershell script. And Powershell.exe stops working completely in Windows 7...
Powershell (x86) still works, on the other hand.
Opening powershell.exe (x64) directly from folder: C:\WINDOWS\system32\WindowsPowerShell\v1.0 only opens blank window and closes immediately
Tried using sfc /scannow and DISM /Online /Cleanup-image /Restorehealth, but it's not working because Windows 7 doesn't have that option
Running the batch script again works, but the powershell part is skipped
I believe it works again after rebooting (haven't tested properly), but I can't seem to make Powershell (x64) work again without rebooting :/ I don't even know what the problem is as I don't know where to start debugging.
This question might be better suited for superuser.com, but I'm asking here first -- thanks for help :)
As #JCWasmx86 pointed out, it was indeed my Antivirus blocking Powershell.
I tested it extensively with Malwarebytes and Avast in different states -- turned off both of them, then switched them on one by one and ran my script after each state change. Turns out, once Avast got enabled, Powershell (x64, or the default one) got silently blocked after script execution, and persisted inactive until reboot or enough time had passed.
This only happened with .exe files. Avast must not like scripts downloading unverified exe files from the internet.

Win'2019 is detecting my scripts with the Win32/Casur.A!cl trojan

I have a windows batch script that, depending on the user menu selection, opens a powershell.exe and passing a variable to run a .ps1 script. I then use Bat To Exe Converted (v3.0.10) to convert it to an exe. A few hours ago I made changes to the PS script and copied it to the Win'2019 server and it accepted it. Now, I just changed two letters in a write-host message command and it keeps quarantining the file. Since this will be passed to customers I can't be telling them to ignore it or white list it.
I'm guessing the .bat and .ps1 files are throwing Windows Defender off. Funny how it was fine just a few hrs ago. Even if I undo the 2 letters I added it still deleting the exe.
The .bat is quite big and it'd be very difficult for me to convert and add inside the .ps1 script in hope of not setting off the trojan. What other options do I have to fix this? Is there a process or url to notify MS about this to get them to fix this false positive?
NOTE: No other Windows version or 3rd party antivirus that I've tried is detecting the exe infected. Only Win'2019's Defender is.
It looks like MS has fixed the false-positive with my code. I came in to work this morning and tried to copy the exe again and this time it worked. I didn't even contact MS (we don't have a support contract anyway).
Btw the exe consisted of a bat and ps1 script that just downloads some public install files (such as 7zip) from an https address, saves them and when running the exe the user would just get a menu of which of the downloaded programs they want to install.
The issue can be reproduced creating a simple new console application (Language : C++) with Visual Studio 2019 (Community Edition) and then just run program: Ctrl + F5. The solution that worked for me, to run the program, was to add the folder as an exclusion in Windows Defender Antivirus. I couldn't find any solution on other threads

Why PowerShell opens a new window when running exe

I have a PowerShell script like this:
$tfExe = path/to/tf.exe
& $tfExt ... do something
On my computer (and other PCs) if I run this script I get the .exe output in my PowerShell window.
When I run the script on another computer (with Windows 7 32-bit) it opens a cmd window, the output displayed there, and the window is immediately closed.
The issue occurs for each .exe tool, even in robocopy.
Why does this happen and how can I change it?
I had another issue with my PowerShell and the solution to that issue also solved this issue.
In my PATHEXT environment variable I didn't have .exe. When I added it, the issue solved and all the .exe tools ran smoothly and the output appears in the PowerShell window.
I had a similar issue and figured out I had deleted the folder I was executing the commands from.
PATHEXT was ok:
But this was not (I had deleted it outside of PowerShell - oops):
Navigating to another path solved the issue.
You are starting an external exe, so it's working as intended. You could however try using cmd.exe /K - more info here https://ss64.com/nt/cmd.html

Can Jenkins run executable files called through a PowerShell script?

I have to install a program on a Windows 8 server using Jenkins as a framework. I wrote a PowerShell script that does run and install executable files when run through the PowerShell console. This does not happen when I run the same scripts through Jenkins.
Nothing happens except the text I output does appear on Jenkins' console.
Can running an .exe be done on Jenkins through a PowerShell script? Please help! Thanks :)
Read a similar answer here:
Open Excel on Jenkins CI
The issue is that Jenkins on Windows usually runs in "Session 0". Which is not visible to the logged in user. The trick is to launch the process (Excel in that answer, PowerShell in your case) in session 1.

Automatically run CasperJS file from command line

Is there a way to set a time when CasperJS will run that way the file can run while I'm not at my desk at the same time every night? If so how to set that up. Pretty new to using command line so help would be awesome!
Yes, use a scripting language like Python to execute your CasperJS script. Once you have the python script you can setup a task if you're using windows to call that script every night at the same time.
If you need help on how to run a CasperJS script using Python you can check out this video here.
http://www.youtube.com/watch?v=Acrx-AjCo8Q&index=2&list=PLei96ZX_m9sVFBCU6PTyinHrT-4Sh0VWI