Problem space in a folder to choose

Batch, ASP, JScript, Kixtart, etc.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Locked
User avatar
hackoo
Posts: 103
Joined: Sat Jan 22, 2011 12:27 am

Problem space in a folder to choose

Post by hackoo » Thu Feb 16, 2012 9:11 am

Hi
I'm making a HTA for compressing with 7zip , but i'm a little stuck on the folder settings to choose from it must be without spaces.
So I'm looking for a tip or trick to circumvent this problem space. Thank you for your help

Code: Select all

 <html> 
<head>  
<SCRIPT LANGUAGE="VBScript">  
'=========================================================  
'Fenêtre pour choisir le répertoire cible de la sauvegarde  
'=========================================================  
Const WINDOW_HANDLE = 0  
BIF_editbox = &H0010  
titre="Sélectionner la destination de la sauvegarde"  
CenterWindow 260,180  
Set objShell = CreateObject("Shell.Application")  
Set objFolder = objShell.BrowseForFolder _  
(WINDOW_HANDLE, titre , BIF_editbox)  
On Error Resume Next  
Set objFolderItem = objFolder.Self  
If Err <> 0 Then  
msgbox "Annulation de la sauvegarde",48,"Annulation de la sauvegarde"  
fermer()  
Else  
objPath = EncodeURI(objFolderItem.Path)  
   
end If  
   
sub compression  
Set WshShell = CreateObject("WScript.Shell")  
Set fso = CreateObject("Scripting.FileSystemObject")  
oProgramFiles = WshShell.ExpandEnvironmentStrings("%PROGRAMFILES%")  
chemin7zip = oProgramFiles &"7-zip7z.exe"  
If Not fso.FileExists(chemin7zip) Then  
MsgBox "Le " & chemin7zip & " n'existe pas",48,chemin7zip  
WshShell.Run "http://www.spiroo.be/7zip/"  
Call Fermer  
Else  
strCMD = "cmd /K cd %PROGRAMFILES%7-zip & 7z.exe"  
password = pass.value  
MsgBox "Vous avez choisi le dossier " & qq(objPath) & " pour la sauvegarde",64,"Dossier Choisi "& qq(objPath)&""  
Str7zip = strCMD & " u " & objPath &"sauvegarde.zip " & objPath & " -p"&password  
MsgBox Str7zip,64," Commande à exécuter !"  
WshShell.Run Str7zip,1,True  
MsgBox "L'archive : " & objPath &"sauvegarde.zip est Crée avec Succès ! ",64,"sauvegarde.zip est Crée avec Succès !"  
Call Fermer  
End If  
End Sub  
   
Sub CenterWindow(x,y)  
window.resizeTo x,y  
iLeft = window.screen.availWidth/2 - x/2  
itop = window.screen.availHeight/2 - y/2  
window.moveTo ileft, itop  
End Sub  
   
Sub Fermer  
window.close()  
End Sub  
   
Function qq(strIn)  
qq = Chr(34) & strIn & Chr(34)  
End Function  
   
Function EncodeURI(StrAencoder)  
Dim cpT  
dim CharSpc(10), CharCod(10)  
CharSpc(0) = " ": CharCod(0) = "%20"  
CharSpc(1) = "µ": CharCod(1) = "%C2%B5"  
CharSpc(2) = "à": CharCod(2) = "%C3%A0"  
CharSpc(3) = "â": CharCod(3) = "%C3%A2"  
CharSpc(4) = "ê": CharCod(4) = "%C3%AA"  
CharSpc(5) = "ç": CharCod(5) = "%C3%A7"  
CharSpc(6) = "è": CharCod(6) = "%C3%A8"  
CharSpc(7) = "é": CharCod(7) = "%C3%A9"  
CharSpc(8) = "ë": CharCod(8) = "%C3%AB"  
CharSpc(9) = "ô": CharCod(9) = "%C3%B4"  
CharSpc(10) = "ø": CharCod(10) = "%C3%B8"  
   
EncodeURI = StrAencoder  
For cpT = 0 To UBound(CharSpc)  
EncodeURI = Replace(EncodeURI, CharSpc(cpT), CharCod(cpT), 1, -1, vbTextCompare)  
Next  
End Function  
</script>  
</head>  
<title>Sauvegarde avec l'utilitaire 7-Zip</title>  
<HTA:APPLICATION ID="Sauvegarde avec l'utilitaire 7-Zip"  
APPLICATIONNAME="Sauvegarde avec l'utilitaire 7-Zip"  
CAPTION="Yes"  
SHOWINTASKBAR="No"  
SINGLEINSTANCE="yes"  
SYSMENU="No"  
SCROLL="no"  
WINDOWSTATE="normal">  
<center>  
<body BGCOLOR="lightblue">  
Mot de passe OBLIGATOIRE : <input type="password" size="20" name="pass" ID="pass"><br><br>  
<input type="submit" id="BTvalider" name="valider" value="Continuer" onclick="compression()">  
<input type="button" id="Fermer" value="Fermer" onclick="Fermer()">  
</body>  
</html>

User avatar
jvierra
Posts: 13623
Joined: Tue May 22, 2007 9:57 am
Contact:

Problem space in a folder to choose

Post by jvierra » Thu Feb 16, 2012 9:42 am

Sorry but we cannot read your code and the question is very hard to understand.

Are you saying you have a listbox with spaces in it or you don't want spaces in the list.

Not clear at all.

"i'm a little stuck on the folder settings to choose from it must be without spaces. "

If you have a folder with spaces and you don't want he spaces yuo will need to rename the folder.

In any case that is just another guess becuse I cannot read your code and I do not understand the request.

User avatar
jvierra
Posts: 13623
Joined: Tue May 22, 2007 9:57 am
Contact:

Problem space in a folder to choose

Post by jvierra » Thu Feb 16, 2012 10:05 am

If a path has spaces in it you have to keep themm. There is no way to remove the spaces except to rename the folder.

If you need quotes then just add them.

objPath = """" & objePath & """"


Locked