The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Special Forums > Windows & DOS: Issues & Discussions
.
google unix.com



Windows & DOS: Issues & Discussions All Windows and DOS questions should go here as well. Discuss UNIX to Windows (Desktop or Server) here!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
batch file using sed command in msdos rita1985 UNIX for Dummies Questions & Answers 1 01-15-2008 02:19 AM
su command in batch mode Rajesh Gohad Shell Programming and Scripting 3 01-26-2007 12:54 AM
batch command in a shell script ivvo UNIX for Dummies Questions & Answers 7 07-20-2005 09:06 AM
Using Batch command jhansrod Shell Programming and Scripting 5 06-10-2005 12:50 PM
trying to read batch process but need some command help etravels Shell Programming and Scripting 1 11-19-2003 10:48 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-04-2008
Killalot57 Killalot57 is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 8
Add password to batch command?

hello, I'd like a batch command to prompt me for a password when I try to use it, and only work if I type in the correct password, can this be done?
thanks in advance.
  #2 (permalink)  
Old 11-04-2008
Lakris Lakris is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 242
Hi, You can use:
read -s -p "password: " pass;echo
to have the entered password stored in the variable pass.

A few hints:
Anyone who can edit the script can also change it to for example echo $pass, a security risk...
create an encrypted passwordfile, for example with
echo lakris $(echo secretpassword | md5sum ) >> .mypasswd
Make sure the passwd file is only readable by the owner of the script
Test the entered and encrypted $pass against what's in the file for a given user.

It would be a very rudimentary password handling routine but this should get You started!

/Lakris
  #3 (permalink)  
Old 11-05-2008
Killalot57 Killalot57 is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 8
yikes, your way over my head buddy!?!? perhaps you could give an example. how would I alter the following batch command to make it prompt me for a password to execute it.

@echo off
color 70
if exist "c:\new folder\file.txt" del "c:\new folder\file.txt"
ECHO hi everybody
ECHO.
PAUSE
  #4 (permalink)  
Old 12-20-2008
ilan ilan is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 101
Quote:
Originally Posted by Killalot57 View Post
yikes, your way over my head buddy!?!? perhaps you could give an example. how would I alter the following batch command to make it prompt me for a password to execute it.

@echo off
color 70
if exist "c:\new folder\file.txt" del "c:\new folder\file.txt"
ECHO hi everybody
ECHO.
PAUSE
Hello Killalot57,

I guess youa re looking for this kind of solution...

@echo off
set /p password="please enter the password:"
echo %password%

pause
color 70
if exist "c:\new folder\file.txt" del "c:\new folder\file.txt"
ECHO hi everybody
ECHO.
PAUSE


you can make the script to ask for any variable with the above..! may be you can take a look at runas command and integrate it with If command to authenticate; you should have the permissions on the password file as appropriate.

--ilan
  #5 (permalink)  
Old 11-05-2008
Lakris Lakris is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 242
Sorry, I didnt realise this was a Windows forum, how silly of me!

I wouldn't be able to do it in cmd.exe. Maybe someone else. But I can recommend ss64.com, it has a very good description of a lot of cmd.exe commands and options.

/Lakris
  #6 (permalink)  
Old 11-05-2008
Killalot57 Killalot57 is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 8
thanks anyway, I'll take a look at that website.
  #7 (permalink)  
Old 11-05-2008
Killalot57 Killalot57 is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 8
meanwhile I'd still greatly appreciate any help from anyone
Closed Thread

Bookmarks

Tags
batch command password xp, shell script, shell scripting, unix scripting, unix scripting basics

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:03 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0