Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Batch File Random Number Copy


  • Please log in to reply
1 reply to this topic

#1 Gotcha_Hotshot22

Gotcha_Hotshot22

  • Members
  • 77 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:11:45 PM

Posted 24 July 2014 - 05:29 PM

Alright, guys. I've encountered another problem with my batch file. Hopefully you guys can help, you seem smart enough and you did solve my last problem.

 

I need to generate a random number using the %random% variable, yes I do realise it's not actually random and can be generated again if two cmd's run the random variable at the same time, and then record that number along with another variable labeled "Field1" AND THEN I also need to record that same exact number to a text document with the "Field1" and date variables. Here's my script so far...

set adminpass=xxwm24NBKW6fs2J6SNPA116j374Xo155D8992vwc742F236LGIP250nvLGIP340nv119786738M4st3rGl1tch3r
set pin=1996
@echo off
color 9F
Title Borderline Tech Record Systems by Daniel Blake
:LogIn
cls
Echo Borderline Tech Record Systems by Daniel Blake
Echo.
set /p Username=Username: 
Echo.
Set /p Password=Password: 
Echo.
if %Password%==LGIP250nv goto :MainMenu
if %Password%==exit exit
Echo.
Echo Incorrect Entry, Please Try Again...
Echo.
pause
Goto :LogIn
:MainMenu
Echo %Username%     %date% >>F:\BorderlineTech\Root\Logs\UserEntry\Logins.txt
cls
Echo _______________          Welcome, %Username%!
Echo ^| Receipt    ^|1^|
Echo ^| Records   ^|2^|           The Current Time Is
Echo ^| Discounts ^|3^|       %Time%  %Date%
Echo ^| Log Out   ^|4^|
Echo ---------------
Echo.
Set /p MainAction=Selection: 
if %MainAction%==1 goto :Receipt
if %MainAction%==2 goto :Records
if %MainAction%==3 goto :Discounts
if %MainAction%==4 goto :LogIn
exit
:Receipt
cls
Echo Please enter the following fields...
Echo.
Echo CLIENT INFORMATION
Echo.
Set /p Field1=Client Name: 
Set /p Field2=Client Phone Number: 
Set /p Field3=Client Address:
Echo %Field2%     %Field3%     %Date% >>F:\BorderlineTech\ContactInfo\"%Field1%".txt
Echo.
ECHO PRODUCT DESCRIPTION
Echo.
set /p Field5=Make: 
set /p Field6=Model: 
Set /p Field7=S/N: 
Echo.
ECHO ADDITIONAL NOTES
Echo.
Set /p Line1=Line 1: 
Set /p Line2=Line 2: 
Set /p Line3=Line 3: 
Set /p Line4=Line 4: 
Set /p Line5=Line 5: 
Set /p Line6=Line 6: 
ECHO.
ECHO EXTRA DETAILS
ECHO.
Set /p Price=Tender Due: 
Set /p Service=Service: 
Echo.
Echo %Date%
Set /p EPUD=Pickup Date: 
Echo.
set random1=%random%
Echo Client Name: %Field1% >>F:\BorderlineTech\Receipts\"%Field1% %random1%".txt
Echo Phone Number: %Field2% >>F:\BorderlineTech\Receipts\"%Field1% %random1%".txt
Echo Address: %Field3% >>F:\BorderlineTech\Receipts\"%Field1% %random1%".txt
Echo Date: %Date% >>F:\BorderlineTech\Receipts\"%Field1% %random1%".txt
Echo. >>F:\BorderlineTech\Receipts\"%Field1% %random1%".txt
Echo Make: %Field5% >>F:\BorderlineTech\Receipts\"%Field1% %random1%".txt
Echo Model: %Field6% >>F:\BorderlineTech\Receipts\"%Field1% %random1%".txt
Echo S/N: %Field7% >>F:\BorderlineTech\Receipts\"%Field1% %random1%".txt
Echo. >>F:\BorderlineTech\Receipts\"%Field1% %random1%".txt
Echo Additional Notes: >>F:\BorderlineTech\Receipts\"%Field1% %random1%".txt
Echo %Line1% >>F:\BorderlineTech\Receipts\"%Field1% %random1%".txt
Echo %Line2% >>F:\BorderlineTech\Receipts\"%Field1% %random1%".txt
Echo %Line3% >>F:\BorderlineTech\Receipts\"%Field1% %random1%".txt
Echo %LIne4% >>F:\BorderlineTech\Receipts\"%Field1% %random1%".txt
Echo %Line5% >>F:\BorderlineTech\Receipts\"%Field1% %random1%".txt
Echo %Line6% >>F:\BorderlineTech\Receipts\"%Field1% %random1%".txt
Echo. >>F:\BorderlineTech\Receipts\"%Field1% %random1%".txt
Echo Service: %Service% >>F:\BorderlineTech\Receipts\"%Field1% %random1%".txt
Echo %Price%     %Service%            %Field1% >>F:\BorderlineTech\Financial\Overall.txt
Echo Tender Due: %Price% >>F:\BorderlineTech\Receipts\"%Field1% %random1%".txt
Echo *Estimated Pickup Date: %EPUD% >>F:\BorderlineTech\Receipts\"%Field1% %random1%".txt
Echo. >>F:\BorderlineTech\Receipts\"%Field1% %random1%".txt
Echo Client Signature:____________________ Date:__/__/____ >>F:\BorderlineTech\Receipts\"%Field1% %random1%".txt
Echo. >>F:\BorderlineTech\Receipts\"%Field1% %random1%".txt
REM ABOVE FIELDS ARE USED FOR CREATING RECEIPTS
REM +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
REM +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
REM BELOW FIELDS ARE USED FOR OFFICIAL RECORDINGS
Echo Client Name: %Field1% >>F:\BorderlineTech\Receipts\Records\"%Field1%".txt
Echo Phone Number: %Field2% >>F:\BorderlineTech\Receipts\Records\"%Field1%".txt
Echo Address: %Field3% >>F:\BorderlineTech\Receipts\Records\"%Field1%".txt
Echo Date: %Date% >>F:\BorderlineTech\Receipts\Records\"%Field1%".txt
Echo. >>F:\BorderlineTech\Receipts\Records\"%Field1%".txt
Echo Make: %Field5% >>F:\BorderlineTech\Receipts\Records\"%Field1%".txt
Echo Model: %Field6% >>F:\BorderlineTech\Receipts\Records\"%Field1%".txt
Echo S/N: %Field7% >>F:\BorderlineTech\Receipts\Records\"%Field1%".txt
Echo. >>F:\BorderlineTech\Receipts\Records\"%Field1%".txt
Echo Additional Notes: >>F:\BorderlineTech\Receipts\Records\"%Field1%".txt
Echo %Line1% >>F:\BorderlineTech\Receipts\Records\"%Field1%".txt
Echo %Line2% >>F:\BorderlineTech\Receipts\Records\"%Field1%".txt
Echo %Line3% >>F:\BorderlineTech\Receipts\Records\"%Field1%".txt
Echo %LIne4% >>F:\BorderlineTech\Receipts\Records\"%Field1%".txt
Echo %Line5% >>F:\BorderlineTech\Receipts\Records\"%Field1%".txt
Echo %Line6% >>F:\BorderlineTech\Receipts\Records\"%Field1%".txt
Echo. >>F:\BorderlineTech\Receipts\Records\"%Field1%".txt
Echo Service: %Service% >>F:\BorderlineTech\Receipts\Records\"%Field1%".txt
Echo Tender Due: %Price% >>F:\BorderlineTech\Receipts\Records\"%Field1%".txt
Echo *Estimated Pickup Date: %EPUD% >>F:\BorderlineTech\Receipts\Records\"%Field1%".txt
Echo. >>F:\BorderlineTech\Receipts\Records\"%Field1%".txt
Echo Client Signature:____________________ Date:__/__/____ >>F:\BorderlineTech\Receipts\Records\"%Field1%".txt
Echo. >>F:\BorderlineTech\Receipts\Records\"%Field1%".txt
Echo. >>F:\BorderlineTech\Receipts\"%Field1% %random%".txt
Echo ++++++++++++++++++++++++++++++++++++++++++++++++ >>F:\BorderlineTech\Receipts\Records\"%Field1%".txt
Echo ++++++++++++++++++++++++++++++++++++++++++++++++ >>F:\BorderlineTech\Receipts\Records\"%Field1%".txt
Echo. >>F:\BorderlineTech\Receipts\"%Field1% %random%".txt
Cls
Echo Records Updated.
Echo.
Echo Now printing results.
Echo Please ensure a proper connection has been made.
Echo.
Pause
Notepad /p F:\BorderlineTech\Receipts\Records\%Field1%.txt
Echo. >>F:\BorderlineTech\Receipts\"%Field1% %random%".txt
Echo ++++++++++++++++++++++++++++++++++++++++++++++++ >>F:\BorderlineTech\Receipts\"%Field1% %random%".txt
Echo ++++++++++++++++++++++++++++++++++++++++++++++++ >>F:\BorderlineTech\Receipts\"%Field1% %random%".txt
Echo. >>F:\BorderlineTech\Receipts\"%Field1% %random%".txt
cls
Echo Print Complete!
Echo.
Pause
goto :MainMenu
:Records
cls
Echo _________________________
Echo ^| Receipts             ^|1^|
Echo ^| Financial           ^|2^|
Echo ^| Contact Information ^|3^|
Echo ^| Main Menu           ^|4^|
Echo ^| Clear Records       ^|5^|
Echo -------------------------
Echo.
Set /p RecordsAction=Selection: 
if %RecordsAction%==1 goto :RecordsReceipts
if %RecordsAction%==2 goto :RecordsFinancial
if %RecordsAction%==3 goto :RecordsContactInformation
if %RecordsAction%==4 goto :MainMenu
if %RecordsAction%==5 goto :RecordsWarning
Echo Invalid Choice, Try Again...
goto :Records
:RecordsReceipts
Set /p ReceiptName=Client Name: 
ECHO.
TYPE F:\BorderlineTech\Receipts\"%ReceiptName%".txt
Echo.
Pause
Goto :Records
:RecordsFinancial
cls
TYPE F:\BorderlineTech\Financial\Overall.txt
pause
goto :Records
:RecordsContactInformation
cls
Set /p Field1=Client Name: 
cls
Echo %Field1%
Echo.
TYPE F:\BorderlineTech\ContactInfo\"%Field1%".txt
Echo.
Pause
goto :Records
:Discounts
cls
Echo _________________
Echo ^| Available   ^|1^|
Echo ^| Refund      ^|2^|
Echo ^| History     ^|3^|
Echo ^| Main Menu   ^|4^|
Echo -----------------
Echo.
Set /p DiscountsAction=Selection:  
if %DiscountsAction%==1 goto :DiscountsAvailable
if %DiscountsAction%==2 goto :DiscountsRefund
if %DiscountsAction%==3 goto :DiscountsHistory
if %DiscountsAction%==4 goto :MainMenu
Echo INvalid Choice, Try Again...
goto :Discounts
:DiscountsAvailable
cls
Echo Available Discounts:
TYPE F:\BorderlineTech\Discounts\Available.txt
Echo.
Echo.
Pause
goto :Discounts
:DiscountsRefund
cls
Set /p Field1=Client Name: 
Set /p Field2=Amount: 
Set /p Field3=Reason: 
Echo %Field2%     %Field1%     %Field3% >>F:\BorderlineTech\Discounts\Refunds.txt
Echo -%Field2%     REFUND     %Field1% >>F:\BorderlineTech\Financial\Overall.txt
Echo %Field1%     %Field2%     %Field3% >>F:\BorderlineTech\Discounts\History.txt
Echo REFUND >>F:\BorderlineTech\Receipts\"%Field1% %random%".txt
Echo %Field1%     %Date% >>F:\BorderlineTech\Receipts\"%Field1% %random%".txt
Echo Refund Amount: %Field2% >>F:\BorderlineTech\Receipts\"%Field1% %random%".txt
Echo Reason: %Field3% >>F:\BorderlineTech\Receipts\"%Field1% %random%".txt
Echo. >>F:\BorderlineTech\Receipts\"%Field1% %random%".txt
Echo Records have been updated.
Echo.
Pause
goto :Discounts
:DiscountsHistory
cls
TYPE F:\BorderlineTech\Discounts\History.txt
Echo.
Pause
goto :Discounts
:RecordsWarning
cls
color CF
ping localhost -n 1 >null
color 0f
ping localhost -n 1 >null
color CF
ping localhost -n 1 >null
color 0f
ping localhost -n 1 >null
color CF
ping localhost -n 1 >null
color 0f
ping localhost -n 1 >null
color CF
ping localhost -n 1 >null
color 0f
ping localhost -n 1 >null
color CF
ping localhost -n 1 >null
color 0f
ping localhost -n 1 >null
color CF
ping localhost -n 1 >null
color 0f
ping localhost -n 1 >null
color CF
ping localhost -n 1 >null
color 0f
ping localhost -n 1 >null
color CF
ping localhost -n 1 >null
color 0f
ping localhost -n 1 >null
color CF
ping localhost -n 1 >null
color 0f
ping localhost -n 1 >null
color CF
ping localhost -n 1 >null
color 0f
ping localhost -n 1 >null
color CF
ping localhost -n 1 >null
color 0f
ping localhost -n 1 >null
color CF
ping localhost -n 1 >null
color 0f
ping localhost -n 1 >null
color 9F
ECHO WARNING! YOU ARE ABOUT TO CLEAR ALL FINANCIAL RECORDS!
ECHO.
ECHO This includes receipts, discounts, and refunds!
Echo.
Echo _______________
Echo ^| Yes     ^|1^|
Echo ^| No      ^|2^|
Echo ---------------
Echo.
set /p WARNINGACTION=Are You Sure You Wish To Clear All Records? 
if %WARNINGACTION%==1 Goto :WARNINGACTIONCONFIRM
if %WARNINGACTION%==2 cls
Echo !Record Deletion Cancelled!
Pause
Goto :MainMenu
:WARNINGACTIONCONFIRM
cls
Echo To Confirm Your Choice, Please Enter The Administrative Password Below
Echo.
Set /p DelConf=Administrative Password: 
if %AdminPass%==%DelConf% goto :CONFIRMPIN
CLS
goto RecordsWarning
:CONFIRMPIN
cls
set /p pincheck=PIN #: 
if %pin%==%pincheck% goto :CONFIRMEDDELETION
GOTO :RecordsWarning
:CONFIRMEDDELETION
cls
Echo Now erasing all records...
Echo.
Pause
del F:\Receipts\*.txt
del F:\Financial\*.txt
cls
Echo Deletion Finished.
Echo.
Pause
Goto :MainMenu

The point of my question, in case I was unclear, is to copy this random number and shove it into a text document with the clients name and the date so I can keep track of which client has which number and on what date it was assigned. 

 

Please and thanks in advance,

Daniel


Edited by Chris Cosgrove, 25 July 2014 - 04:42 PM.
Moved to 'Programming'

Thanks,

Daniel


BC AdBot (Login to Remove)

 


#2 Gotcha_Hotshot22

Gotcha_Hotshot22
  • Topic Starter

  • Members
  • 77 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:11:45 PM

Posted 02 August 2014 - 09:40 PM

I figured it out...

 

I set a %random% variable as a variable

ie set 123=%random%

then i use the 123 variable to save the files with that random number.


Thanks,

Daniel





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users