|
Answer» Can anyone tell me why this BATCH file's window flashes on and off quickly when it is run, it is supposed to write a password to the desktop but for some reason it has stopped doing so. any help is much appreciated
@echo off set sDate=%DATE:~10,4%%DATE:~4,2%%DATE:~7,2% set aux=%sDate%
set sDate=
:LOOP if "%aux%"=="0" goto END set last_digit=%aux:~-1% set sDate=%sDate%%last_digit% set /A aux=%aux%/10 goto LOOP
:END set /A div=2260 set /A integer=%sDate%/%div% set /A remainder=(%sDate% - %div%*%integer%)%%div% set /A fracc=10000*%remainder%/%div% if %fracc% lss 999 set fracc=0%fracc%
setsol=%fracc% echo %fracc% echo password = %sol% >"C:\Documents and Settings\genie\Desktop\Password.txt" pause
Thanks Geniewell HERES what you could do, take out @echo off, open command prompt then run your batch from there:
c:\> "C:\path\of\file.bat"
and you should get all your syntax etc. it should tell why it stopped. i.e. Sysntax is incorrect.
the lines above that should be the errors that caused itThanks BFB, I did as you suggested and it came up with these errors at the end. I'm a newbie here and am not sure what's GOING on. It appears to be date related as some days it will run fine but I'm clueless as to how to fix it. again your help is much appreciated. The program is supposed to take the present date (year,month, day) then reverse the numbers and divide by 2260. The four digits after the decimal point of the answer is what should be displayed on the screen if everything runs correctly
Genie ........... C:\> set /A integer=02709002/2260 invalid number. Numeric constants are either decimal (17), hexadecimal (0x11), or octal (021)
C:\>set /A remainder=02709002 - 2260*)%div invalid number. Numeric constants are either decimal (17), hexadecimal (0x11), or octal (021)
C:\>set /A frac=1000*/2260 Missing operand. 999 was unexpected at this time.
C:\> if 1ss 999 set fracc=0well for the first two,
CODE: [Select]invalid number. Numeric constants are either decimal (17), hexadecimal (0x11), or octal (021) you cannot have a 0 in front of your value, to shorten it, youll take your original code:
Code: [Select] set /A integer=%sDate%/%div% change it to:
Code: [Select] set /A integer=%sDate:~1,20%/%div% starts after the first char(in this case its a 0) and stops after 20th char(set as you like, but 20 is so it will always show the val)
so it WOULD look like Code: [Select]2709002thanks BFB , that worked wonderfully
best regards Genie
|