I can't run my batch file

M

Marco

Hello.

I can't run the commands of my batch file if I call the batch trought a
Macro o VBA code, but if I click twice on the file it works.

I tried in multiples ways, RunCommand; RunApp but is doesn't work.

This is what I have in the batch file:

ftp -a -s:ftp.txt

I also tried with this:

ftps.exe -a -s:ftp.txt

the txt file as the command lines of the FTP.

Please help.

Regards,
Marco
 
J

Jae

If you are trying to run a batch file from Access, try using Shell command.

shell ("path of the batch file")
 
M

Marco

Hello.

Such as

Shell ("c:\site\upload.bat")

Only that?

Can I use the Shell word in macros?


Thanks,
Marco
 
M

Marco

Hello.

In wich Macro Action type will put that code?

RunApp?

PS: Rui are you portuguese?

Thanks.
Marco
 
R

Rui

Marco,

Shell is a function. you can use it in a VBA module. Try this:

open a VBA module and type:

Sub TestShell()
Shell ("c:\windows\notepad.exe")
end sub

This should open notepad. If you need more info, highligh shell and press
F1, you should be able to get more info on the function.

One last thing, disregard my last reply about the escaping the \ by doing \\.
I've been programming with other languages and messed up.

Rui

PS. - Sou portugues, embora nao esteja em Portugal. Desculpa, nao tinha
reparado no teu nome. Ja nao vinha a estes grupos 'a alguns anos. Comecei a
ler algumas das perguntas e tive de responder. Um abraco.
 
M

Marco

Oi.

Mas apoias a seleccição no europeu?

Tás á mt tempo a programar? eu comecei a dar uns toques mas isto é
complicado. só cenas em access.

ainda por cima esta cena de enviar os ficheiros por ftp não funciona.

Isto não funciona. ele até chama o ficheiro mas não faz nada. Não me envia
o ficheiro para o servidor FTP.

Tou-me a passar com isto.

Obrigado,
marco
 
R

Rui

desculpa a demora.

Claro que apoio a seleccao. quando se esta fora do pais, sao coisinhas como
estas que nos dao alguma alegria.

Ja programo a alguns anos. o dificel e' comecar. Depois, as coisas comecam a
ser mais simples.

Quanto ao teu problema, estas no caminho certo mas deves ter algum erro.
Aqui vao umas sugestoes:

1. abre o notepad e escreve o teu comando. guarda o ficheiro com c:\nome.bat
ftp -a -s:ftp.txt (acho que falta aqui qq coisa, tal como username e
password)
2. Abre uma janela de DOS. (windows->run->cmd). escreve nome.bat
Tens alguma mensagem de erro?
3. se funcionou, altera o ficheiro .bat que criaste. insere "cmd /k " no
inicio da linha.
4. volta a fazer o passo 2.
5. cria um novo modulo em access e escreve:
Sub TestShell()
dim retorno
retorno= Shell ("c:\nome.bat")
end sub
6. Funcionou on tens mensagens de erro?


Eu sei que e possivel fazer isto porque ja o fiz a algum tempo atras. Estava
a utilizar outro programa (winscp) mas tive sucesso.

Rui
 
M

Marco

RUI.

Obrigadão.

Acho que com a tua ajuda consegui perceber onde estava o problema. o cmando
cmd /k foi crucial. como consegui ler a linha de comandos percebi o problema.
mas não era fácil.

Obrigado.
Marco
 
R

Rui

fico muito contente que tenhas conseguido.

O commando que te indiquei tem salvo a minha vida muitas vezes ;)

Rui
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top