I need Shell.Execute to execute multiple commands. But I noticed that every time a Shell.Execute gets executed, even without a Shell.Close, it executes it in it’s own, new environment with no ‘memory’ of the previous executed command.
I need to go to a specific director first, with a “CD \MyDirectory\MySecondDirectory\TargetDirectory” first before I can use a Shell.Execute in this “Targetdirectory” where an executable resides.
I use 7Z open source library to extract .CBR and CBZ (comic book) files which are essentialy RAR and ZIP files.
The && concatenation works fine. The problem I have is putting quotes around path parameters. My command string build-up (it is complicated): CommandString = "CD " + UnZipCommandPath + " && 7z.exe E """ + MyComicBookFolder.Child(ComicFile.Name).NativePath + """ -O" + ""+ MyComicBookFolder.NativePath + ""
The literal I get from that is: CD C:\Users\slind\SynologyDrive\Dev\ComicReader\Source\DebugStrip\DebugStrip libs\ && 7z.exe E "C:\Users\slind\AppData\Roaming\ComicReader\Cache\Bob Morane - 19 - De Draak Van De Fenstones\Bob Morane - 19 - De Draak Van De Fenstones.cbr" -OC:\Users\slind\AppData\Roaming\ComicReader\Cache\Bob Morane - 19 - De Draak Van De Fenstones\
which works OK. Except the last parameter -O etc -OC:\Users\slind\AppData\Roaming\ComicReader\Cache\Bob Morane - 19 - De Draak Van De Fenstones) should get quotes around it.
It works with the first parameters, but not with the last. This double/triple quote thing is confusing to say the least.
[EDIT] Solved. I needed 4 quotes to get the correct result: CommandString = "CD " + UnZipCommandPath + " && 7z.exe E """ + MyComicBookFolder.Child(ComicFile.Name).NativePath + """ -O" + """"+ MyComicBookFolder.NativePath + """"