Forum Discussion
joffre
15 years agoRegular Contributor
Hello,
Looks like the command being passed into the run command is incorrect. From your new results, I see two log messages that begins with 'Run Command'. First is on line 10 which shows the full command. The second one is on line 14 which looks much shorter. The variables 'ComandoCriarTabela and 'DirLog' are missing from the second log message. And this is the line that's being passed into the run command. The LGComponentes routine cannot access variables created outside of it's function unless they're global variables which is why they're effectively blank values.
I'm guessing these variables are accessible in the Sub routine above the LGComponentes function and the first log message is in the same routine. Try altering your code so you pass in the run command as a string into the LGComponentes function:
Set directUIHWND = explorer.wndCabinetWClass2.SHELLDLL_DefView.FolderView
'Renames 01 - LGComponentes folder to 1.LGComponentes and get inside of it
Call directUIHWND.Keys("01 - LGComponentes[F2]1.LGComponentes[Enter][Enter]")
Call directUIHWND.Keys(CaminhoDaPasta3)
'Renames the SQL file that starts with 1 to 1.sql
Call directUIHWND.Keys("Like %1%[F2]1.sql[Enter][BS]")
Call LGComponentes(ComandoCriarTabela & "1.LGComponentes\SQLServer\1.sql -o " &DirLog&"1.txt")
Call directUIHWND.Keys(CaminhoDaPasta4)
'Back at Scripts_Criacao_Banco, select the folder 1.LGComponentes and press the down arrow
Call directUIHWND.Keys("1.LGComponentes[Down]")
Log.Message("Pasta LGComponentes Renomeda com Sucesso!!!")
Function LGComponentes(strRunCommand)
Dim ShellObj
Set ShellObj = Sys.OleObject("WScript.Shell")
Log.Message("Run Command: " & strRunCommand)
Call ShellObj.Run(strRunCommand, 1, true)
Log.Message("Run command has completed.")
End Function
(Also a comment line only requires to begin with a single quote ' - I've made the changes above as well.)
Cheers,
Jackson
LOOKS LIKE it worked perfectly!!! I'll test it with bigger scripts that takes more time to run, and I'll tell you in a few minutes.
Could you please explain me what this function does exactly? Line by line if possible.
Function Funcao(strRunCommand)
Dim ShellObj
Set ShellObj = Sys.OleObject("WScript.Shell")
Log.Message("Run Command: " & strRunCommand)
Call ShellObj.Run(strRunCommand, 1, true)
Log.Message("Run command has completed.")
End Function
Appreciate your help!!!
About how to comment lines. I know just one ' is necessary. I do that to let me find that code easier.