Hi,
I have searched the forums and have got a partial answer to the following - but not fully.
First I wanted to run a batch file from a shell command, where there were spaces in the file path. I done this by doing the following:
dim x
dim shell_cmd
shell_cmd = _
chr(34) & "c:\folder with space\batchfile.bat" & chr(34)
x = shell(shell_cmd, 1)
This runs fine.
The next step is I want to pass in a log file as a parameter.
This works fine if there are no apaces in the log file, such as:
dim x
dim shell_cmd
shell_cmd = _
chr(34) & "c:\folder with space\batchfile.bat" & chr(34) & _
"c:\log_file.txt"
x = shell(shell_cmd, 1)
So my problem is where the parameter has a space in the folder name such as "c:\folder with space\log_file.txt"
I have tried many variations without success - but initially thought the way to go was:
dim x
dim shell_cmd
shell_cmd = _
chr(34) & "c:\folder with space\batchfile.bat" & chr(34) & _
" " & chr(34) & "c:\folder with space\log_file.txt" & _
chr(34)
x = shell(shell_cmd, 1)
The batch file is using this parameter as a log file - so every command is followed by ">>%1".
But it doesn't run. The batch file is called, but it fails to interpret the log file as a parameter.
Anyone with any ideas?
I really do think I have exausted all variations.
Apart from getting the business to not have spaces in their folder names, an alternative would be to define the folder path in the actual batch file and only pass in the log file name, then append the 2 in the batch file - but as the vb code will be calling about 30 different batch files, I want to maintain the folder in the vb code and pass it in.
Thanks
Aidan
I have searched the forums and have got a partial answer to the following - but not fully.
First I wanted to run a batch file from a shell command, where there were spaces in the file path. I done this by doing the following:
dim x
dim shell_cmd
shell_cmd = _
chr(34) & "c:\folder with space\batchfile.bat" & chr(34)
x = shell(shell_cmd, 1)
This runs fine.
The next step is I want to pass in a log file as a parameter.
This works fine if there are no apaces in the log file, such as:
dim x
dim shell_cmd
shell_cmd = _
chr(34) & "c:\folder with space\batchfile.bat" & chr(34) & _
"c:\log_file.txt"
x = shell(shell_cmd, 1)
So my problem is where the parameter has a space in the folder name such as "c:\folder with space\log_file.txt"
I have tried many variations without success - but initially thought the way to go was:
dim x
dim shell_cmd
shell_cmd = _
chr(34) & "c:\folder with space\batchfile.bat" & chr(34) & _
" " & chr(34) & "c:\folder with space\log_file.txt" & _
chr(34)
x = shell(shell_cmd, 1)
The batch file is using this parameter as a log file - so every command is followed by ">>%1".
But it doesn't run. The batch file is called, but it fails to interpret the log file as a parameter.
Anyone with any ideas?
I really do think I have exausted all variations.
Apart from getting the business to not have spaces in their folder names, an alternative would be to define the folder path in the actual batch file and only pass in the log file name, then append the 2 in the batch file - but as the vb code will be calling about 30 different batch files, I want to maintain the folder in the vb code and pass it in.
Thanks
Aidan