radix Posted January 21, 2015 Posted January 21, 2015 (edited) Hello,I got this folder structure:"\$1\Install\CCleaner_x86_&_x64" In $1 I have Install.cmd which call a cmd file located in the above folder structure: "\$1\Install\CCleaner_x86_&_x64\CCleaner_x86_&_x64.cmd"CCleaner_x86_&_x64.cmd will install CCleaner and it's OK. Install.cmd from $1 folder have this content:@Echo Off:: Install CCleanerSTART CMD /C "CD %~dp0Install\Piriform_CCleaner_5.1.5075_x86_&_x64 & CCleaner_x86_&_x64.cmd" and don't work. If I remove & characters from folder and file names, it will work fine.So, it's possible to succesfully call the second cmd file if it's located in a folder structure that contain & character and/or spaces?Thanks Edited January 21, 2015 by radix
Yzöwl Posted January 21, 2015 Posted January 21, 2015 Remove the & characters then! The folder/file names are your choice so choose something sensible for the environment and scripting language you're using.
radix Posted January 22, 2015 Author Posted January 22, 2015 So, these are the limit of batch scripting. Thanks!
gunsmokingman Posted January 22, 2015 Posted January 22, 2015 Perhaps a VBS script might work, place the below script in the folder and it should open Test.txt if it there.Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject") If Fso.FileExists("Test.txt") Then WScript.Echo "Confirm : " & _ Replace(WScript.ScriptFullName,WScript.ScriptName,"") & "Test.txt" CreateObject("Wscript.Shell").Run("Test.txt"),1,False Else WScript.Echo "Missing : " & _ Replace(WScript.ScriptFullName,WScript.ScriptName,"") & "Test.txt" End If Contents Of Test.txtTesting $ in pathway. 1
jaclaz Posted January 22, 2015 Posted January 22, 2015 It is not about "limits" of batch files. The concept of "special" characters is that a few characters are "special" . Which while it remains true that it makes very little sense (actually NO sense ) to use a "special" character in a file name as it is the perfect way to make your own batches/scripts/whatever more complex than needed and have *any* third party batch/script/whatever fail, the "special" character can be dealt with - in a "special" way .Namely you need to escape "special" characters:http://www.robvanderwoude.com/escapechars.php @gunsmokingman"$" is not AFAIK/AFAICR a "special" character in batch. jaclaz 1
radix Posted January 22, 2015 Author Posted January 22, 2015 (edited) Thanks jaclaz to point in the right direction.The working batch script:START /WAIT CMD /C "CD %~dp0Install\Piriform_CCleaner_5.1.5075_x86_^&_x64 & Piriform_CCleaner_5.1.5075_x86_^&_x64.cmd" Edited January 22, 2015 by radix
Yzöwl Posted January 22, 2015 Posted January 22, 2015 You may in your example above, be better advised using START "" /WAIT, where "" is "EMPTY TITLE". It's still a pointless exercise to have a file and folder structure over which you have full control and deliberately use naming structures which are not suitable. The folder inside $1 you have named Install, all of the sub folders and their contained batch files can be named anything at all, so why choose something which means that you need to take special action within their contained installation scripts. Take for instance the example above, everyone knows that the program is called CCleaner, nobody, except for those directly involved with the Developer cares at installation time who makes it so drop the Piriform_ from both the directory and file names. If I was to only have x64 version of any software then I would include x64 in the names otherwise I know that the software would install on either platform. So since this obviously installs on both platforms, just drop the _x86_&_x64 from the names. Additionally, the installation batch file in every folder doesn't need to carry the same name as the parent folder, if it's in the CCleaner directory it's relatively safe to assume it isn't used to install Opera in the Opera directory, so just tell us what it does by giving it a sensible name. Then you should be creating the individual batch files to use their parent directories if necessary for the current directories in order that you don't have to specifically code it in your working batch script. Examples:CALL "%~dp0Install\CCLeaner_5.1.5075\install.cmd"START "" /W CMD /C "%~dp0Install\CCLeaner_5.1.5075\install.cmd" The system above also means that if you wanted to install the following five programs you could use something like this:FOR %%A IN ("Prog_1" "Prog_2" "Prog_3" "Prog_4" "Prog_5") DO CALL "%~dp0Install\%%~A\install.cmd"
gunsmokingman Posted January 22, 2015 Posted January 22, 2015 Well Jaclas my script will run with special charaters in the name. 1
jaclaz Posted January 22, 2015 Posted January 22, 2015 Well Jaclas my script will run with special charaters in the name.I never doubted it , I am pretty sure that your .vbs (or other) scripts are well thought out and well written , I was only pointing out how your earlier example:Testing $ in pathway.was not a valid example of a test of *anything* for a "special" character in a path (because "$" is not "special"). Gotta go , I have to test my new scuba diving equipment and - strangely enough - I go underwater to test it, as last time I tested one by making a short (but brisk ) walk outside it came out eventually that it was not fully waterproof... @radixWell, you have been told (and re-told):http://homepage.ntlworld.com./jonathan.deboynepollard/FGA/dukhat-on-foolishness.html jaclaz
bphlpt Posted January 23, 2015 Posted January 23, 2015 @jaclaz, I believe you have an extra period "." in your link above after "com" - ntlworld.com./jonathan. Without it, the link works fine. - http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/dukhat-on-foolishness.html. Cheers and Regards
jaclaz Posted January 23, 2015 Posted January 23, 2015 @jaclaz, I believe you have an extra period "." in your link above after "com" - ntlworld.com./jonathan. Without it, the link works fine. - http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/dukhat-on-foolishness.html. Cheers and RegardsYes/no Meaning that yes , there is actually an "extra dot after the com" in the posted link , which is a (recent) copy/paste from the generic DeBoyne Pollard's FGA's page:http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/but no , the link works fine here with or without the extra dot (... like we were talking here of special characters....)I wonder HOW I managed to insert it jaclaz
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now