Jump to content

Recommended Posts

Posted

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.

Posted

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.

Posted (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 by Somerset
Posted

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. 

Posted

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."

Posted

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.

 

  • Solution
Posted (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 by Subz
Posted
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!!! :D Your suggestion has worked now I just need to hide it and if I remember that is just changing the K to a C?

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...