Jump to content

Pass Arguments


Go to solution Solved by Subz,

Recommended Posts

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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. 

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

  • Solution

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
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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