Jump to content

Recommended Posts

Posted

Hello and Good Day to All!

I am trying to install .NET 3.5 on Windows 10 x64bit via autoit (via ShellExecuteWait + PowerShell).

If I run this line, it will runs without issues:

ShellExecuteWait('PowerShell.exe', '-executionpolicy Bypass -File "' & @ScriptDir & '\OJP83BU523.ps1' & '"')

"OJP83BU523.ps1" contains: DISM /Online /Enable-Feature /FeatureName:NetFX3 /All /Source:D:\Sources\sxs /LimitAccess

However, since I won't know in advance the drive letter of the "sources" folder, I created a script to generate a PowerShell Script to give a correct path for it.

With the modified script below, PowerShell only blinks and nothing happens

ShellExecuteWait('PowerShell.exe', '-executionpolicy Bypass -File "' & @ScriptDir & '\' & $filename & '"')

or

ShellExecuteWait('PowerShell.exe', '-executionpolicy Bypass -File "' & $filename & '"')

 

I wish I know the difference with "$filename" and "\OJP83BU523.ps1" usage, as for me, it should be the same.

Attached is my entire autoit script.

any help is appreciated!, many thanks in advance!

test.au3

Posted

You left the handle to the file open without closing it. The easiest solution would be to ditch the FileOpen line.

FileOpen returns a handle to a file. FileWrite will put the data in the file, but it won't be able to be read until the file handle is closed with FileClose. Instead, you can directly open, write, and close the file all with FileWrite.

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...