Nunos Posted May 29, 2022 Posted May 29, 2022 Good day I am struggling to get the proper syntax or maybe I am doing it in an improper way to run an executable and pass some arguments to it from my @scriptDir. I am automating the stuff in this link. How to Export and Copy Local Group Policy Settings to Another PC | Password Recovery (top-password.com) I was able to make the first command work properly with the code below. Run(@ScriptDir & "\Resources\LGPO\LGPO.exe /b C:\Backup\ /n GPO-Backup",@ScriptDir, @SW_MAXIMIZE) But not able to see what I am doing wrong in the import. I verified LGPO.exe exists and the backup is named that long GUID, {C07F453F-BD11-45B4-B707-C5BE685CE802} and it does exist in my folder structure. Run(@ScriptDir & '\Resources\LGPO\LGPO.exe /g' & @ScriptDir & "\Resources\LGPO\{C07F453F-BD11-45B4-B707-C5BE685CE802}", @ScriptDir, @SW_MAXIMIZE) Thank you in advance for the assistance.
Somerset Posted May 29, 2022 Posted May 29, 2022 1 hour ago, Nunos said: Run(@ScriptDir & '\Resources\LGPO\LGPO.exe /g' & @ScriptDir & "\Resources\LGPO\{C07F453F-BD11-45B4-B707-C5BE685CE802}", @ScriptDir, @SW_MAXIMIZE) doesn't there need to be a space after the /g
Nunos Posted May 29, 2022 Author Posted May 29, 2022 Just tried a space after the g and still doesn't run just getting a fast splash screen like when you run an exe from cmd and have the wrong switches.
Somerset Posted May 29, 2022 Posted May 29, 2022 (edited) write it out in command line and see if it works. if it doesn't execute even though you typed it out, then you might have to quote the last portion of it since some command line parameters need the path to be quoted. I just know this is going to be a pain since it is windows related stuff. https://blog.securestrux.com/applying-configuration-with-microsofts-lgpo-utility Below is an example on this web page. Quote C:\LGPO\LGPO.exe /g 'C:\LGPO\Backup\{F02F0236-6A68-40F2-8F91-1861194EB794}\' see the quoting on the path, that is what i was referring to. Edited May 29, 2022 by Somerset
Nunos Posted May 29, 2022 Author Posted May 29, 2022 I can run it from the cmd line by changing to the directory and running it almost like you have above just no quotes. So then tried as you described with single quotes like... Run(@ScriptDir & '\Resources\LGPO\LGPO.exe /g' & @ScriptDir & '\Resources\LGPO\{C07F453F-BD11-45B4-B707-C5BE685CE802}', @ScriptDir, @SW_MAXIMIZE) No luck. The quotes kill me every time.
pixelsearch Posted May 30, 2022 Posted May 30, 2022 @NunosDoes this work for you ? (untested) Run(@ScriptDir & "\Resources\LGPO\LGPO.exe /g " & _ Chr(34) & "'" & @ScriptDir & "\Resources\LGPO\{C07F453F-BD11-45B4-B707-C5BE685CE802}" & "'" & Chr(34), _ @ScriptDir, _ @SW_MAXIMIZE) "I think you are searching a bug where there is no bug... don't listen to bad advice."
Nunos Posted May 30, 2022 Author Posted May 30, 2022 @pixelsearch It does the same thing just a quick flash of the cmd console that if you look quick enough shows it didn't execute.
pixelsearch Posted May 30, 2022 Posted May 30, 2022 Let's hope it's not because of the missing \ as found on the web page example : Command: C:\LGPO\LGPO.exe /g 'C:\LGPO\Backup\{F02F0236-6A68-40F2-8F91-1861194EB794}\' "I think you are searching a bug where there is no bug... don't listen to bad advice."
Subz Posted May 30, 2022 Posted May 30, 2022 Try using the following at the top of your script #RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** Also use RunWait(@Comspec & ' /k "' & ...) this should show you what the error you're getting. Nunos 1
Solution Subz Posted May 30, 2022 Solution Posted May 30, 2022 (edited) Here is what worked for me, note the double quote after /k #RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** Local $sLGPODir = @ScriptDir & "\Resources\LGPO" Run(@ComSpec & ' /k ""' & $sLGPODir & '\LGPO.exe" /g "' & $sLGPODir & '\{C07F453F-BD11-45B4-B707-C5BE685CE802}"', $sLGPODir) ;~ Run Hidden - use the command line below instead ;~ Run(@ComSpec & ' /c ""' & $sLGPODir & '\LGPO.exe" /g "' & $sLGPODir & '\{C07F453F-BD11-45B4-B707-C5BE685CE802}"', $sLGPODir, @SW_HIDE) Edited May 30, 2022 by Subz pixelsearch 1
Nunos Posted May 30, 2022 Author Posted May 30, 2022 @Subz RunWait(@Comspec & ' /k "' & @ScriptDir & '\Resources\LGPO\LGPO.exe /g' & @ScriptDir & '\Resources\LGPO\{C07F453F-BD11-45B4-B707-C5BE685CE802}', @ScriptDir, @SW_MAXIMIZE)
Nunos Posted May 30, 2022 Author Posted May 30, 2022 1 minute ago, Subz said: Here is what worked for me, note the double quote after /k #RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** Local $sLGPODir = @ScriptDir & "\Resources\LGPO" Run(@ComSpec & ' /k ""' & $sLGPODir & '\LGPO.exe" /g "' & @ScriptDir & '\Resources\LGPO\{C07F453F-BD11-45B4-B707-C5BE685CE802}"', $sLGPODir) Sorry I was posting just as you updated!!! Your suggestion has worked now I just need to hide it and if I remember that is just changing the K to a C?
Subz Posted May 30, 2022 Posted May 30, 2022 (edited) Updated my last post on how to run it hidden. Edited May 30, 2022 by Subz Nunos 1
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