Jump to content

Create a .exe from a .bat


Recommended Posts

  • Moderators

joesedroid,

Welcome to the AutoIt forums.

You cannot use AutoIt to convert a batch file to an executable - the file to convert needs to be a working AutoIt script.  But you can probably get AutoIt to do whatever the batch file does - and then you will be able to make an executable. So I suggest you post the batch file (see here how to do it) and then we can see how you might proceed.

M23

 

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

slmgr.vbs /ipk xxxx-xxxx-xxxx-xxxx-xxx-xxxx

slmgr.vbs /skms Server.org.location

slmgr.vbs /ato

cd "c:\program files (x86)\Microsoft Office\Office14"

cscript ospp.vbs /sethst:Server.org.location

cscript ospp.vbs /act

slmgr.vbs /dli

cscript ospp.vbs/dhistorykms

=============================

Excellent, thanks for getting back to me, I am just trying to activate licenses for office.

Hope this works.

Link to comment
Share on other sites

Welcome to Autoit and the forum!

What do you want to do with the output of slmgr.vbs etc? Retrieve the output and check for errors?
If I start it from the command line I get a MsgBox.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

RunWait(@ComSpec & " /c "&"slmgr.vbs /ipk xxxx-xxxx-xxxx-xxxx-xxx-xxxx","",@SW_HIDE)
RunWait(@ComSpec & " /c "&"slmgr.vbs /skms Server.org.location","",@SW_HIDE)
RunWait(@ComSpec & " /c "&"slmgr.vbs /ato","",@SW_HIDE)
RunWait(@ComSpec & " /c "&"cscript ospp.vbs /sethst:Server.org.location","c:\program files (x86)\Microsoft Office\Office14",@SW_HIDE)
RunWait(@ComSpec & " /c "&"cscript ospp.vbs /act","c:\program files (x86)\Microsoft Office\Office14",@SW_HIDE)
RunWait(@ComSpec & " /c "&"slmgr.vbs /dli","c:\program files (x86)\Microsoft Office\Office14",@SW_HIDE)
RunWait(@ComSpec & " /c "&"cscript ospp.vbs/dhistorykms","c:\program files (x86)\Microsoft Office\Office14",@SW_HIDE)

 

Regards,
 

Link to comment
Share on other sites

 

slmgr.vbs (Windows7/2008)

Software Licensing Management Tool.

This just allows us to point to the KMS key and authenticate it with our KMS server/Microsoft and activate it.

The only output we want to see is if it was successful. I tried to use Trongs command but am unsure where to do it. I made it a .txt file and an .au3, says it compiles successfully but nothing happens when I run it.

Thanks again for your help.

 

RunWait(@ComSpec & " /c "&"slmgr.vbs /ipk xxxx-xxxx-xxxx-xxxx-xxx-xxxx","",@SW_HIDE)
RunWait(@ComSpec & " /c "&"slmgr.vbs /skms Server.org.location","",@SW_HIDE)
RunWait(@ComSpec & " /c "&"slmgr.vbs /ato","",@SW_HIDE)
RunWait(@ComSpec & " /c "&"cscript ospp.vbs /sethst:Server.org.location","c:\program files (x86)\Microsoft Office\Office14",@SW_HIDE)
RunWait(@ComSpec & " /c "&"cscript ospp.vbs /act","c:\program files (x86)\Microsoft Office\Office14",@SW_HIDE)
RunWait(@ComSpec & " /c "&"slmgr.vbs /dli","c:\program files (x86)\Microsoft Office\Office14",@SW_HIDE)
RunWait(@ComSpec & " /c "&"cscript ospp.vbs/dhistorykms","c:\program files (x86)\Microsoft Office\Office14",@SW_HIDE)

 

Link to comment
Share on other sites

Nothing happens because the scripts are being run hidden (caused by @SW_HIDE).

Option "/dli" displays the license information. What do you want to do with this information?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

That makes sense however when I run the .exe it creates, I see a paused script in the task bar by the clock and its got a flashing X. Do you think im doing something wrong with it? All im really doing is copying the text to a .au3 file and making it a .exe

I have about 4 or 5 similar scripts I want to run silently in my environment and I have not used this product before. All i need is for these batch files to be executables. I guess I don't need the full functionality of AutoIT but it seems like it would be a great product to learn and use. 

 

 

Link to comment
Share on other sites

