Randy Johnson
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
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
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.Shel l")
'Call WshShell.Run(strCmd, 7, True)
'Set WshShell = Nothing
'************************* *********
'*************************
Dim WshShell
Dim strCmd
strCmd = "mysql.exe -urandy -prandy -Drandy -e ""REPLACE INTO randy (fields....) SELECT...."""
WScript.Echo strCmd
'Set WshShell = CreateObject("WScript.Shel
'Call WshShell.Run(strCmd, 7, True)
'Set WshShell = Nothing
'*************************
ASKER
I ended up using a mysql statement :
-e "source replace.sql" -v -v -v and it worked fine.
-e "source replace.sql" -v -v -v and it worked fine.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Dim WshShell
Set WshShell = CreateObject("WScript.Shel
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