svenjatzu Posted April 4, 2019 Posted April 4, 2019 Hi im trying to build a script that recognises the active network, and then change the ipv4 dns from maually to automatic. i tryed already with powershell and it works. now i wanna add the powershell script to my au3 script but on running the script it doesnt run powershell as admin. how can i solve this? this is my powershell script: Get-Netadapter | ?{$_.Status -in 'Up','Disconnected'} | %{Set-NetIPInterface -InterfaceIndex $_.ifIndex -Dhcp Enabled; Set-DnsClientServerAddress -InterfaceIndex $_.ifIndex} this is my vba script to run the ps1 as admin: Set oShell = CreateObject("Shell.Application") oShell.ShellExecute "powershell", "-executionpolicy bypass -file dns.ps1", "", "runas", 1 someone please can help me to make it work with autoit? thanks
Developers Jos Posted April 4, 2019 Developers Posted April 4, 2019 Moved to the appropriate forum. Moderation Team SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Developers Jos Posted April 4, 2019 Developers Posted April 4, 2019 3 minutes ago, svenjatzu said: this is my vba script to run the ps1 as admin: Set oShell = CreateObject("Shell.Application") oShell.ShellExecute "powershell", "-executionpolicy bypass -file dns.ps1", "", "runas", 1 Should be easy to convert to Autoit3. Just check out the Objxxx() functions in the helpfile and let us know when you have something that doesn't work. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
svenjatzu Posted April 4, 2019 Author Posted April 4, 2019 4 minutes ago, Jos said: Should be easy to convert to Autoit3. Just check out the Objxxx() functions in the helpfile and let us know when you have something that doesn't work. Jos Thanks i gonna look for it : )
svenjatzu Posted April 4, 2019 Author Posted April 4, 2019 Well this objxxx() doesnt seem to be what im looking for or im to stupid for it
iamtheky Posted April 4, 2019 Posted April 4, 2019 (edited) if you requireadmin for your script, then any other commands you run from the script will also be ran as admin, including powershell commands that invoke .ps1 files (look at post #5 in this thread) Edited April 4, 2019 by iamtheky ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
Developers Jos Posted April 4, 2019 Developers Posted April 4, 2019 9 minutes ago, svenjatzu said: Well this objxxx() doesnt seem to be what im looking for or im to stupid for it Post your script when you want some help. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Moderators JLogan3o13 Posted April 4, 2019 Moderators Posted April 4, 2019 For one-liners, this works just fine: RunAs("<admin account>", "<Domain>", "<Password>", 0, "powershell.exe -command Start-Sleep 10 | Get-NetAdapter | Out-File <filePath", @WindowsDir) Even when AutoIt does not run as admin. For full scripts, something like this is what I normally use: RunAs("admin account", "<Domain>", "<Password>", 0, "powershell.exe -file <path to file>.ps1", @WindowsDir) "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Juvigy Posted April 5, 2019 Posted April 5, 2019 #requireadmin in the beginning of your script should solve your problem.
svenjatzu Posted April 19, 2019 Author Posted April 19, 2019 thanks so far, i solved it a diferent way
Moderators Melba23 Posted April 19, 2019 Moderators Posted April 19, 2019 svenjatzu, Then please post the answer to help those who have the same problem in the future. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
svenjatzu Posted April 19, 2019 Author Posted April 19, 2019 My sollution is, drop the project to the archive untill its gonna be urgent to finish it, in between i set the changes by hand. But ofc ass soon as i restart the project and finish it i gonna add the code : )
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