ricky Posted January 22, 2014 Share Posted January 22, 2014 Hello, I have a command line to execute in a dos prompt, but my command line as a quote and double-quote, how can I execute it? Line : osql -E -S .SQLEXPRESS -h-1 -Q "SET NOCOUNT ON; SELECT 'Version=', CONVERT(NVARCHAR,SERVERPROPERTY('productversion'))" My function to execute the command line : Func DosCommand($command) Local $foo, $line, $temp $foo = Run(@ComSpec & " /c " & $command, @ScriptDir, @SW_HIDE, 2); $STDOUT_CHILD = 2 De Constants.au3 While 1 $line = StdoutRead($foo) If @error Then ExitLoop If $line <> "" Then $temp &= _OEMToAnsi($line) WEnd Return $temp EndFunc ;==>DosCommand Func _OEMToAnsi($sOEM) ; http://autoitscript.fr/forum/viewtopic.php?f=21&t=4108&hilit=conversion+OEM+ANSI Local $sAnsi Local $a_AnsiFName = DllCall('user32.dll', 'Int', 'OemToChar', 'str', $sOEM, 'str', '') If @error = 0 Then $sAnsi = $a_AnsiFName[2] Return $sAnsi EndFunc ;==>_OEMToAnsi Thanks for your help Link to comment Share on other sites More sharing options...
michaelslamet Posted January 22, 2014 Share Posted January 22, 2014 (edited) $command = 'osql -E -S .\SQLEXPRESS -h-1 -Q "SET NOCOUNT ON; SELECT ' & "'Version=', CONVERT(NVARCHAR,SERVERPROPERTY('productversion'))" & '"' Edit: too many ' char Edited January 22, 2014 by michaelslamet Link to comment Share on other sites More sharing options...
ricky Posted January 22, 2014 Author Share Posted January 22, 2014 (edited) Hello, thanks, in first test it doesn't work because a quote before Version is not necssary, working line : $command = 'osql -E -S .\SQLEXPRESS -h-1 -Q "SET NOCOUNT ON; SELECT ' & "'Version=', CONVERT(NVARCHAR,SERVERPROPERTY('productversion'))" & '"' Thanks a lot! Edited January 22, 2014 by ricky03 Link to comment Share on other sites More sharing options...
michaelslamet Posted January 22, 2014 Share Posted January 22, 2014 Hello, no, doesn't work! Sorry that I type too much ' char. Please try the edited post above Link to comment Share on other sites More sharing options...
ricky Posted January 22, 2014 Author Share Posted January 22, 2014 I edit at the same time. 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