here is my problem code
Location = FolderChoiceTextBox.Text + "\copy.bat" FileOpen(1, Location, OpenMode.Output) 'open text file for writing 'used in the loop Dim pa As Integer PrintLine(1, "@echo off") 'autorun.inf PrintLine(1, ":: variables") 'autorun.inf PrintLine(1, "set drive=", locationdrive.Text) 'autorun.inf PrintLine(1, "set backupcmd=xcopy /s /c /d /e /h /i /r /k /y") 'autorun.inf PrintLine(1) 'loop round each item in the list box Do While pa < CheckedListBox1.Items.Count PrintLine(1, "echo ### Backing up Selected Documents...") ' PrintLine(1, "%backupcmd%", Chr(34) & CheckedListBox1.Items.Item(pa) & Chr(34) & "%drive%\", outputdir.Text & Chr(34)) 'this line here currently output the user selected path and then the output drive PrintLine(1) MsgBox(CheckedListBox1.Items.Item(pa)) pa = pa + 1 Loop PrintLine(1, "echo Backup Complete!") 'autorun.inf INPUTS PrintLine(1, "@pause") 'autorun.inf INPUTS FileClose(1)
That outputs a .bat file when the save button is clicked the output of the file looks like this:
@echo off :: variables set drive= sssw set backupcmd=xcopy /s /c /d /e /h /i /r /k /y echo ### Backing up Selected Documents... %backupcmd% "C:\Documents and Settings\Matthew gooch\My Documents\My Pictures\untitled.bmp"%drive%\ " echo Backup Complete! @pause
When I run the bat file it doesnt work, which i think is due to the large gaps between:
set drive= sssw
+
%drive%\ "
Is there anyway to stop VB outputting it like this ?
The second problem is a little more complex (i think) than the first. In the program I have a text box which is used to fill in the drive path(marked in red) which will be used as an output folder for the little bat file this program creates.
PrintLine(1, "%backupcmd%", Chr(34) & CheckedListBox1.Items.Item(pa) & Chr(34) & "[color=#FF0000]%drive%\", outputdir.Text [/color]& Chr(34))
Breakdown of code:
PrintLine(1, "%backupcmd%", In here goes a file that the user has selected a JPG,GIF,PDF etc etc the output looks like (C:\image.jpg) & "drive%\", In here should go an output folder on the drive selected (output folder).)
So my problem is if i enter an output folder into outputdir.Text then it adds the output folder i entered to every file added to the list due to the loop in my code. I need it so if outputdir.text has text in it it then atatches it to that user selcected file only then continues around the loop.
I can send the compelte source of .exe if necassery on request.
Thanks in advance for the help