Solved

Batch File with Hide Password

Posted on 2011-09-12
19
1,832 Views
Last Modified: 2012-05-12
Hello,

i have batch file with emddebed user name , now i want to create for each user a dedicated user name and password, so i want batch file that ask for user name and password should not be clear , check below my batch


get.bat

echo del c:\ftp\get.out
echo cd c:\ftp
ftp -v -n < c:\ftp\get.ftp > c:\ftp\get.out
exit

Open in new window





get.ftp
o 10.10.100.123
USER user1
PASSWORD 
ascii
lcd C:\FTP
cd \user\users
get text text.txt
delete text
delete text_temp
quit

Open in new window

0
Comment
Question by:palddl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 3
  • +6
19 Comments
 
LVL 13

Expert Comment

by:stergium
ID: 36527570
hello.
i've never heard or seen a non plaintext batch file. i dont think that its possible
0
 
LVL 1

Author Comment

by:palddl
ID: 36527578
ok give also plaintext method
0
 
LVL 17

Expert Comment

by:Shanmuga Sundaram
ID: 36527606
check whether this helps

the other way is to convert the batch file to exe using a tool that will convert batch file to exe file. there are variety of tools to do this. next password protect the converted exe file. there are tools that will password protect exe file. Some of the googled results here
0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 70

Expert Comment

by:Qlemo
ID: 36527690
Do you ask for a script which does ask the user for user name and/or password on each execution? Or do you want to hardwire both, but it being unique?
0
 
LVL 43

Accepted Solution

by:
Steve Knight earned 167 total points
ID: 36528030
For the password parts of that I have such a script on my site here:

http://scripts.dragon-it.co.uk/links/batch-password2

and another here is useful for hiding a hard coded password in a batch file so it isn't visible unless you know how:

http://scripts.dragon-it.co.uk/links/batch-password1

You can use that along with a dynamically created ftp script, example here:

http://scripts.dragon-it.co.uk/links/batch-ftp-scripting

Would suggest if you need to prompt for username and password (or maybe the username they logon to windows is correct one?) then something like this:

@echo off
call :getusername
if "%user%"=="NONE" (
  echo No username entered
  exit /b
)

call :getpassword
if "%pwd%"=="NONE" (
  echo No password entered
  exit /b
)

echo Username is %user% and password is %pwd%

(echo open 10.10.100.123
echo user %user%
echo %pwd%
echo ascii
echo lcd c:\ftp
echo cd \users\users
echo get text text.txt
echo delete text
echo delete text_temp
echo quit
) | ftp -n -i
pause
exit /b

:getpassword
REM Add getpassword routine of your choice in from first link above. This is for XP onwards.  2000 version in link.
set InputTitle=Enter Password:
set InputResult=%Temp%\Input.tmp
reg add "HKCU\Console\%InputTitle%" /v "CursorSize" /t REG_DWORD /d "100" /f >NUL 2>&1
reg add "HKCU\Console\%InputTitle%" /v "FaceName" /t REG_SZ /d "Terminal" /f >NUL 2>&1
reg add "HKCU\Console\%InputTitle%" /v "FontFamily" /t REG_DWORD /d "48" /f >NUL 2>&1
reg add "HKCU\Console\%InputTitle%" /v "FontSize" /t REG_DWORD /d "1048588" /f >NUL 2>&1
reg add "HKCU\Console\%InputTitle%" /v "FontWeight" /t REG_DWORD /d "400" /f >NUL 2>&1
reg add "HKCU\Console\%InputTitle%" /v "ScreenBufferSize" /t REG_DWORD /d "196638" /f >NUL 2>&1
reg add "HKCU\Console\%InputTitle%" /v "ScreenColors" /t REG_DWORD /d "136" /f >NUL 2>&1
reg add "HKCU\Console\%InputTitle%" /v "WindowPosition" /t REG_DWORD /d "24904160" /f >NUL 2>&1
reg add "HKCU\Console\%InputTitle%" /v "WindowSize" /t REG_DWORD /d "196638" /f >NUL 2>&1
set input=NONE
start "%InputTitle%" /wait "%ComSpec%" /v:on /c "echo.&set /p Input= &echo !Input!>"%InputResult%""
for /f "delims=" %%a in ('type "%InputResult%"') do set pwd=%%a
del "%InputResult%"
reg delete "HKCU\Console\%InputTitle%" /f >NUL 2>&1
exit /b

