I'm attempting to write a .bat file for a simple password reset prompt for users, and the last thing I need to do is to quit, which is not being executed for some reason. The process halts after the connection is made, the quit command is ignored, and has to be typed in manually before the process resumes.
Here is what I have:
#echo off
Echo Password Reset Process
Pause
Echo Enter your user ID when asked
Echo ---
Echo Change your password by using this format, including the slashes:
Echo 'oldpassword/newpassword/newpassword'
Echo ---
Echo You will not be able to see what you type
Echo So proceed carefully!
Echo ---
Echo Begin Your Password Reset Now?
Pause
FTP Server.domain.org
Quit
Pause
exit
Thank you!
Try this:
#echo off
Echo Password Reset Process
set /P "userID=Enter your user ID: "
Echo Enter your new password by using this format, including the slashes:
set /P "password=oldpassword/newpassword/newpassword: "
Echo Begin Your Password Reset Now?
Pause
(
echo %userID%
echo %password%
echo Quit
) > passfile.txt
FTP -s:passfile.txt Server.domain.org
del passfile.txt
exit
Batch files only contain commands for the Windows shell cmd.exe. If you want to input commands into some other program, you have to use its means to do so.
With FTP, you can use the -s:filename switch, see ftp -h. So you can create a file, say ftp-cmd.txt, with the necessary lines and end it with the line quit and then in your batch file call ftp -s:ftp-cmd.txt. That should do the trick.
Related
Ive done some research on this but with minimal luck. What I have is a batch file that installs several programs for me. One of the programs requires the creation of an .INI file. basically it adds a username and password to the program
#echo off
echo Enter a Username:
echo Enter a Password:
set /p boompanes=
pause
echo %boompanes%> Visual.ini
This creates the ini file with the one line of code but I need it in a certain spot on the file. see below
echo off
echo. >"C:\Users\Public\Desktop\Visual.ini
echo enter a Username:
echo enter a Password:
pause
The outcome of the file needs to be identical to the following:
[Visual Mfg]
Userid= *username*
Password= *password*
Database=VMFG
With just the username and password being modified.
With this code it creates the .ini file but its empty as expected.
From what i understand that you what the output you wrote there,
to do this you must know somethings:
first line you use >file.ini
second and n lines you will need to add value to file.ini using >> not only >
you will need to set another variable for the password then print everything,
#echo off
echo Enter a Username:
set /p user=
echo Enter a Password:
set /p pass=
pause
echo [Visual Mfg]> Visual.ini
echo Userid=*%user%*>> Visual.ini
echo password=*%pass%*>> Visual.ini
echo Database=VMFG>> Visual.ini
i hope that that what you really need.
I want a batch file that will launch a continuous loop of cmd with and echo message
I can do it without echo with this code
#echo off
:1
start
GOTO 1
but all I want is that the every opened cmd window should give an echo message like "hello".
Here This Might Do It For You. (Remove The Spaces Between The Codes)
#echo off
echo (Your Message Here)
start (batfilename).bat
(batfilename).bat
I have a simple batch file:
ECHO OFF
CLS
ECHO WELCOME
ECHO.
ECHO Launching your app...
What I would like is to return to a default CMD state where the user can type commands, I mean, this state: C:[path][path].....>
I want to give to the user the possibility to continue to type anything he wants after the echo "Launching your app..."
So visually it would give this:
WELCOME
Launching your app...
C:[path][path][path]> _
#echo off
rem check if started from own process (use our own parameter)
rem and if not, spawn a new cmd with correct parameters and
rem keep it open
if not "%~1"=="__startcmd__" (
"%comspec%" /k "%~f0" __startcmd__ %*
exit
)
rem eliminate custom parameter of parameter list
shift
rem your custom screen
cls
title "command window"
prompt $p$g
echo WELCOME
echo Launching your app ...
I'm trying to write a batch script that will do a RunAs for any given windows service (using explorer.exe to test) for any given user that can be input at time of running. What I currently have is this.
set /p Var1="Domain = "
set /p Var2="Username = "
set /p Var3="Service to open= "
RunAs /user:%Var1%\%Var2% "%Var3%" /seperate
On command line, this seems to work ok (with coded values instead of variables) but in a batch file it just seems to repeat itself, without opening what it's been specified (it doesn't even prompt for a password, so I can only presume its not even trying). Any idea why it's looping and what I can do to stop it?
Cheers
Hi #Gary Barnett i created something similar to this awhile back.
Here is an example;
#ECHO OFF
set /P Domainn=Enter Domain Name:
set /P Usern=Enter Username:
set userunas=runas /user:%domainn%\%usern% "
:optionmenu
CLS
ECHO 1 - Control.exe
ECHO 2 - MSinfo32.exe
ECHO 3 - Explorer.exe
ECHO q - Quit
ECHO.
set /P optionnum=Enter command number:
GOTO option%optionnum%
:option1
%userunas%control.exe
goto optionmenu
:option2
%userunas% %commonprogramfiles%\micros~1\MSInfo\msinfo32.exe"
goto optionmenu
:option3
%userunas%explorer.exe
goto optionmenu
:optionq
EXIT
Note: You must run the batch file as Administrator (right-click -> Run as Administrator) or it wont work.
/seperate is not a switch from RUNAS. So,
RUNAS /USER:"%Var1%\%Var2%" "%Var3%"
should go fine. If /seperate is a parameter to %Var3% program, use:
RUNAS /USER:"%Var1%\%Var2%" "%Var3% /seperate"
You may also add PAUSE at end of script so you can check results, while "debugging".
i have been formulating and doing a batch program that enables the user to enter his password,just like that, and i seem to arrive at nothingness, can anybody show me how to create a batch program that enables the user to enter his password?and run a specific program when log in is successfull, by the way, i am using windows xp sp2
set /p "PASSWORD=Enter your password: "
I use the quotes so I can show the trailing space in the batch file. Otherwise it's not necessary; any trailing spaces will be echoed into the output.
set /? shows a number of ways of manipulating variables in cmd.exe
Here's something that works for me...
#echo off
:loginPASS
set /p password=Password:
if %password% == qwerty goto loginsuccessful
if %password% == %password% goto loginfailed
:loginfailed
echo Login failed, password was incorrect!
pause
cls
goto login
:loginsuccessful
echo LOGIN SUCCESSFUL!
cd <location of file (dont include its name) example: C: /Users/YOURUSERNAME/desktop>
<type in file name here>
if you want to make a username input too, then delete the loginPASS section make a new one called loginUSER and type in this:
:loginUSER
set /p username=Username
cls
if %username% == Admin goto AdminLogin
if %username% == Bob goto BobLogin
if %username% == %username% goto NoUsername
make a new section called NoUsername
:NoUsername
echo User not found, check your username again.
pause
cls
goto loginUSER
this will tell the user if they entered the wrong username.
after that make a new section for 1 of the users and name appropriately.
in this case you will name it AdminLogin.
After that repeat loginPASS and make the password for the user.
The whole code should look something like this:
#echo off
:AdminLogin
set /p password=Password:
if %password% == 158468 goto loginsuccessful
if %password% == %password% goto loginfailed
:loginfailedADMIN
echo Login failed, password was incorrect!
pause
cls
goto AdminLogin
:loginsuccessfulADMIN
echo LOGIN SUCCESSFUL!
cd <location of file (dont include its name) example: C: /Users/YOURUSERNAME/desktop>
<type in file name here>
pause
exit
You will want to make seperate login sections for each user.
Hope this helps!
P.S There might be other ways but this is what i use.