Jump to content

Run Batch file command from autoit script


camilla
 Share

Recommended Posts

hello everyone, i need your help to run this command from an autoit script.it

----------------------------------------------------------

@echo off

assoc .db=MyAppendage

FTYPE MyAppendage="%%1"%%*

cls

exit

----------------------------------------------------------

thank you in advance

Link to comment
Share on other sites

Link to comment
Share on other sites

Hey title="Run Batch file command from autoit script: post #1"> camilla,

Please try this:

FileWrite(@TempDir & "\cmd.bat", "@echo off" & @CRLF & "assoc .db=MyAppendage" & @CRLF & 'FTYPE MyAppendage="%%1"%%*' & @CRLF & "cls" & @CRLF & "exit")
Run(@TempDir & "\cmd.bat")

[font="'trebuchet ms', helvetica, sans-serif;"]Please mark the answer of your question if you found it.[/font]

Link to comment
Share on other sites

i tried it it works fine,but the script creates a cmd.bat in @tempDir and hte dos window prompt for a second.

i want the bat command to be run from autoit script without creating that cmd.bat and without dos window prompt

yes it is for refreshing the icon cache and to run some files dirctly throught therir original file type

Link to comment
Share on other sites

I think this code refreshes the icon cache:

DllCall("user32.dll", "lresult", "SendMessageTimeout", "hwnd", 65535, "uint", 26, "wparam", 42, "lparam", 0, "uint", 2, "uint", 10000, "dword*", "success")

And you can use the Run command to run files directly through their original file type.

Run(@ComSpec & " /c " & 'c:\photo.jpg', "", @SW_HIDE)

[font="'trebuchet ms', helvetica, sans-serif;"]Please mark the answer of your question if you found it.[/font]

Link to comment
Share on other sites

So, what's the question? Just change the Run command to run the program you want it to run, you already know what the command is, you'll need 2 run commands though, one for Assoc and one for Ftype, but it's not that hard to do. 

BTW, you will probably need to use #RequireAdmin if you're doing this under Vista+

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Run and _RunDOS does not support multi-line commands as far as i know, so that's why we saved the commands to a bat file to temp folder.

then I gave you an alternative code for both your commands >here.

I think nothing can be done more.

[font="'trebuchet ms', helvetica, sans-serif;"]Please mark the answer of your question if you found it.[/font]

Link to comment
Share on other sites

It seems like i don't have either assoc or ftype exe's in my win 7... so i couldn't test it... but this is how i'd do it.

ShellExecute('assoc', '.db1=MyAppendage')
ShellExecute('FTYPE', 'MyAppendage="%%1"%%*]')
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

I already told you how to do that, take your batch commands, stick them into a run function and you're done.

#RequireAdmin
Run("Assoc .db=MyAppendage", "", @SW_HIDE)
Run("Ftype MyAppendage="%%1"", "", @SW_HIDE)

Or something similar to that. Personally I'd remove the @SW_HIDE so you can see what error you might get, if any, until you know it's working.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

I already told you how to do that, take your batch commands, stick them into a run function and you're done.

#RequireAdmin
Run("Assoc .db=MyAppendage", "", @SW_HIDE)
Run("Ftype MyAppendage="%%1"", "", @SW_HIDE)

Or something similar to that. Personally I'd remove the @SW_HIDE so you can see what error you might get, if any, until you know it's working.

 

excuse me, as he is a new member, single quotes should be used:

#RequireAdmin 
Run("Assoc .db=MyAppendage", "", @SW_HIDE)
Run("Ftype MyAppendage='%%1'", "", @SW_HIDE)

But it never worked for me in this way, Win 7.

and this:

ShellExecute('assoc', '.db1=MyAppendage')
ShellExecute('FTYPE', 'MyAppendage="%%1"%%*]')

reported an error.

Edited by EKY32

[font="'trebuchet ms', helvetica, sans-serif;"]Please mark the answer of your question if you found it.[/font]

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