JeffQOOQAAA Posted December 26, 2016 Share Posted December 26, 2016 Hi ALL. I met a problem. Local $DHCP = "Install-WindowsFeature DHCP -IncludeManagementTools" ShellExecute("C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe") sleep(2000) Send($DHCP) Send("{Enter}") I have no idea can't normally excute this command in PowerShell Have anyone seen before ? Link to comment Share on other sites More sharing options...
careca Posted December 26, 2016 Share Posted December 26, 2016 (edited) I get an error too, but it's not related to autoit, the error is within the poweshell window, so it begs the question, why are you posting it here? Quote Install-WindowsFeature : The term 'Install-WindowsFeature' 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. At line:1 char:1 + Install-WindowsFeature DHCP -IncludeManagementTools + ~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Install-WindowsFeature:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException BTW: this does the same in here: ShellExecute("powershell.exe", $DHCP) Edited December 26, 2016 by careca Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
JeffQOOQAAA Posted December 26, 2016 Author Share Posted December 26, 2016 yes! this is error. due to I type this command into powershell directly can normally excute But can't excute via Autoit, So.... i don't know why...... Link to comment Share on other sites More sharing options...
careca Posted December 26, 2016 Share Posted December 26, 2016 How about this? what happens? #RequireAdmin Local $DHCP = "Install-WindowsFeature DHCP -IncludeManagementTools" ShellExecute("powershell.exe", $DHCP) Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
JeffQOOQAAA Posted December 26, 2016 Author Share Posted December 26, 2016 Still got same error..... Link to comment Share on other sites More sharing options...
careca Posted December 26, 2016 Share Posted December 26, 2016 What about Run('powershell '& $DHCP) Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
Subz Posted December 26, 2016 Share Posted December 26, 2016 You need PowerShell running as Administrator try something like: ;~ Change "Get-AppxPackage" to Install-WindowsFeature DHCP -IncludeManagementTools (I believe this is a Windows Server Feature and not included with standard Windows) PowerShell.exe -Command "& {Start-Process PowerShell.exe -ArgumentList '-ExecutionPolicy Bypass Get-AppxPackage' -Verb RunAs}" Or use a PowerShell Script Opt('ExpandVarStrings', 1) PowerShell.exe -Command "& {Start-Process PowerShell.exe -ArgumentList '-ExecutionPolicy Bypass -File ""@ScriptDir@\FileName.ps1""' -Verb RunAs}" Link to comment Share on other sites More sharing options...
JeffQOOQAAA Posted January 13, 2017 Author Share Posted January 13, 2017 Hi Subz Do you mean use "Get-AppxPackage" replace Install-WindowsFeature DHCP -IncludeManagementTools command ? But I try this, it will show many function & cmdlet list, is right? Link to comment Share on other sites More sharing options...
Subz Posted January 13, 2017 Share Posted January 13, 2017 No, "Get-AppxPackage" was just an example, What I meant was replace "Get-AppxPackage" in my example with "Install-WindowsFeature DHCP -IncludeManagementTools" for example: nb: -ExcutionPolicy and Bypass should only be required for PowerShell script like in my second example above. PowerShell.exe -Command "& {Start-Process PowerShell.exe -ArgumentList 'Install-WindowsFeature DHCP -IncludeManagementTools' -Verb RunAs}" Link to comment Share on other sites More sharing options...
JeffQOOQAAA Posted January 13, 2017 Author Share Posted January 13, 2017 Hi Subz I try this command, right? RunWait(@ComSpec & " /c " & "powershell -noexit -Command " &"{Start-Process PowerShell.exe -ArgumentList 'Install-WindowsFeature DHCP -IncludeManagementTools' -Verb RunAs}") Link to comment Share on other sites More sharing options...
Subz Posted January 13, 2017 Share Posted January 13, 2017 Yes except except for the quotes, you would probably require something like this RunWait(@ComSpec & ' /c powershell -noexit -Command "& {Start-Process PowerShell.exe -ArgumentList ' & "'Install-WindowsFeature DHCP -IncludeManagementTools'" & ' -Verb RunAs}"') Link to comment Share on other sites More sharing options...
JeffQOOQAAA Posted January 13, 2017 Author Share Posted January 13, 2017 Hi Subz. I''ve tried this commandm but looks like can't normally install DHCP services. Have any idea for other way? Link to comment Share on other sites More sharing options...
Subz Posted January 13, 2017 Share Posted January 13, 2017 Can you type the exact command you write in PowerShell to install this? Link to comment Share on other sites More sharing options...
JeffQOOQAAA Posted January 13, 2017 Author Share Posted January 13, 2017 RunWait(@ComSpec & " /c " & 'powershell -noexit -Command "& {Start-Process PowerShell.exe -ArgumentList ' & "'Install-WindowsFeature DHCP -IncludeManagementTools'" & '-Verb RunAs}"') This it! Link to comment Share on other sites More sharing options...
Subz Posted January 13, 2017 Share Posted January 13, 2017 Sorry I meant in PowerShell, either the IDE or Shell. Link to comment Share on other sites More sharing options...
JeffQOOQAAA Posted January 13, 2017 Author Share Posted January 13, 2017 But I type your command , still can't install DHCP RunWait(@ComSpec & ' /c powershell -noexit -Command "& {Start-Process PowerShell.exe -ArgumentList ' & "'Install-WindowsFeature DHCP -IncludeManagementTools'" & ' -Verb RunAs}"') Link to comment Share on other sites More sharing options...
Subz Posted January 13, 2017 Share Posted January 13, 2017 What about: #RequireAdmin RunWait(@ComSpec & ' /c powershell -noexit -Command "& {Install-WindowsFeature DHCP -IncludeManagementTools}"') Link to comment Share on other sites More sharing options...
iamtheky Posted January 13, 2017 Share Posted January 13, 2017 Is there an error? What's it say in the windows powershell event log? ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
JeffQOOQAAA Posted January 13, 2017 Author Share Posted January 13, 2017 I got this error Install-WindowsFeature : The term 'Install-WindowsFeature' 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. At line:1 char:4 + & {Install-WindowsFeature DHCP -IncludeManagementTools} + ~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Install-WindowsFeature:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException Link to comment Share on other sites More sharing options...
Subz Posted January 13, 2017 Share Posted January 13, 2017 As I mentioned above this command is only available for Windows Server natively. You would need to install RSAT Tools https://www.microsoft.com/en-us/download/details.aspx?id=45520 to install on a desktop. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now