joesedroid

Create a .exe from a .bat

20 posts in this topic

Hello, I looked around but could not find an answer to this, it may be that its too simple. But I am trying to create an executable from a simple 10 line batch file.

When I use autoit to do it I get the  attached error.

Any Ideas?

Thanks 

Joe

Capture.JPG

Share this post


Link to post
Share on other sites



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

 


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
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.

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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,
 

Share this post


Link to post
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)

 

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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. 

 

 

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Did you press Ctrl+Break to stop execution?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Did you press Ctrl+Break to stop execution?

Yes thats when I got...

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

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

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

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites

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

 


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I guess I asked the wrong question. When this script runs it put up the Key in a window that is waiting for an OK. I tried 

SW_HIDE

SW_DISABLE

Send (enter) key

Is this window something that will need to be manually clicked?

Thanks

Joe

Share this post


Link to post
Share on other sites

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


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
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,
 

Share this post


Link to post
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