mattfaust Posted January 20, 2014 Share Posted January 20, 2014 My password ( !SQLpassword ) is not getting read and entered correctly, why? thanks expandcollapse popup#include <GUIConstantsEx.au3> #include <ProgressConstants.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <StaticConstants.au3> #include <Process.au3> Local $SQLinstance,$user,$pw, $SaveDir, $progressbar, $button, $wait, $s, $msg, $m GUICreate("SQL DB Backup", 300, 140, 300, 200) $SQLinstance = GUICtrlCreateEdit("LOCALHOST\MSSQLEXPRESS", 10, 10, 200, 20) $user = GUICtrlCreateEdit("SQLusername", 10, 40, 200, 20) $pw = GUICtrlCreateEdit("!SQLpassword", 10, 70, 200, 20) $progressbar = GUICtrlCreateProgress(10, 100, 200, 20) GUICtrlSetColor(-1, 32250); not working with Windows XP Style ;$progressbar2 = GUICtrlCreateProgress(10, 40, 200, 20, $PBS_SMOOTH) $button = GUICtrlCreateButton("Start", 220, 100, 70, 20) $SaveDir = GUICtrlCreateEdit("D:\Backup\SQL" & @CRLF, 10, 120, 200, 20) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $button ; Run Notepad with the window maximized. ; $iPID = Run("notepad.exe", "", @SW_SHOWMAXIMIZED) RunBackup() EndSwitch WEnd Func RunBackup() $SQLinstance1=GUICtrlRead($SQLinstance) $username=GUICtrlRead($user) $password= GUICtrlRead($pw) $command = "sqlcmd -S "&$SQLinstance1&" -U "&$username&" -P "&$password&" -Q "&'"'&"BACKUP DATABASE testDB TO DISK="&"'"&"C:\temp\Backupsql.bak"&"'"&'"' ;RunWait($command) $iPID = Run("notepad.exe", "") Sleep (1000) Send ($command) ;exit EndFunc Link to comment Share on other sites More sharing options...
mikell Posted January 20, 2014 Share Posted January 20, 2014 ! is reserved in the Send() function -- it means ALT To send your string raw you must write it like this Send ($command, 1) Link to comment Share on other sites More sharing options...
mattfaust Posted January 21, 2014 Author Share Posted January 21, 2014 so how would I use $command in RunWait, as it doesnt have the raw flag? Link to comment Share on other sites More sharing options...
BrewManNH Posted January 21, 2014 Share Posted January 21, 2014 What is $password getting set to? Also, you should be using an input control (GUICtrlCreateInput) instead of an edit control because an edit control can have more than one line by default. 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...
michaelslamet Posted January 21, 2014 Share Posted January 21, 2014 I cant see why RunWait can fail on this. Go and try it, I think it should no issue with ! character Link to comment Share on other sites More sharing options...
mattfaust Posted January 21, 2014 Author Share Posted January 21, 2014 $password = !SQLPassword. it doesnt seem to work but the dos window is closing before I can read the output, it may be another issue. is there a way I can make the command window stay - or - capture the output, Im reading about StderrRead - but im a bit lost Link to comment Share on other sites More sharing options...
Solution michaelslamet Posted January 21, 2014 Solution Share Posted January 21, 2014 Try this: RunWait(@comspec & " /k " & $command) Link to comment Share on other sites More sharing options...
mattfaust Posted January 21, 2014 Author Share Posted January 21, 2014 thanks 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