camilla Posted September 3, 2013 Share Posted September 3, 2013 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 More sharing options...
camilla Posted September 3, 2013 Author Share Posted September 3, 2013 any help? Link to comment Share on other sites More sharing options...
Danyfirex Posted September 3, 2013 Share Posted September 3, 2013 You should wait for help. ¬¬ don't bump your post before 24 hour. Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
EKY32 Posted September 3, 2013 Share Posted September 3, 2013 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 More sharing options...
camilla Posted September 3, 2013 Author Share Posted September 3, 2013 EKY32 thank you it works, but the cmd.bat still exist in tempdir i want the script to run the bat command directly without any other files thank you Link to comment Share on other sites More sharing options...
EKY32 Posted September 3, 2013 Share Posted September 3, 2013 Yes, try this: FileWrite(@TempDir & "\cmd.bat", "@echo off" & @CRLF & "assoc .db=MyAppendage" & @CRLF & 'FTYPE MyAppendage="%%1"%%*' & @CRLF & "cls" & @CRLF & "del %temp%\cmd.bat" & @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 More sharing options...
EKY32 Posted September 3, 2013 Share Posted September 3, 2013 And please, can I ask what does your code do? Is it for refreshing the icon cache or something? [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 More sharing options...
camilla Posted September 3, 2013 Author Share Posted September 3, 2013 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 More sharing options...
EKY32 Posted September 3, 2013 Share Posted September 3, 2013 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 More sharing options...
camilla Posted September 3, 2013 Author Share Posted September 3, 2013 exactly i need this code -------------------------------------------------------- Run(@ComSpec & " /c " & 'c:photo.jpg', "", @SW_HIDE) ------------------------------------------------------------------------- but instead "c:photo.jpg" i need to run the commands [ assoc .db=MyAppendage FTYPE MyAppendage="%%1"%%*] Link to comment Share on other sites More sharing options...
BrewManNH Posted September 3, 2013 Share Posted September 3, 2013 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 GudeHow 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 More sharing options...
camilla Posted September 3, 2013 Author Share Posted September 3, 2013 i want to run that command without dos prompt i mean run directly from the autoit script as an autoit script not a batch script Link to comment Share on other sites More sharing options...
EKY32 Posted September 3, 2013 Share Posted September 3, 2013 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 More sharing options...
DW1 Posted September 3, 2013 Share Posted September 3, 2013 RunWait(@COMSPEC & " /c ASSOC .db=MyAppendage", "", @SW_HIDE) RunWait(@COMSPEC & " /c FTYPE MyAppendage=""%%1""%%*", "", @SW_HIDE) Although you could accomplish this with autoit alone by simply creating the proper registry values. AutoIt3 Online Help Link to comment Share on other sites More sharing options...
careca Posted September 3, 2013 Share Posted September 3, 2013 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 More sharing options...
BrewManNH Posted September 3, 2013 Share Posted September 3, 2013 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. EKY32 1 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 GudeHow 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 More sharing options...
EKY32 Posted September 3, 2013 Share Posted September 3, 2013 (edited) 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 September 3, 2013 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 More sharing options...
camilla Posted September 3, 2013 Author Share Posted September 3, 2013 danwilli thank you careca thank you thank you it works as i want it now 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. i will test it and see in win7 32&64 Link to comment Share on other sites More sharing options...
JCEF Posted September 3, 2013 Share Posted September 3, 2013 Try _RunDos funtion: http://www.autoitscript.com/autoit3/docs/libfunctions/_RunDos.htm Link to comment Share on other sites More sharing options...
JCEF Posted September 3, 2013 Share Posted September 3, 2013 Try _RunDos funtion: http://www.autoitscript.com/autoit3/docs/libfunctions/_RunDos.htm This had already been said. Sorry. I opened the page some time ago and I have not refreshed before this post. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now