Jump to content

Passing arguments to a command


Recommended Posts

I am trying to write a script to install BGInfo from sysinternals and then run it with a couple switches. https://technet.microsoft.com/en-us/sysinternals/bginfo.aspx

I have made a configuration that has everything in it that I want and saved it as MYBKGRND.bgi I have used DirCreate and FileInstall to put all of the information where I want it. My problem is I am not sure how to run it and pass the /switches I want to it. I would like to use two switches I believe /timer:0 and /NOLICPROMPT

What I made so far is below.

 

#RequireAdmin

DirCreate("C:\Background\")
DirCreate("C:\Background\Backgrounds\")
FileInstall("C:\Users\Nunos\Desktop\BGInfo\Backgrounds\Background.jpg", "C:\Background\Backgrounds\Background.jpg",1)
FileInstall("C:\Users\Nunos\Desktop\BGInfo\Bginfo.exe", "C:\Background\Bginfo.exe",1)
FileInstall("C:\Users\Nunos\Desktop\BGInfo\MYBKGRND.bgi", "C:\Background\MYBKGRND.bgi",1)

Run("C:\Background\Bginfo.exe"

 

Edited by Nunos
Link to comment
Share on other sites

Try something like:

#RequireAdmin

DirCreate("C:\Background\Backgrounds\")
FileInstall("C:\Users\Nunos\Desktop\BGInfo\Backgrounds\Background.jpg", "C:\Background\Backgrounds\Background.jpg",1)
FileInstall("C:\Users\Nunos\Desktop\BGInfo\Bginfo.exe", "C:\Background\Bginfo.exe",1)
FileInstall("C:\Users\Nunos\Desktop\BGInfo\Background.bgi", "C:\Background\Background.bgi",1)

Run('C:\Background\Bginfo.exe /timer:0 /NoLicPrompt')

 

Link to comment
Share on other sites

If your script is located in "C:\Users\Nunos\Desktop\BGInfo" folder then you could use the following, this would allow you to move the entire C:\Users\Nunos\Desktop\BGInfo" folder and still be compiled.  The script also only has to be run once for a system after that Run in Registry will start BGInfo when ever a user logs on.

#RequireAdmin

Local $sBGInfo = EnvGet("SystemDrive") & "\BackGround"
If FileExists($sBGInfo & "\Backgrounds\") = 0 Then DirCreate($sBGInfo & "\Backgrounds\")
If FileExists($sBGInfo & "\Backgrounds\Background.jpg") = 0 Then FileInstall(".\Backgrounds\Background.jpg", $sBGInfo & "\Backgrounds\Background.jpg", 1)
If FileExists($sBGInfo & "\BGinfo.exe") = 0 Then FileInstall(".\Bginfo.exe", $sBGInfo & "\Bginfo.exe", 1)
If FileExists($sBGInfo & "\Background.bgi") = 0 Then FileInstall(".\Background.bgi", $sBGInfo & "\Background.bgi", 1)

;~ Start BGInfo every time user logs on without the need for re-running this script
RegWrite("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "BGInfo", "REG_SZ", $sBGInfo & '\Bginfo.exe "' & $sBGInfo & 'Background.bgi" /timer:0 /NoLicPrompt /Silent')
;~ Start BGInfo for this installation script.
Run($sBGInfo & '\Bginfo.exe "' & $sBGInfo & 'Background.bgi" /timer:0 /NoLicPrompt /Silent')

 

Link to comment
Share on other sites

Wow that is a great way to do it I will test it on a few limited systems today.

 

!>05:39:04 Aut2exe.exe encountered an error ended with error:   Error adding file:  \Backgrounds\Background.jpg .rc:2
!>05:39:04 Target exe is not created, abandon build.rc:2

I am not sure why it wont compile but that is the error from console window in SciTe

Edited by Nunos
Updated with error after attempting to compile.
Link to comment
Share on other sites

Using your example above you should have the following, this compiles fine for me on my system:

C:\Users\Nunos\Desktop\BGInfo\BGInfoScript.au3
C:\Users\Nunos\Desktop\BGInfo\BGinfo.exe
C:\Users\Nunos\Desktop\BGInfo\Background.bgi
C:\Users\Nunos\Desktop\BGInfo\Backgrounds\Background.jpg

Your BGInfoScript.au3 should have the following:
nb: Added backslashes to Background.bgi

#RequieAdmin ;~ Required for Windows 10
Local $sBGInfo = EnvGet("SystemDrive") & "\BackGround"
If FileExists($sBGInfo & "\Backgrounds\") = 0 Then DirCreate($sBGInfo & "\Backgrounds\")
If FileExists($sBGInfo & "\Backgrounds\Background.jpg") = 0 Then FileInstall(".\Backgrounds\Background.jpg", $sBGInfo & "\Backgrounds\Background.jpg", 1)
If FileExists($sBGInfo & "\BGinfo.exe") = 0 Then FileInstall(".\Bginfo.exe", $sBGInfo & "\Bginfo.exe", 1)
If FileExists($sBGInfo & "\Background.bgi") = 0 Then FileInstall(".\Background.bgi", $sBGInfo & "\Background.bgi", 1)

;~ Start BGInfo every time user logs on without the need for re-running this script
RegWrite("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "BGInfo", "REG_SZ", $sBGInfo & '\Bginfo.exe "' & $sBGInfo & '\Background.bgi" /timer:0 /NoLicPrompt /Silent')
;~ Start BGInfo for this installation script.
Run($sBGInfo & '\Bginfo.exe "' & $sBGInfo & '\Background.bgi" /timer:0 /NoLicPrompt /Silent')

 

Edited by Subz
Added #RequireAdmin for Windows 10
Link to comment
Share on other sites

And just in case you want to play more with bginfo and .bgi files (be advised this is a metric shit ton of fun and will kill many hours):

https://msitpros.com/?p=3831

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

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