Link to home
Start Free TrialLog in
Avatar of Randy Johnson
Randy JohnsonFlag for United States of America

asked on

4k character line, batch file

I am running a command line command in a batch file

mysql -urandy -prandy -Drandy -e "REPLACE INTO randy (fields....) SELECT....


The line is around 4000 characters long.   If I run the bat file in XP   it is fine.

If I run it in win2k server  I get an error : The input line is too long.


I read  that There is a hard code limit in a bat file that I should use vbscript to run the command.

How would I use vbscript to run the command?


Randy
Avatar of dlwyatt82
dlwyatt82
Flag of Canada image

'**********************************

Dim WshShell

Set WshShell = CreateObject("WScript.Shell")
Call WshShell.Run("mysql.exe -urandy -prandy -Drandy -e ""REPLACE INTO randy (fields....) SELECT....""", 7, True)

Set WshShell = Nothing

'**********************************

Note the double "" if you want a quotation mark to be part of your string - in this case, part of the command line used to launch mysql.exe.  There are three quotes (""") at the end of the string in my example - two of them add a quote to the string itself, and the third indicates the end of the string to VBScript.  The second and third parameters (7, true) specify that the app should start up Minimized, and that your VBScript should wait until mysql.exe has finished executing before moving on to the next line in the script.

See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/wsmthrun.asp
Avatar of Randy Johnson

ASKER


E:\randy\bigmysql.vbs(4, 1) Microsoft VBScript runtime error:
Permission denied


Any ideas how how to fix this ?  that is what happens when I run the script
probably some kind of error in your command line.  Try this instead, as a debug.  Note that I have commented out the lines that actually attempt to Run the program (using the single quote ' ).  This version is just to output the command line you're trying to launch.  Edit the strCmd =   line and run it, then paste the output here and we should be able to see the problem.

'**********************************

Dim WshShell
Dim strCmd

strCmd = "mysql.exe -urandy -prandy -Drandy -e ""REPLACE INTO randy (fields....) SELECT...."""

WScript.Echo strCmd

'Set WshShell = CreateObject("WScript.Shell")
'Call WshShell.Run(strCmd, 7, True)

'Set WshShell = Nothing

'**********************************
 
I ended up using a mysql statement   :

-e "source replace.sql" -v -v -v  and it worked fine.
ASKER CERTIFIED SOLUTION
Avatar of PAQ_Man
PAQ_Man
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial