arcticpup Posted February 27, 2009 Share Posted February 27, 2009 Hi, I'm still very new to AutoIT and am struggling with the following. OK, here's what I want to do. Read a registry key (this is actually the SQL server and instance name eg: mycomputer\sqlexpress) into a variable. I'm OK with this bit. Now, I want to connect to the SQL server using the above variable and a trusted connection (so in dos it would look like osql -Smycomputer\sqlexpress -E) How do I pass the variable created into the middle of a DOS string? I've tried _rundos() without much luck. Once I've overcome that hurdle, I want to retrieve a certain value from a certain table. (Which in SQL I'm fine with) CODEUse MYDB Select accesspassword from ib21 where staffnumber = 1 go Ideally, I would like the result to be returned as a dialog box or failing that as a text file. Amy I asking the impossible here? Any help would be greatly appreciated. Link to comment Share on other sites More sharing options...
arcticpup Posted February 27, 2009 Author Share Posted February 27, 2009 OK, I've made some progress and consolidated it into 1 CMD file without the need for a seperate SQL file. Now I have just 2 questions. 1)How do I pass the registry variable into the DOS command 2)Can I use _runDOS without the quotes as it is messing up my SQL string (Or can I just pass the SQL file direct to dos via autoit?) Link to comment Share on other sites More sharing options...
KaFu Posted February 27, 2009 Share Posted February 27, 2009 1) $var = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir") Run(@ComSpec & " /k " & 'echo ' & $var) 2) I guess you can't. You can either escape quotes by quoting them or use single quotes to enclose the statement if $var contains double quotes or the other way around. MsgBox(0,"Test"," "" ") MsgBox(0,'Test',' '' ') MsgBox(0,"Test"," ' ") MsgBox(0,'Test',' " ') OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
arcticpup Posted February 27, 2009 Author Share Posted February 27, 2009 1) $var = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir") Run(@ComSpec & " /k " & 'echo ' & $var) 2) I guess you can't. You can either escape quotes by quoting them or use single quotes to enclose the statement if $var contains double quotes or the other way around. MsgBox(0,"Test"," "" ") MsgBox(0,'Test',' '' ') MsgBox(0,"Test"," ' ") MsgBox(0,'Test',' " ')Great stuff! Have now got it creating a text file.... Is it possible to take the output from the DOS box and have this display in a message box. Thanks for all your help so far though! Link to comment Share on other sites More sharing options...
PsaltyDS Posted February 27, 2009 Share Posted February 27, 2009 Great stuff! Have now got it creating a text file.... Is it possible to take the output from the DOS box and have this display in a message box. Thanks for all your help so far though!Yet another dog eats yet another help file...Look up StdOutRead(). Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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