Ok, Never mind the previous post
At First you can replace These lines:
Code: Select all
if %cho%==Y goto INSTALL1
if %cho%==y goto INSTALL1
if %cho%==n goto EXIT
if %cho%==N goto EXIT
with
Code: Select all
if /i %cho%==Y goto INSTALL1
if /i %cho%==N goto EXIT
the /i switch will ignore the letter case ( capital or small) and will treat both as the same.
also add
set "cho=" before
set /p "cho=>" to prevent any crashes when the user input nothing and press enter directly.
Now this what you are going to do after you finish coding your batch:1> After the Exit command add this function:Code: Select all
:GUI <variable_to_set_destinatio_to>
IF Exist "output1256.txt" DEL /F /Q "output1256.txt" >NUL
rem Create the VBScript, if not exist
IF NOT EXIST "%~DP0GUI.vbs" (
( FOR /F "tokens=1*" %%a IN ('findstr "^:VBS: " ^< "%~F0"') DO Echo.%%b )>"%~DP0GUI.vbs"
)
Cscript //nologo "%~DP0GUI.vbs"
For /F "delims=" %%A In ('Type "OutPut.txt"') Do SET "%~1=%%A"
GOTO :EOF
:VBS: Option Explicit
:VBS: BrowseFolder "My Computer", False
:VBS: 'Source/Destination Folder
:VBS: Function BrowseFolder( myStartLocation, blnSimpleDialog )
:VBS: Const MY_COMPUTER = &H11&
:VBS: Const WINDOW_HANDLE = 0 ' Must ALWAYS be 0
:VBS: Dim numOptions, objFolder, objFolderItem
:VBS: Dim objPath, objShell, strPath, strPrompt,oFS, objShell2, fsHandle
:VBS: strPrompt = "Select a Folder:"
:VBS: numOptions = &H10& ' Additional text field to type folder path
:VBS: Set objShell = CreateObject( "Shell.Application" )
:VBS: If UCase( myStartLocation ) = "MY COMPUTER" Then
:VBS: Set objFolder = objShell.Namespace( MY_COMPUTER )
:VBS: Set objFolderItem = objFolder.Self
:VBS: strPath = objFolderItem.Path
:VBS: Else
:VBS: strPath = myStartLocation
:VBS: End If
:VBS: Set objFolder = objShell.BrowseForFolder( WINDOW_HANDLE, strPrompt, numOptions, strPath )
:VBS: If objFolder Is Nothing Then
:VBS: BrowseFolder = ""
:VBS: Exit Function
:VBS: End If
:VBS: Set objFolderItem = objFolder.Self
:VBS: objPath = objFolderItem.Path
:VBS:
:VBS: set oFS = WScript.CreateObject("Scripting.FileSystemObject")
:VBS: Set objShell2 = CreateObject("wscript.shell")
:VBS: Set fsHandle = oFS.OpenTextFile ("output1256.txt",8,True) 'external file
:VBS: fsHandle.Writeline objPath
:VBS: End Function
REM Must leave empty line after this line
and don't forget to leave empty line at the end of your batch file it's important.
2> before each Xcopy command in your batch add this command:The word
"Destination_Folder" can be any word you want but this will be the variable that will hold the destination folder name. ( leave it as it is for now )
3>now replace all destination folders in all xcopy commands like the red part here:XCopy "NewFolder\NewFolder_2\*.*" "UserBackup\NewFolder\NewFolder_2\*.*" /c /s /r /d /y /i > "UserBackup\Logfile_NewFolder_2.log"
with this:
And that's all, it should work find with you, and for each xcopy command you will get a pop-up GUI to ask for destination folder.
This Link has many usiful GUI interfaces that can be used with batch files too :
www.robvanderwoude.com