Writing secure batch files - batch-file

I have a simple batch file:
#echo off
set username=user
set password=pass
::do some things with the username and password
the user could just call the batch file from cmd, and type set after my batch file has run it's course and see the username and password.
Is there any way to fix this?
(excluding bat to exe converters)

Prompt for password then save it
This script here to use the password associated with a batch file from a hidden stream attached to the file, prompt for the password if not present and save it. If you know how to work out what is going on in the batch you could do the same and get the password to work with, but to a casual observer it is not at all obvious how it works.
Password entry obscured from batch file
Script to prompt for and enter password in hidden manner.
Password hidden using ADS
Script to store password in an extra data stream with the batch file that you can't see but is there and can be read by the batch file itself.

Related

Insert password with a batch file

I want to list all of my bitwarden items in a batch file. The cli command is bw list items but after this the command line asks me about the master password: ? Master password: [hidden]
So my question is, how do i write the password in a batch file, so that i don't have to rewrite my password over and over again.
And before someone mentions the security issues, i will not put the password in plain text in the batch file.
My batch file:
#echo off
bw list items
But as already mentioned after executing this batch file, the command line asks me after the master password, and i want a batch command that writes the password for me, so that only the output will be shown in the console.

Using batch file to control dos user input

I'm using a program called lewice that runs in a dos window.
When you run the program it requires 'user input' to give a file name for the input files.
Is there anyway I can get a batch file to send the commands to the dos window so the batch file can by default use file name x?
Thanks
Not sure if that's what you want but maybe lewice can use inputs parameters, you just have to create a shortcut and add options:
https://superuser.com/questions/29569/how-to-add-command-line-options-to-shortcut
It might get trickier if the path to the file has spaces.

auto schedule upload using batch file and command prompt

I am trying to use a cmd file to run a batch file that uploads a file of mine to a directory of my website. The batch file looks like this:
open ip address
username
password
option confirm off
cd \public_html\wp-content\uploads\2014\07
put "C:\Users\a\Documents\pdf\Contact Info.pdf"
quit
The cmd file looks like this:
ftp -s:c:\Users\a\Documents\upload.bat
When I run the cmd file I get output in command prompt that says that my username and password are ok and then tells me that option confirm off is an invalid command and that the cd filepath is a prohibited file name. It then says my file is uploaded but I can't find where the file is put. Is there a reason why this is happening? Is it possible to upload the file to that directory?
Use winscp. Download: http://winscp.net/eng/download.php
option confirm off is a valid WinSCP command, see http://winscp.net/eng/docs/scriptcommand_option
Example: Uploading a single file with WinSCP
http://winscp.net/eng/docs/script_upload_single_file
Step 1
create file: winscp-upload-script.txt
option batch abort
option confirm off
open sftp://username:password#example.com/
put "C:\Users\a\Documents\pdf\Contact Info.pdf" \public_html\wp-content\uploads\2014\07
exit
Step 2
create file: do-upload.bat
"C:\Program Files (x86)\WinSCP\winscp.com" /script=winscp-upload-script.txt
Step 3
Go scheduler, create new task, like described here (http://www.sevenforums.com/tutorials/12444-task-scheduler-create-new-task.html) and use do-upload.bat and configure event timing.
-Done-

Is it possible to create a batch file that will call another batch file at some point and also supply it with a sequence of inputs

I have a batch file (lets say "test.bat"). Now when we run this test.bat it asks for user inputs during it's execution, For ex. user credentials and then shows a menu. The user can choose an option from the menu by entering a value after which the script will ask him for a lot more product specific details.
Question:
I need to call this test.bat inside another batch file and whenever test.bat requires user inputs my batch script should be able to provide a some inputs (a known sequence of menu options and inputs).
Is there anyway I can achieve this?
To call another batch file, I refer this link:
Several ways to call a windows batch file from another one or from prompt. Which one in which case?
To get user inputs:
Echo off
set /p x=path name:
echo path is %x%
pause

I want to make a simple batch file

that opens Minecraft.exe, and logs in when clicked. Is this possible?
Hmm, Is this what you want; it should work:
#echo off
"%cd%\minecraft.exe" username password serverip
edit the username, password and ip to your liking.
A Better Solution in my opinion:
Just figured it out, the batch file doesn't work, however; when set up as a shortcut it does! So create a new shortcut and for the path use this:
Format:
"<FilePath>" <username> <password> <server>
Example:
"C:\Program Files\Minecraft\Minecraft.exe" bobjones passchuck 123.123.123.123
Hope that works out for you, alot simpler then a bath file IMO.
also if you don't include IP, it just goes and logins in to minecraft. Stopping at the title screen.
http://www.minecraftwiki.net/wiki/Tutorials/Setting_up_a_server#Start_the_Minecraft_Server_.28.jar_version.29
To start the jar version of Minecraft on Windows, create a new file in Notepad, and paste in
java -Xms512M -Xmx1G -jar minecraft_server.jar
Save the file as startserver.bat, and place the file in the same folder as minecraft_server.jar. The .bat extension saves the file as a batch file.

Resources