The flashing "X" in the taskbar simply means that you paused the script by clicking on the icon. Unselect the "Script Paused" selection in the context menu and you are fine.
If needed you can suppress the taskbar icon.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Ok but when I run it in the SciTE editor i get this...

>Running:(3.3.15.0):C:\Program Files (x86)\AutoIt3\Beta\autoit3.exe "C:\Activations\autoit\test.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop

>Process failed to respond; forcing abrupt termination...
>Exit code: 1    Time: 8.876

Can you direct me to some good training on this? Like I said this is my 1st attempt at this kind of scripting.

Thanks

Link to comment
Share on other sites

Did you press Ctrl+Break to stop execution?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

That is to be expected:
Seems to be the normal message when  you kill a script using Ctrl+Break.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Ok, I think I got this now... its mostly working however Im not sure how to path to my office folder, right now I have...

RunWait(@ComSpec & " /c "&"cd c:\program files (x86)\Microsoft Office\Office14","",@SW_HIDE)
RunWait(@ComSpec & " /c "&"cscript ospp.vbs /inpkey:XXXXX-XXXXX-XXXXX-XXXXX-XXXXX","",@SW_HIDE)
RunWait(@ComSpec & " /c "&"cscript ospp.vbs /act","",@SW_HIDE)
RunWait(@ComSpec & " /c "&"slmgr.vbs /dli","",@SW_HIDE)

And it is saying path not found or script not found (its going to fast to read). Do I need to have this script all on one line?

EDIT: After taking a screen shot its pathing to my local profile to run these scripts I.E.

           Input error: Cannot find Script file "C:\Users\admin\desktop\ospp.vbs"

Looks like its not pointing to the c:\program files (x86)\Microsoft Office\Office14"

Again, thanks for all your help, I believe this is the last part of my script.

Edited by joesedroid
Link to comment
Share on other sites

  • Developers

try:

FileChangeDir("c:\program files (x86)\Microsoft Office\Office14")
RunWait(@ComSpec & " /c cscript ospp.vbs /inpkey:XXXXX-XXXXX-XXXXX-XXXXX-XXXXX","",@SW_HIDE)
RunWait(@ComSpec & " /c cscript ospp.vbs /act","",@SW_HIDE)
RunWait(@ComSpec & " /c slmgr.vbs /dli","",@SW_HIDE)

... and change the /c to /k in case of issues with one of the commands.

Jos

Edited by 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.
  :)

Link to comment
Share on other sites

Thanks, that seemed fix some if it, two questions though.

1) What does the /c /k do?

2) When I run this I get a Windows popup showing that ive activated the key AND the key number. id like to not show that. I guessing thats something in the windows OS. Is there a way to not show it?

Thanks!

Link to comment
Share on other sites

  • Developers

1) each dos command has a help function so this is easily figure out by yourself. As a one time favor:

C:\>cmd /?
Starts a new instance of the Windows command interpreter

CMD [/A | /U] [/Q] [/D] [/E:ON | /E:OFF] [/F:ON | /F:OFF] [/V:ON | /V:OFF]
    [ [/C | /K] string]

/C      Carries out the command specified by string and then terminates
/K      Carries out the command specified by string but remains

2) there is a helpfile that comes with AutoIt3, have you looked at the options for RunWait. As it was a one time favor , no additional pointer are provided here. ;)

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

Link to comment
Share on other sites

  • Developers

Ah ok:
there is probably not much you can do to avoid it poping up unless the program supports a alternative to provide the key.
You could monitor and hide it asap and then fill in the key with ControlSend().

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

Link to comment
Share on other sites

:sweating:

Run(@ComSpec & ' /k cd\&&cls ', "", @SW_SHOWMAXIMIZED)
    Local $hWnd = WinWait("[CLASS:cmd]", "", 2)
    WinActivate($hWnd)
    Send('cd "c:\program files (x86)\Microsoft Office\Office14"'& "{Enter}")
    Sleep(500)
    Send('cscript ospp.vbs /inpkey:XXXXX-XXXXX-XXXXX-XXXXX-XXXXX'& "{Enter}")
    Sleep(500)
    Send('cscript ospp.vbs /act'& "{Enter}")
    Sleep(500)
    Send('slmgr.vbs /dli'& "{Enter}")
    Sleep(500)
    Send("Exit{Enter}")

 

Regards,
 

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