:getusername
set InputTitle=Enter Username:
set InputResult=%Temp%\Input.tmp
reg add "HKCU\Console\%InputTitle%" /v "ScreenBufferSize" /t REG_DWORD /d "196638" /f >NUL 2>&1
reg add "HKCU\Console\%InputTitle%" /v "ScreenColors" /t REG_DWORD /d "128" /f >NUL 2>&1
reg add "HKCU\Console\%InputTitle%" /v "WindowPosition" /t REG_DWORD /d "24904160" /f >NUL 2>&1
reg add "HKCU\Console\%InputTitle%" /v "WindowSize" /t REG_DWORD /d "196638" /f >NUL 2>&1
set input=NONE
start "%InputTitle%" /wait "%ComSpec%" /v:on /c "echo.&set /p Input= &echo !Input!>"%InputResult%""
for /f "delims=" %%a in ('type "%InputResult%"') do set user=%%a
del "%InputResult%"
reg delete "HKCU\Console\%InputTitle%" /f >NUL 2>&1

exit /b

Let us know if you need help customising!



Steve


0
 
LVL 16

Assisted Solution

by:AlexPace
AlexPace earned 166 total points
ID: 36529993
Below is a way to do it in a single Robo-FTP script.  In this one, the username and password are only stored in RAM not written to the disk.  This code also detects and reports errors.... so, for example, it won't delete the source file if the download fails.
SET activity = "setting local working folder."
WORKINGDIR "c:\FTP"
IFERROR GOTO fatal_error
PROMPT username "Please enter your username: " "Log in to FTP site"
PROMPT password "Please enter your password: " "Password?" /password
SET activity = "connecting to user folder on FTP site."
FTPLOGON "10.10.100.123" /user=username /pw=password
FTPCD "/sub/folder/"
IFERROR GOTO fatal_error
SET activity = "downloading file."
RCVFILE "text" /as "text.txt" /type=ASCII
IFERROR GOTO fatal_error
FTPDELETE "text"
FTPDELETE "text_temp"
GOTO done
:fatal_error
SET warning = "FTP operation failed while " + activity
MESSAGEBOX warning
:done
FTPLOGOFF
EXIT

Open in new window

0
 
LVL 16

Expert Comment

by:AlexPace
ID: 36530058
Oh, I forgot to mention that when the user types the the password it shows **** instead of the clear text.

Use the -s command line switch to launch Robo-FTP so that it automatically runs a script.  So for example if you saved the above script in the Robo-FTP install folder in a file named prompt.s the command line would look like this:

  C:\Program Files\Robo-FTP 3.7\Robo-FTP.exe" -s"prompt.s"
0
 
LVL 10

Assisted Solution

by:ReneGe
ReneGe earned 167 total points
ID: 36546253
By using SFK:
http://stahlworks.com/dev/index.php?tool=echo

All you have to do, is play with the colors so your happy!!

Cheers,
Rene


@ECHO OFF
color C0
ECHO Please enter password
sfk color red
SET /P PASSWORD=
cls
color C0
echo the password is: %PASSWORD%
PAUSE

Open in new window

0
 
LVL 16

Expert Comment

by:AlexPace
ID: 36548315
That color thing is cool.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 36548378
"color" is built in command btw, you just can't set both foreground / background to the same colour.  SFK looks like it could be useful for a few things mind, especially less sneaky way than my registry for setting same colour -- though suggested that so it didn't need any external tools.

Still not quite sure WHAT is wanted here mind!

Steve
0
 
LVL 10

Expert Comment

by:ReneGe
ID: 36548546
Thank Alex !
Steve :)
0
 
LVL 59

Expert Comment

by:LeeTutor
ID: 36949311
I've requested that this question be deleted for the following reason:

This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
 
LVL 10

Expert Comment

by:ReneGe
ID: 36949303
I actually provided a working solution, and others seems to have put lots of time to help. May I suggest splitting points?
0
 
LVL 10

Expert Comment

by:ReneGe
ID: 36949312
I actually provided a working solution, and others seems to have put lots of time to help. May I suggest splitting points?
0
 
LVL 10

Expert Comment

by:ReneGe
ID: 36949319
I double post by mistake. Sorry for that!
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 36949542
Agreed Rene.

3 way split as three working solutions there we worked on:

Windows native solution: Dragon-it http:#36528030
Windows native solution + tool for setting colour:  ReneGe http:#36546253
Third party tool - RoboFTP:  AlexPace http:#36529993
0
 

Expert Comment

by:South Mod
ID: 36998364
All,
 
Following an 'Objection' by ReneGe (at http://www.experts-exchange.com/Q_27390766.html) to the intended closure of this question, it has been reviewed by at least one Moderator and is being closed as recommended by the Expert.
 
At this point I am going to re-start the auto-close procedure.
 
Thank you,
 
SouthMod
Community Support Moderator
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article summaries thoughts and ideas from two years of sustained use. It provides good reasoning to make the jump to Windows 10.
Determining the an SCCM package name from the Package ID
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question