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.

5701.

Solve : Need help with a batch file?

Answer»

I am installing AIM via a batch file process. Due to the way AIM installs itself I can't seem to get it to install silently as there are no switches that I have found that can do this. ANYWAY everything seems to be fine until the install finishes , at that point it pops a box up and asks to click close. I would like to somehow SCRIPT for a way to either click the close button for the user or somehow put into the script a timeout with a taskkill or something where after say 40 seconds the batch would kill setup.exe and continue to execute ?

Basically a way to force a continuation of the script after a set amount of time In Vista and Win7 you can USE the timeout command and then kill the task.

launch setup.exe with

start "" "c:\folder\setup.exe"
timeout -t 40
taskkill blah blahThanks but we still use WINDOWS xp will that also work there ? Use PING instead.

start "" "c:\folder\setup.exe"
ping -n 40 localhost >nul
taskkill blah blah

5702.

Solve : echo %%i throu FOR loop?

Answer»

Dear friends, in batch i write
Code: [Select]for /F "delims=" %%i in (MyFile.TXT) do echo.%%i>>NewFile.TXTif %%i contains for example "abc>def" (without the " ") it generates error because the > is interpreted as if i redirect abc to def
if i surround the expression with " " it's ok, but i can't do it because i must redirect to NewFile.TXT without the " "
Thanks for helpWhat OS are you using? It works fine here in Win 7.
I use Windows 7, Thank you very much, but sorry to say... i was too short, indeed my code is like this:
Code: [Select]for /f "delims=" %%i in (MyFile.TXT) do echo.%%i|find "ABC" >> NewFile.TXTand the line in the file contains 123>asd\678
and of course i get error: The system cannot find the PATH specified.
because >asd\ is interpreted as redirecting to a path that of course does not exist.
Thanks, any idea?Try this:

Quote

for /f "delims=" %%i in ('find "ABC" ^<MyFile.TXT') do echo.%%i>> NewFile.TXT


Or this:

Quote
find "ABC" <MyFile.TXT >>NewFile.TXT
Thank you very very much, i use the 1st suggetion because i need more manipulations.
Please tell me what is this use/behaviour of ^ before the input <
after your solution i tried instead of the use of ^ this: '"find "ABC"
OK i realized that it's an escape char that causes to interpret codes as simple chars.
I see that robvanderwoude has a lot about it.

again thank you very muchQuote from: yossi_moses on JULY 25, 2012, 08:38:35 AM
after your solution i tried instead of the use of ^ this: '"find "ABC" <MyFile.TXT"' and it also worked.

If you try that again in a for in do loop command you will find that it generates an error and will fail.

I'm glad you found the solution useful. Am I missing something?

Code: [Select]C:\>type myfile.txt
abc&def
abc<def
abc|def
abc>def
123>asd\678
123<asd\678
123&asd\678
123|asd\678

C:\>type test1.bat
@echo off
for /f "delims=" %%i in (myfile.txt) do echo.%%i>>newfile.txt

C:\>test1.bat

C:\>type newfile.txt
abc&def
abc<def
abc|def
abc>def
123>asd\678
123<asd\678
123&asd\678
123|asd\678

C:\>
A later post revealed that this was more like the real request:

for /f "delims=" %%i in (MyFile.TXT) do echo.%%i|find "ABC" >> NewFile.TXTDear Salmon Trout, 1st, thanks a lot. But it seems that indeed some thing is missed.
very strange, but
ECHO%%Var>FileName
is well escaped (no need for escape chars),
and
ECHO%%Var|FIND
is not escaped.

Please HELP me to UNDERSTAND how to thank in a way that my thank to any body will be counted in the forum.
Thanks
5703.

Solve : Read from file named after the next day in the week?

Answer»

I'm stuck trying to do something in a batch file based on the day of the week. Here's some of the code:

Code: [Select]SET /P M=
:
IF %M%==1 (
SET M=1.Monday
GOTO :MONDAY
)
IF %M%==2 (
SET M=2.Tuesday
GOTO :TUESDAY
)
IF %M%==3 (
SET M=3.Wednesday
GOTO :WEDNESDAY
)
IF %M%==4 (
SET M=4.Thursday
GOTO :THURSDAY
)
IF %M%==5 (
SET M=5.Friday
GOTO :FRIDAY
)
IF %M%==6 (
SET M=Special
GOTO :SPECIAL
)
IF %M%==Q GOTO :QUIT_ADMIN
IF %M%==q GOTO :QUIT_ADMIN
:

:MONDAY
CLS
IF EXIST logs\templog.txt DEL /F /Q logs\templog.txt
For /F "Tokens=*" %%I In[b] (Tuesday.txt)[/b] Do (
C:\psexec \\<server> %W% %%I /passw >>logs\templog.txt
)
At the top of the script I set M=whatever day of the week the user inputs (1-5 corresponds to Mon-Fri). On Monday the batch file should read from a document named "Tuesday.txt" Instead of referring directly to this list (Tuesday.txt) I'd like to refer to it as a dynamic variable like "Tomorrow".

"Tomorrow" should equal %M%+1. How can I do this? This will eliminate the need to repeat the code for every day of the week which I think is a lot cleaner. Thanks for the help.

Thanks,

MJCode: [Select] set /a Tomorrow=%M%+1 Quote from: Lemonilla on July 25, 2012, 03:25:40 PM

Code: [Select] set /a Tomorrow=%M%+1
M is equal to 1.Monday.
So you end up with your code failing.
Code: [Select]C:\Users\Squash>set M=1.Monday

C:\Users\Squash>set /a tomorrow=%M% + 1
Missing operator.
But you could substring the variable
Code: [Select]C:\Users\Squash>set /a tomorrow=%M:~0,1% + 1
2What happens at :SPECIAL?

Also, you can replace these 2 lines

IF %M%==Q GOTO :QUIT_ADMIN
IF %M%==q GOTO :QUIT_ADMIN

with this one line

IF /I %M%==Q GOTO :QUIT_ADMIN

Salmon Trout - Special is used when the standard daily list changes. Rather than append the changes to Tuesday.txt (for example) a separate list is made. Thanks for the tip about Quit. I'll apply that for sure. I have several other scripts where I account for both upper and lower case entries from the user so this is nice to know.

Squashman - Thank you for your help. I didn't realize that what I asked for %M%+1 could work. Maybe it didn't. I added

SET /A Tomorrow=%M% + 1 and "2" was returned
SET /A Tomorrow=M + 1 and "2" was returned
SET /A Tomorrow=%M:~0,1% + 1, "2" was returned

Since my lists are named after the day of the week is it possible for %M% + 1 to equal "Tuesday" instead of "2"?

Thanks again,

MJ
Not really understanding what you are trying to do.
Code: [Select]SET /P M=

IF %M%==1 (
SET TOMORROW=TUESDAY
GOTO :MONDAY
)
IF %M%==2 (
SET TOMORROW=WEDNESDAY
GOTO :TUESDAY
)
IF %M%==3 (
SET TOMORROW=THURSDAY
GOTO :WEDNESDAY
)
IF %M%==4 (
SET TOMORROW=FRIDAY
GOTO :THURSDAY
)
IF %M%==5 (
SET TOMORROW=SATURDAY
GOTO :FRIDAY
)
IF %M%==6 (
SET M=Special
GOTO :SPECIAL
)
IF %M%==Q GOTO :QUIT_ADMIN
IF %M%==q GOTO :QUIT_ADMINIt could probably be streamlined if we knew the purpose and code.

I'm guessing that the code for the actual function is repeated 7 times with just a name changed for the file each daySquashman - thanks again. It appears that I was mentally over-complicating things and I'm not much of a script writer. SET TOMORROW= was what I was looking for. It allowed me to tidy up one script and cut 3/4 of another one out.

Every night I have to drain servers in two different farms. The script determines the day of the week and then references preconfigured lists named after the days of the week to run wlbs commands against. For example: on Monday the script determines that it's Monday and loads the servers from the Tuesday.txt list, emails the proper parties the list of servers that scheduled to be drained, drains them, creates a log, emails me the log and cleans up the temporary txt files it creates in the process.

Perhaps you can help me clean up another segment of the script:

Code: [Select]FINDSTR /V "WLBS" logs\templog.txt >>logs\format.txt
FOR /F "Tokens=* Delims= " %%A in (logs\format.txt) do (
SET /a N+=1
echo ^%%A^ >>logs\RebootLog.txt
This part of the script searches templog.txt and outputs every line that doesn't start with WLBS to format.txt. Blat is being used for emailing the logs. When Blat reads RebootLog.txt and copies the contents into the body of an email it isn't easily read. So I use the next lines of code to read the contents of format.txt and add a space between each line so the body of the email that Blat sends is easily read.

Is there a simpler way to add a CR at the end of every line of text in templog.txt so I can just echo it to RebootLog.txt and bypass the need for format.txt?

Thanks,

MJNot understanding you again. I am one of those people who needs to see examples. What the Input Looks like and what the desired output needs to look like. Then I code based on that information.The text that is output to the log report (templog.txt) looks like this:

Did not receive response from the cluster.
Did not receive response from the cluster.
Did not receive response from the cluster.
Did not receive response from the cluster.

But, when Blat uses the templog.txt file to create the email body the text in the email body looks like this:

Did not receive response from the cluster.Did not receive response from the
cluster.Did not receive response from the cluster.Did not receive response from the cluster.

I am ECHOING the contents of templog.txt to format.txt to correct the formatting so the email body looks like this:

Did not receive response from the cluster.

Did not receive response from the cluster.

Did not receive response from the cluster.

Did not receive response from the cluster.

I'd prefer not to have to use format.txt to finesses the data but there's something about how Blat views templog.txt (which is a plain text file btw) that is forcing the need. I just wonder if there is a less involved way to do what I've done than

Code: [Select]findstr /V "WLBS" logs\templog.txt >>logs\format.txt
FOR /F "Tokens=* Delims= " %%A in (logs\format.txt) do (
SET /a N+=1
echo ^%%A^ >>logs\RebootLog.txt

Thanks,

MJCan we see the entire batch file.I'm guessing that the line endings are not MSDOSsified.

Try this to see what it spits out.

Code: [Select]for /f "delims=" %%a in ('findstr /V "WLBS" logs\templog.txt') do cmd /c echo.%%a>>logs\RebootLog.txt
5704.

Solve : Can I run a com file in separate memory space??

Answer»

rem.>file.txt creates a zero byte file.

2>nul SENDS the error stream to nul and hides any error message, if the file can't be found.Hi,
This works great! My program seems to work BETTER from it's .PIF, so instead of the cmd /k I have "start /separate/wait msdosfile".
If I quit the program normally everything is fine. If I close the window using windows little red X (don't know what else to call it) there is another window behind it saying "^cTerminate batch job (Y/N) ?" Answer Y runs the del command, N quits before it. as people even dummer than I am have to use this, it may GET a little confusing. Is there a switch to disable the question and continue the batch file and does there have to be a second window?
You'll just have to educate the dumb people not to close the program from the red XThank you for your help.
Geoffl

5705.

Solve : need some help checking a batch file for errors?

Answer»

I made this batch file about a year ago to fix windows network scanning errors for a program CALLED Spiceworks. Somehow since then I forgot why some of the lines of code are the way that they are, and I think that I have most of the problems fixed now.. but I was hoping that someone could look at the file and see if there are any errors that need fixed.

One thing that I could never figure out was how to get the REGISTRY backup part to just backup to a folder called c:\reg_backup%date% instead of the random number thing that it is currently using.. any help here would be great. (A lot of the users want this fixed so that it backs up to a folder with a date) just figured this out, and changed the batch file.. and tested

I spent a lot of time figuring out what commands would work correctly under XP/Vista/7 so I think everything is OK, but for some reason the copy that was posted had a ton of "\\" when it should just have been "\" but I think that's all fixed now..

It would also be nice if it created a log file.. I tried to add one a long time ago, but couldn't get it to work right

Code: [Select]@ECHO OFF
COLOR 1F
CD \\
CLS
ECHO Version 1.7
ECHO 03/24/2012
ECHO Author: Adam1818
ECHO This has only been tested on Windows 7 and XP
ECHO please do your own testing for Vista
ECHO .
ECHO USE AT YOUR OWN RISK
ECHO **************************************************************
ECHO **************************************************************

:ROOT
ECHO 1. Please backup my Registry before making any changes
ECHO 2. BASIC REBUILD (recommended first attempt)
ECHO 3. Advanced Options
ECHO 4. Quit Now
ECHO 9. COMPLETE REBUILD, without Prompts
SET INPUT=
SET /p INPUT=Please make a selection...
IF "%INPUT%"=="1" GOTO REG_BACKUP
IF "%INPUT%"=="2" GOTO FIREWALL_DOM_SER
IF "%INPUT%"=="3" GOTO ROOT2
IF "%INPUT%"=="4" GOTO END
IF "%INPUT%"=="9" GOTO SKIP
FOR %%j IN (1 2 3 4 9) DO IF "%%j"=="%INPUT%" GOTO :%INPUT%
CLS
GOTO root

:ROOT2
CLS
ECHO ADVANCED OPTIONS: make a selection
ECHO .
ECHO 1. Run NSLOOKUP
ECHO 2. Disable System Standby and Hibernate
ECHO 3. Rebuild WMI
ECHO 4. Delete old Windows updates Temp files
ECHO 5. ADD LocalAccountTokenFilterPolicy
ECHO 6. Disable UAC
ECHO 7. Add LOCAL Administrator account
ECHO 8. (BASIC REBUILD) FIREWALL RULES, ENABLE DOM, ADD SERVICES
ECHO 9. Registry backup
ECHO 10. Windows XP HOME (Not Pro) computer in a workgroup
ECHO 11. Restart Computer
SET INPUT=
SET /p INPUT=Please make a selection...
IF "%INPUT%"=="1" GOTO NSLOOKUP
IF "%INPUT%"=="2" GOTO PWR_SETTINGS
IF "%INPUT%"=="3" GOTO WMI
IF "%INPUT%"=="4" GOTO WINUPDATE
IF "%INPUT%"=="5" GOTO LATFP
IF "%INPUT%"=="6" GOTO UAC
IF "%INPUT%"=="7" GOTO ADMIN
IF "%INPUT%"=="8" GOTO FIREWALL_DOM_SER
IF "%INPUT%"=="9" GOTO REG_BACKUP
IF "%INPUT%"=="10" GOTO WIN_XP_WORKGROUP_FIX
IF "%INPUT%"=="11" GOTO RESTART_PROMPT
FOR %%j IN (1 2 3 4 5 6 7 8 9 10 11) DO IF "%%j"=="%INPUT%" GOTO :%INPUT%
CLS
GOTO root2

:SKIP
CLS
ECHO **************************************************************
ECHO **************************************************************
ECHO COMPLETE REBUILD, with no Prompts
ECHO This will run the following with NO PROMPTS!!
ECHO (This may take 2-15 minutes depending on computer)
ECHO **************************************************************
ECHO Complete Registry Backup to c:\REG_BACKUP_MM-DD-YYYY
ECHO Disable "Hibernate" and "System Standby"
ECHO ADD LocalAccountTokenFilterPolicy
ECHO Complete WMI Rebuild
ECHO Force Group Policy Updates
ECHO Flush DNS (Ipconfig/flushDNS)
ECHO Open the correct Firewall ports
ECHO Allow ICMP ECHO Request (ping)
ECHO Enable Printer and File Sharing (Firewall)
ECHO Enable WMI (Firewall)
ECHO Enable RDP (Firewall)
ECHO Enable DCOM
ECHO SET DCOM Authentication Level
ECHO SET DCOM Impersonation Level
ECHO Change several services to auto start with Windows
ECHO **************************************************************
ECHO **************************************************************
ECHO IT DOES NOT DO THE FOLLOWING
ECHO **************************************************************
ECHO Delete Windows updates temporary files
ECHO Disable UAC
ECHO Create an Administrator Account
ECHO Run NSLOOKUP tool to test DNS
ECHO Disable force guest on Windows XP HOME clients
ECHO **************************************************************
ECHO **************************************************************
ECHO Do you want to continue with the COMPLETE REBUILD?
ECHO 1. Return to root menu
ECHO 9. RUN COMPLETE REBUILD
SET SKIP=
SET /p SKIP=Please make a selection... (1 or 9)
IF "%SKIP%"=="1" GOTO ROOT
IF "%SKIP%"=="9" GOTO SKIP2
FOR %%j IN (1 9) DO IF "%%j"=="%SKIP%" GOTO :%SKIP%
CLS
GOTO SKIP

:REG_BACKUP
:SKIP2
SET INPUT=_%date:~4,2%-%date:~7,2%-%date:~10,4%
md c:\REG_BACKUP%INPUT%
ECHO making a complete backup of the registry at c:\REG_BACKUP%INPUT%
REGEDIT.EXE /e c:\REG_BACKUP%INPUT%\complete.reg
ECHO making a backup of individual registry keys that will be modified
REG export HKLM\SOFTWARE\Microsoft\Ole c:\REG_BACKUP%INPUT%\Ole.REG
REG export HKLM\SYSTEM\CurrentControlSET\Services\eventsystem c:\REG_BACKUP%INPUT%\eventsystem.REG
REG export HKLM\SYSTEM\CurrentControlSET\Services\lanmanworkstation c:\REG_BACKUP%INPUT%\lanmanworkstation.reg
REG export HKLM\SYSTEM\CurrentControlSET\Services\rasauto c:\REG_BACKUP%INPUT%\rasauto.reg
REG export HKLM\SYSTEM\CurrentControlSET\Services\remoteregistry c:\REG_BACKUP%INPUT%\remoteregistry.reg
REG export HKLM\SYSTEM\CurrentControlSET\Services\rpclocator c:\REG_BACKUP%INPUT%\rpclocator.reg
REG export HKLM\SYSTEM\CurrentControlSET\Services\winmgmt c:\REG_BACKUP%INPUT%\winmgmt.reg
REG export HKLM\SYSTEM\CurrentControlSET\Services\wmiapsrv c:\REG_BACKUP%INPUT%\wmiapsrv.reg
ECHO **************************************************************
ECHO Registry backed up to c:\REG_BACKUP%INPUT%
ECHO **************************************************************
IF "%SKIP%"=="9" GOTO SKIP3
GOTO ROOT

:NSLOOKUP
CLS
ECHO NSLOOKUP This is a basic DNS test
SET INPUT=
SET /p INPUT=Enter the name of your Spiceworks server:
ECHO **************************************************************
NSLOOKUP "%INPUT%"
ECHO **************************************************************
ECHO The above results should look similar to the following
ECHO **************************************************************
ECHO Server: DNS_servername.DomainName
ECHO Address IP address of DNS server
ECHO .
ECHO Name: Spiceworks_Servername.DomainNmae
ECHO Address: IP address of Spiceworks server
ECHO **************************************************************
ECHO IF your results don't look the same as the example
ECHO your DNS needs to be looked at before running any additional
ECHO repairs on the local computer
ECHO .
ECHO .
ECHO 1. Run NSLOOKUP again
ECHO 2. Return to Advanced Menu
ECHO 3. My DNS is reporting bad information
SET INPUT=
SET /p INPUT=Please make a selection...
IF "%INPUT%"=="1" GOTO NSLOOKUP
IF "%INPUT%"=="2" GOTO ROOT2
IF "%INPUT%"=="3" GOTO DNS
FOR %%j IN (1 2 3) DO IF "%%j"=="%INPUT%" GOTO :%INPUT%
CLS
GOTO NSLOOKUP

:DNS
ECHO IF you ran NSLOOKUP and it didn't return the anticipated
ECHO results.. Does your network even have a DNS server?
ECHO Does your DNS have a "reverse lookup zone"?
ECHO Is there an "Host (A)" Record for the name you tested?
ECHO Watch the video at the following address, it helped me out:
ECHO http://www.spiceworks.com/tv/?cat=webinars&video=Managing-DNS
ECHO 1. Open the webpage now.
ECHO 2. Return to Advance Menu
SET INPUT=
SET /p INPUT=Please make a selection...
IF "%INPUT%"=="1" GOTO DNS_Video
IF "%INPUT%"=="2" GOTO ROOT2
FOR %%j IN (1 2) DO IF "%%j"=="%INPUT%" GOTO :%INPUT%
CLS
GOTO DNS

:DNS_Video
Start iexplore "www.spiceworks.com/tv/?cat=webinars&video=Managing-DNS"

:PWR_SETTINGS
CLS
ECHO Is the computer that you are having problems with
ECHO sometimes SCAN correctly, and other it has scan errors?
ECHO It may also have duplicates in Spiceworks
ECHO if so it maybe the Power Management Settings are set to "hibernate"
ECHO or "System Standby" after X amount of time.
ECHO if one of the above is true disabling them on this computer may fix your problem
ECHO (Disables Hibernation and System Standby
ECHO .
ECHO 1. Disable Hibernation and System Standby
ECHO 2. Return to Advanced Menu.
SET INPUT=
SET /p INPUT=Please make a selection...
IF "%INPUT%"=="1" GOTO VER_PWR
IF "%INPUT%"=="2" GOTO ROOT2
FOR %%j IN (1 2) DO IF "%%j"=="%INPUT%" GOTO :%INPUT%
CLS

:VER_PWR
:SKIP3
ECHO Disable Hibernate and System Standby
VER | FINDSTR /IL "5.1." > NUL
IF %ERRORLEVEL% EQU 0 GOTO PWR_XP
VER | FINDSTR /IL "6.1." > NUL
IF %ERRORLEVEL% EQU 0 GOTO PWR_Vista_7
VER | FINDSTR /IL "6.0." > NUL
IF %ERRORLEVEL% EQU 0 GOTO PWR_Vista_7
GOTO PWR_SETTINGS

:PWR_XP
POWERCFG /hibernate off
POWERCFG /CREATE Spice1
POWERCFG /CHANGE Spice1 /monitor-timeout-ac 15
POWERCFG /CHANGE Spice1 /monitor-timeout-dc 10
POWERCFG /CHANGE Spice1 /disk-timeout-ac 30
POWERCFG /CHANGE Spice1 /disk-timeout-dc 10
POWERCFG /CHANGE Spice1 /standby-timeout-ac 0
POWERCFG /CHANGE Spice1 /standby-timeout-dc 0
POWERCFG /CHANGE Spice1 /hibernate-timeout-ac 0
POWERCFG /CHANGE Spice1 /hibernate-timeout-dc 0
POWERCFG /CHANGE Spice1 /processor-throttle-ac ADAPTIVE
POWERCFG /CHANGE Spice1 /processor-throttle-dc ADAPTIVE
POWERCFG /SETACTIVE Spice1
IF "%SKIP%"=="9" GOTO SKIP4
GOTO ROOT2

:PWR_VISTA_7
powercfg -H off
powercfg -x -standby-timeout-ac 0
IF "%SKIP%"=="9" GOTO SKIP4
GOTO ROOT2

:WMI
CLS
ECHO WMI Rebuild
ECHO 1. Rebuild WMI
ECHO 2. Return To Advanced Menu
SET INPUT=
SET /p INPUT=Please make a selection...
IF "%INPUT%"=="1" GOTO WMI2
IF "%INPUT%"=="2" GOTO ROOT2
FOR %%j IN (1 2) DO IF "%%j"=="%INPUT%" GOTO :%INPUT%
CLS
GOTO WMI

:WMI2
:SKIP4
ECHO Rebuilding WMI... Please wait.
@echo on
cd %WinDir%\System32\Wbem\
net stop sharedaccess
net stop winmgmt /y
if exist Rep_bak rd Rep_bak /s /q
ren Repository Rep_bak
for %%i in (*.dll) do RegSvr32 -s %%i
@ECHO OFF
echo **************************************************
ECHO THE NEXT LINE MAY TAKE A FEW MINUTES, PLEASE WAIT
ECHO IGNORE ALL "#PRAGMA AUTORECOVERY" MESSAGES
ECHO THAT IS EXPECTED, IT IS NOT AN ERROR
echo **************************************************
@ECHO ON
for %%i in (*.mof,*.mfl) do Mofcomp %%i
net start winmgmt
if not exist wmicore.exe goto notexist
wmicore /s
:notexist
@ECHO OFF
VER | FINDSTR /IL "5.1." > NUL
IF %ERRORLEVEL% EQU 0 GOTO WMI_XP
VER | FINDSTR /IL "6.1." > NUL
IF %ERRORLEVEL% EQU 0 GOTO WMI_Vista_7
VER | FINDSTR /IL "6.0." > NUL
IF %ERRORLEVEL% EQU 0 GOTO WMI_Vista_7
:WMI_XP
@ECHO OFF
ECHO Windows XP
net start winmgmt
IF "%SKIP%"=="9" GOTO SKIP5
GOTO ROOT2
:WMI_Vista_7
@ECHO OFF
ECHO Windows Vista or 7
ECHO now verifing the WMI Repository
winmgmt /resetRepository
ECHO THIS WILL TAKE 30 SECONDS
winmgmt /verifyrepository
net start winmgmt
IF "%SKIP%"=="9" GOTO SKIP5
GOTO ROOT2

:WinUpDate
CLS
ECHO Remove old Windows update temporary files?
ECHO (not necessary for Spiceworks scan errors)
ECHO 1. Please cleanup the old windows updates temp files
ECHO 2. Return to Advanced Menu
SET INPUT=
SET /p INPUT=Please make a selection...
IF "%INPUT%"=="1" GOTO WinUpDate2
IF "%INPUT%"=="2" GOTO ROOT2
FOR %%j IN (1 2) DO IF "%%j"=="%INPUT%" GOTO :%INPUT%
CLS
GOTO WinUpDate

:WinUpDate2
ECHO Resetting Automatic Updates
net stop "Automatic Updates"
del /f /s /q %windir%\SoftwareDistribution\*.*
ECHO.
ECHO.
net start "Automatic Updates"
ECHO Forcing AU detection and resetting authorization tokens
wuauclt.exe /reSETauthorization /detectnow
GOTO ROOT2

:LATFP
CLS
ECHO Some people report that the following key is needed
ECHO HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
ECHO "LocalAccountTokenFilterPolicy"=dword:00000001
ECHO .
ECHO 1. Please add the Registry key for me
ECHO 2. Return to Advanced Menu
SET INPUT=
SET /p INPUT=Please make a selection...
IF "%INPUT%"=="1" GOTO LATFPY
IF "%INPUT%"=="2" GOTO ROOT2
FOR %%j IN (1 2) DO IF "%%j"=="%INPUT%" GOTO :%INPUT%
CLS
GOTO LATFP

:LATFPY
:SKIP5
REG add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v LocalAccountTokenFilterPolicy /t REG_DWORD /d "0" /f
IF "%SKIP%"=="9" GOTO SKIP6
GOTO :ROOT2

:UAC
CLS
VER | FINDSTR /IL "5.1." > NUL
IF %ERRORLEVEL% EQU 0 GOTO VER
ECHO 1. Disable UAC (Recommended for computers not in a Domain)
ECHO 2. Return to Advanced Menu
SET INPUT=
SET /p INPUT=
IF "%INPUT%"=="1" GOTO UAC2
IF "%INPUT%"=="2" GOTO ROOT2
FOR %%j IN (1 2) DO IF "%%j"=="%INPUT%" GOTO :%INPUT%
CLS
GOTO UAC

:UAC2
ECHO Disable UAC
REG ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 0 /f
GOTO ROOT2

:ADMIN
CLS
REM List of current Administrator accounts on this computer
NET LOCALGROUP Administrators
ECHO **************************************************************
ECHO Would you like to add a LOCAL Administrator account?
ECHO **************************************************************
ECHO User: SysAdmin
ECHO Password: Passw0rd (P is capital, and 0 is a zero)
ECHO **************************************************************
ECHO 1. please add the account for me.
ECHO 2. Return to Advanced Menu
SET INPUT=
SET /p INPUT=Please make a selection...
IF "%INPUT%"=="1" GOTO AddAccount
IF "%INPUT%"=="2" GOTO ROOT2
FOR %%j IN (1 2) DO IF "%%j"=="%INPUT%" GOTO :%INPUT%
CLS
GOTO ADMIN

:AddAccount
net user SysAdmin Passw0rd /ADD
net localgroup Administrators SysAdmin /ADD
ECHO: Administrator account has been added
GOTO ROOT2

:FIREWALL_DOM_SER
:SKIP6
ECHO refreshing system policies
ECHO IF it hangs here for more than a few minutes
ECHO Press N and then enter, and the script should cont.
gpupdate /force
ipconfig /flushdns
VER | FINDSTR /IL "5.1." > NUL
IF %ERRORLEVEL% EQU 0 GOTO ver_xp
VER | FINDSTR /IL "6.1." > NUL
IF %ERRORLEVEL% EQU 0 GOTO ver_7
VER | FINDSTR /IL "6.0." > NUL
IF %ERRORLEVEL% EQU 0 GOTO ver_vista

:ver_xp
ECHO Windows XP commands
ECHO Setting Firewall Services
netsh firewall SET icmpSETting 8
netsh firewall SET service remoteadmin enable
netsh firewall SET service remoteadmin enable subnet
GOTO DCOM

:ver_vista
ECHO Vista commands
ECHO SETting Firewall Services
netsh firewall SET icmpSETting 8 enable
netsh firewall SET service remoteadmin enable
netsh firewall SET service remoteadmin enable subnet
netsh advfirewall firewall SET rule group="file and printer sharing" new enable=yes
netsh advfirewall firewall SET rule group="windows management instrumentation (wmi)" new enable=yes
netsh advfirewall firewall SET rule group="remote administration" new enable=yes
GOTO DCOM

:ver_7
ECHO Windows 7 commands
ECHO Setting Firewall Services
netsh advfirewall firewall SET rule group="file and printer sharing" new enable=yes
netsh advfirewall firewall SET rule group="windows management instrumentation (wmi)" new enable=yes
REM following line will error on Win 7 Home Edition
netsh advfirewall firewall SET rule group="remote administration" new enable=yes
GOTO DCOM

:DCOM
ECHO Enabling DCOM
REG add HKLM\SOFTWARE\Microsoft\Ole /v EnableDCOM /t REG_SZ /d "Y" /f
ECHO Configuring DCOM
REG add HKLM\SOFTWARE\Microsoft\Ole /v LegacyAuthenticationLevel /t REG_DWORD /d "2" /f
REG add HKLM\SOFTWARE\Microsoft\Ole /v LegacyImpersonationLevel /t REG_DWORD /d "3" /f
GOTO Services

:Services
ECHO Changing Service Startup Configurations
REG ADD HKLM\SYSTEM\CurrentControlSET\Services\eventsystem /v start /t REG_DWORD /d 2 /f
REG ADD HKLM\SYSTEM\CurrentControlSET\Services\lanmanworkstation /v start /t REG_DWORD /d 2 /f
REG ADD HKLM\SYSTEM\CurrentControlSET\Services\rasauto /v start /t REG_DWORD /d 2 /f
REG ADD HKLM\SYSTEM\CurrentControlSET\Services\remoteregistry /v start /t REG_DWORD /d 2 /f
REG ADD HKLM\SYSTEM\CurrentControlSET\Services\rpclocator /v start /t REG_DWORD /d 2 /f
REG ADD HKLM\SYSTEM\CurrentControlSET\Services\rpcss /v start /t REG_DWORD /d 2 /f
REG ADD HKLM\SYSTEM\CurrentControlSET\Services\winmgmt /v start /t REG_DWORD /d 2 /f
REG ADD HKLM\SYSTEM\CurrentControlSET\Services\wmiapsrv /v start /t REG_DWORD /d 2 /f
ECHO Resyncing WMI
winmgmt.exe /resyncperf
GOTO Restart_Prompt

:WIN_XP_WORKGROUP_FIX
VER | FINDSTR /IL "5.1." > NUL
IF %ERRORLEVEL% EQU 0 GOTO ver_xp_WGFIX
VER | FINDSTR /IL "6.1." > NUL
IF %ERRORLEVEL% EQU 0 GOTO ROOT2
VER | FINDSTR /IL "6.0." > NUL
IF %ERRORLEVEL% EQU 0 GOTO ROOT2
:ver_xp_WGFIX
CLS
ECHO Note that for Windows XP in a workgroup setting,
ECHO default all connections coming from "the network"
ECHO will be authenticated as the Guest User.
ECHO **************************************************************
ECHO Note that for WinXP Home you cannot disable
ECHO the ForceGuest behavior (only in WinXP Pro).
ECHO **************************************************************
ECHO However this will make the change in the Registry
ECHO to fix the problem in WinXP Home Computers.
ECHO **************************************************************
ECHO This will change the registry key for you.
ECHO **************************************************************
ECHO 1. please change the registry value for me.
ECHO 2. Return to Advanced Menu
SET INPUT=
SET /p INPUT=Please make a selection...
IF "%INPUT%"=="1" GOTO WGFIX
IF "%INPUT%"=="2" GOTO ROOT2
FOR %%j IN (1 2) DO IF "%%j"=="%INPUT%" GOTO :
:WGFIX
REG add HKLM\SYSTEM\CurrentControlSet\Control\Lsa /v ForceGuest /t REG_DWORD /d "0" /f
GOTO ROOT2

:Restart_Prompt
CLS
ECHO **************************************************************
ECHO **************************************************************
ECHO Some changes will not take effect until you restart.
ECHO Would you like to restart your computer now?
ECHO **************************************************************
ECHO
**************************************************************
ECHO 1. Restart my computer in 15 seconds
ECHO 2. I will restart it myself
SET INPUT=
SET /p INPUT=
IF "%INPUT%"=="1" GOTO RESTART
IF "%INPUT%"=="2" GOTO END
FOR %%j IN (1 2) DO IF "%%j"=="%INPUT%" GOTO :%INPUT%
CLS
GOTO Restart_Prompt

:RESTART
shutdown /r /t 15 /c "your computer will restart in 15 seconds"
exit

:END
exit
Qlueless,
Welcome to the CH forum.
I can not personally help you. May I offer some suggestions?
First, never expect volunteers to verify a long, long batch file.

Second, you need to make it cleaner for yourself. You can not remember a year later what you did. Maybe your code is much too long for yourself to visualize easily. . You need to BREAK it up into short things the can e tested and verified. These are called subroutines and can be other batch files. You invoke such with the CALL keyword and pass arguments. Much easier to understand.

You need to make more comments about what things do and why you do something odd or different that what would be expected. And you need to implement some kind of error recovery method.

Also, you short write a paragraph or two about why you are doing this. Is it just and exercise? or does it fill a need that can not be done some other way? Do you every use VB Script?
Some very good points by Geek:

Quote

never expect volunteers to verify a long, long batch file

This most of all. You see this type of question from time to time, and often nobody at all replies.

Quote
you need to make it cleaner for yourself. You can not remember a year later what you did. Maybe your code is much too long for yourself to visualize easily. . You need to break it up into short things the can e tested and verified. These are called subroutines and can be other batch files. You invoke such with the CALL keyword and pass arguments. Much easier to understand.

This is definitely good advice. Start small and work your way up. Write and test the script in stages. Make sure each part works before adding another.

Quote
You need to make more comments about what things do

Failing to COMMENT is one of the biggest mistakes that a batch scripter can make, in my opinion. Not only does good commenting help when you come back later on, it can help you right now, as you are actually writing the code, because it forces you to state in writing what a line or section of code is supposed to do. In order to do this, you have to actually think about that. If you just slap lines of code in because you hope they might do what you want, you'll end up with a mess, and you won't know what works and what doesn't (and why). Sometimes you need to turn echoing on to see where code is not doing what you want. For example here the code I show in red does absolutely nothing and if you put @echo on before it and @echo off after it, you will see why.


SET INPUT=
SET /p INPUT=
IF "%INPUT%"=="1" GOTO RESTART
IF "%INPUT%"=="2" GOTO END
FOR %%j IN (1 2) DO IF "%%j"=="%INPUT%" GOTO :%INPUT%
CLS
GOTO Restart_Prompt


It looks like it was left over from an earlier incarnation of the script where you made the code GOTO a variable label e.g. :1 :2 etc and then you found out that typing 3 made the script crash?




well you could always run the program and see where it crashes, here's a script that will make a copy that creates a log of the commands that it does before it crashes, that way if it does have an error, you will know exactly which line it is on.
Code: [Select]
@echo off
echo Enter Name Of File To Edit
set /p name=
echo @echo off >>%name%Bug.bat
echo ^:^: This is a bug testing program for batch. >>%name%Bug.bat
echo ^:^: Results may varry with scrips containing for loops. >>%name%Bug.bat
echo ^:^: ******* By Lemonilla >>%name%Bug.bat
for /f "delims=" %%G in (%name%.bat) do (
echo echo %%G ^>^>%name%Log.txt >>%name%Bug.bat
echo %%G ^>^>%name%Log.txt >>%name%Bug.bat
echo %%G >>%name%Bug.bat
)
start %name%Bug.bat


PS: Don't know if this works with multi-line for loops.
5706.

Solve : [help]about bootable flashdrive?

Answer»

can anyone HELP me how to make bootable FLASHDRIVE that can make a DOS command that have a boot disk start up dia,l recovery disk ,and SYSTEM disk?look up bootdisk.com for a bootable ISO image.

Use Xboot for Windows to create a bootable USB drive using the ISO image.ok i will TRY thank you for the reply how to make a config.sys?how to lock this thread?

5707.

Solve : How to add new user environment variable uisng the DOS command???

Answer»

Dear All,

How can I add new user environment variable by DOS command???

is it possible?? PLEASE advise

Thanks in advance.

see attach image:



[year+ old attachment deleted by admin]Why do you need to CREATE a permanent variable?

There's probably a registry hack to do it, but your answer to the question will help decide which way to go.You can do this with the SETX command. It is part of the Windows Support tools.
If you don't have the disc for the support tools I believe it can be downloaded.Thanks Squashman. It is part of Windows 7 now.

This is from the help:

Code: [Select]NOTE: 1) SETX writes variables to the master environment in the registry.

2) On a local system, variables created or modified by this tool
will be AVAILABLE in future command windows but not in the
current CMD.exe command window.

3) On a remote system, variables created or modified by this tool
will be available at the next logon session.

4) The valid Registry Key data types are REG_DWORD, REG_EXPAND_SZ,
REG_SZ, REG_MULTI_SZ.

5) Supported hives: HKEY_LOCAL_MACHINE (HKLM),
HKEY_CURRENT_USER (HKCU).

6) Delimiters are case sensitive.

7) REG_DWORD values are extracted from the registry in decimal
format.

Examples:
SETX MACHINE COMPAQ
SETX MACHINE "COMPAQ COMPUTER" /M
SETX MYPATH "%PATH%"
SETX MYPATH ~PATH~
SETX /S system /U user /P password MACHINE COMPAQ
SETX /S system /U user /P password MYPATH ^%PATH^%
SETX TZONE /K HKEY_LOCAL_MACHINE\System\CurrentControlSet\
Control\TimeZoneInformation\StandardName
SETX BUILD /K "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows
NT\CurrentVersion\CurrentBuildNumber" /M
SETX /S system /U user /P password TZONE /K HKEY_LOCAL_MACHINE\
System\CurrentControlSet\Control\TimeZoneInformation\
StandardName
SETX /S system /U user /P password BUILD /K
"HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\
CurrentVersion\CurrentBuildNumber" /M
SETX /F ipconfig.out /X
SETX IPADDR /F ipconfig.out /A 5,11
SETX OCTET1 /F ipconfig.out /A 5,3 /D "#$*."
SETX IPGATEWAY /F ipconfig.out /R 0,7 Gateway
SETX /S system /U user /P password /F c:\ipconfig.out /X

5708.

Solve : ISO: DOS BATCH method to FIND+REPLACE text in TaskSched .XML file?

Answer»

Hi, I am looking for a way to SEARCH+REPLACE a string between two XML tags (see below), with a different string, using DOS BATCH.

Scenario: I have a .XML file (exported from TaskSched) that has the following lines:
Code: [Select] <UserId>COMPUTERNAME\USERNAME</UserId>Code: [Select] <Actions Context="Author">
<Exec>
<Command>D:\subfolder1\subfolder2\filename1.bat</Command>
<WorkingDirectory>D:\subfolder1\subfolder2</WorkingDirectory>
</Exec>
<Exec>
<Command>D:\subfolder1\subfolder2\filename2.bat</Command>
<WorkingDirectory>D:\subfolder1\subfolder2</WorkingDirectory>
</Exec>
</Actions>Of note, the following things need to be changed:
COMPUTERNAME\USERNAME with variable values contained in %COMPUTERNAME% and %USERNAME% ,
and the drive letter (in this case D ) to whatever the current drive letter is that the BATCH is executed from, for example C.You would be better off not using batch, because this is impossible in vanilla batch.Luigi, maybe you should restrict yourself to answering questions where you actually know something? Such an answer as that is 1. Unhelpful 2. Untrue. Using nothing but built-in batch commands, the task is easy.

1. Batch file

@echo off
setlocal enabledelayedexpansion
set driveletter=%~d0
echo Batch LOCATED on drive %driveletter%
echo Computer name %computername%
echo User name %username%
if exist output.xml DEL output.xml
for /f "delims=" %%A in (input.xml) do (
set thisline=%%A
set "newline=!thisline:COMPUTERNAME\USERNAME=%computername%\%username%!"
set "newline=!newline:D:\=%driveletter%\!"
echo Input !thisline!
echo Output !newline!
echo !newline! >> output.xml
echo.
)
echo Complete
Pause


2. Input.xml

<UserId>COMPUTERNAME\USERNAME</UserId>
<Actions Context="Author">
<Exec>
<Command>D:\subfolder1\subfolder2\filename1.bat</Command>
<WorkingDirectory>D:\subfolder1\subfolder2</WorkingDirectory>
</Exec>
<Exec>
<Command>D:\subfolder1\subfolder2\filename2.bat</Command>
<WorkingDirectory>D:\subfolder1\subfolder2</WorkingDirectory>
</Exec>
</Actions>

3. Output.xml

<UserId>PEGASUS\user901</UserId>
<Actions Context="Author
<Exec>
<Command>C:\subfolder1\subfolder2\filename1.bat</Command>
<WorkingDirectory>C:\subfolder1\subfolder2</WorkingDirectory>
</Exec>
<Exec>
<Command>C:\subfolder1\subfolder2\filename2.bat</Command>
<WorkingDirectory>C:\subfolder1\subfolder2</WorkingDirectory>
</Exec>
</Actions>

4. Batch console display

Batch located on drive C:
Computer name PEGASUS
User name user901
Input <UserId>COMPUTERNAME\USERNAME</UserId>
Output <UserId>PEGASUS\user901</UserId>

Input <Actions Context="Author">
Output <Actions Context="Author

Input <Exec>
Output <Exec>

Input <Command>D:\subfolder1\subfolder2\filename1.bat</Command>
Output <Command>C:\subfolder1\subfolder2\filename1.bat</Command>

Input <WorkingDirectory>D:\subfolder1\subfolder2</WorkingDirectory>
Output <WorkingDirectory>C:\subfolder1\subfolder2</WorkingDirectory>

Input </Exec>
Output </Exec>

Input <Exec>
Output <Exec>

Input <Command>D:\subfolder1\subfolder2\filename2.bat</Command>
Output <Command>C:\subfolder1\subfolder2\filename2.bat</Command>

Input <WorkingDirectory>D:\subfolder1\subfolder2</WorkingDirectory>
Output <WorkingDirectory>C:\subfolder1\subfolder2</WorkingDirectory>

Input </Exec>
Output </Exec>

Input </Actions>
Output </Actions>

Complete
Press any key to continue . . .Quote from: Luigi master on June 28, 2016, 10:06:42 AM

You would be better off not using batch, because this is impossible in vanilla batch.

Your Posts will now be moderated from here out before they show up here...

patio.Luigi Master is a 16 year old gal, it seems. It's nice to see gals doing batch stuff but you need to read a bit more widely Luigi Master, to learn a bit more about this and that. You didn't make a typo about your gender there, did you?


PENchaotic, is COMPUTERNAME\USERNAME actual literal text, or someone's details?

Quote from: PENchaotic on June 28, 2016, 09:32:33 AM
Scenario: I have a .XML file (exported from TaskSched) that has the following lines:
Code: [Select] <UserId>COMPUTERNAME\USERNAME</UserId>

The line can be recreated completely in either case, and I'm only commenting that it may be variable text.Age nor gender have any bearing...seeing innaccurate advice over time is the deciding factor...I trawled through his, erm I mean her, posts before commenting, patio: I know exactly what you mean.

My waffle wasn't meant to question any decisions - I'll avoid commenting in response to forum matters, as I should have done here.

I wasn't sure how to phrase my point that Luigi didn't seem to be a gal. MEA culpa.
Luigi is a boy's name, and 'master' is a male title.
5709.

Solve : Batch file to copy, rename and organize files from a CD to a HD?

Answer» HELLO everybody,

My name is Antoine, I'm new on this forum. I'm trying to DEVELOP the following batch file :

My point : As a private pilot, I get every month a CD-ROM with updated information in PDF format (approach plates, rules, airport information, etc.), spread in various files and directories.

The way these data are organized and named on that CD doesn't totally fit my needs, thus I would like to automatically transfer chosen data from the CD-ROM to my HD (E:\) in dedicated directories and with a completed name.

For instance, airport visual approach plate files are identified on the CD-ROM with a long name containing amongst others the 4 letters of airport's ICAO name (eg LSZH). I would like the file's name to be automatically completed with the city name (eg ZURICH LSZH).
Airports LIST is finished and I would fill up a conversion table for the name completion, either inside the batch file, or ideally in a separate text file.
Depending on the PDF's file name, one can also find out what kind of information it contains and therefore in which directory to transfer it. For instance, visual approach charts PDFs name contain also the word "VAC", and I would transfer such files into a VAC folder on my HD.

Currently I'm doing this job manually, but it's typically something that could (and should) be automated.
I have very little experience with batch files, and didn't find out so far how to do it, especially check and modify long file names and how to create/work with a conversion table.


How would you proceed to create such a batch file ? Is there a way doing it, or should I TURN towards another language ? Would anybody be nice enough to help me ?

Thanks a lot in advance.
Best regards

Antoine

My system : windows 7 64
How many places did you ask this question?

I've seen two... and I don't want to waste my time if some people are doing work on your behalf in another forum.2 places only, yet...This point has been solved by foxidrive in another forum.
For those who are interested in the solution, it's over there.

A real big thank you to foxidrive for his very efficient support, and all my appologizes for any inconvenience - the goal was not to draw competition between fora...

Best regards
Antoine
5710.

Solve : Batch file to check multiple folders, if the folders it's checking has certain..?

Answer»

I want a batch file to check a lot of folder and check their sub folders for certain names. I am creating a Garry's Mod FastDL generator where the batch file has to check every addon (multiple folders) and check their subfolders, if they have the subfolders of the name "materials, models, sounds, SCRIPTS or particles", then it should copy it to a specific output folder, if it has any other folder, it shall NOT copy it over. This might sound confusing but if you read it carefully, you'll understand.And what have you started with so far ? ?I created a batch for Unreal Tournament 99, years ago that went in and added textures, sounds, maps, and all that. Not your specific game, but similar functionality.

You should be ABLE to just IF EXIST at a specific target locations and then if it exists dont xcopy and if it doesnt exist then xcopy the contents from your MEDIA to the drive at the specific target location.

Testing If a Drive or Directory Exists from a Batch File
https://support.microsoft.com/en-us/kb/65994

Quote from: JacobGunther12 on June 24, 2016, 03:10:49 PM

if they have the subfolders of the name "materials, models, sounds, scripts or particles", then it should copy it to a specific output folder

This is not tested:

Code: [Select]@echo off
for %%a in (
materials
models
sounds
scripts
particles
) do for /d /R "d:\base\folder" %%b in (*) do if /i "%%~nxb"=="%%a" robocopy "%%b" "c:\output folder\%%a" /mir
pause
or you know
Code: [Select]xcopy materials/* outputfolder/
xcopy models/* outputfolder/
xcopy sounds/* outputfolder/
xcopy scripts/* outputfolder/
xcopy particles/* outputfolder/
Quote from: Luigi master on June 27, 2016, 07:59:02 PM
or you know
Code: [Select]xcopy materials/* outputfolder/
xcopy models/* outputfolder/
xcopy sounds/* outputfolder/
xcopy scripts/* outputfolder/
xcopy particles/* outputfolder/

How does your script determine where those folders are in the tree of folders?
The OP is probably handing in his assignment as we SPEAK anyway.
Oh, okay.
5711.

Solve : Drive A error. System Halt?

Answer»

Hi. My father very recently bult himself a new computer and asked me to help him get it running, but when i turn it on i get the following lines
"Bios Rom Checksum Error
Detecting floppy drive A media....
Drive A error. System halt."

Any ideas as to how i might go about FIXING this would be much APPRECIATED. ThanksCode: [SELECT]@echo off
echo unplug the floppy dive and see if the error message goes away
echo - maybe the cable has been put in 180 degrees the wrong way.Seems to be lots of information on the web about this with a SIMPLE google search.
If you can get into the BIOS make sure the floppy is not the 1st boot device. It shouldn't make a difference if there is no disk in there but maybe things have CHANGED over the years.

Other posts say this is a memory issue or memory timing issue. The bios is losing its settings which could be a battery issue. The list goes on and on.

5712.

Solve : Need a Batchscript that will check the version of a file-and Uninstall if exist?

Answer»

Basically i need a batch script that will first check if a particular file version exists., And if it does, it will uninstall it. If it does'nt exist, than it will do nothing and exit.

in this case its the file named "BmaSearch.exe"




Here is a work in progress script that i put together. I just need help with the check version PART of it.


"@echo off

REM check if BARRACUDA Add-In is already installed
if exist "C:\Program Files (x86)\Barracuda\Message Archiver\Outlook Add-In\BmaSearch.exe" (
GOTO UNINSTALL
) else (

if exist "C:\Program Files\Barracuda\Message Archiver\Outlook Add-In\BmaSearch.exe" (
GOTO UNINSTALL
))




:UNINSTALL

REM UINSTALL ADDON
echo UnInstalling
msiexec /x \\qpaynet.local\sysvol\QpayNet.local\Policies\{B7D55D1D-7D20-46EB-92F9-FEB42BABC41E}\Machine\Applications\BmaOutlookAddIn-3.6.20.0_x86.msi /quiet

exit"


Please help

thanksNot seeing what you need help with. The syntax of all your commands look correct.@echo off

REM check if Barracuda Add-In is already installed
if exist "C:\Program Files (x86)\Barracuda\Message Archiver\Outlook Add-In\BmaSearch.exe" (
GOTO UNINSTALL
) else (

if exist "C:\Program Files\Barracuda\Message Archiver\Outlook Add-In\BmaSearch.exe" (
GOTO UNINSTALL
)}

EXIT
REM EXIT or else you will go to UNINSTALL whether or not the file exists!

:UNINSTALL

REM UINSTALL ADDON
echo UnInstalling
msiexec /x \\qpaynet.local\sysvol\QpayNet.local\Policies\{B7D55D1D-7D20-46EB-92F9-FEB42BABC41E}\Machine\Applications\BmaOutlookAddIn-3.6.20.0_x86.msi /quiet

REM You don't need this
REM exit

You could do it in 5 lines of code:

@echo off
set installed=NO
if exist "C:\Program Files (x86)\Barracuda\Message Archiver\Outlook Add-In\BmaSearch.exe" set installed=YES
if exist "C:\Program Files\Barracuda\Message Archiver\Outlook Add-In\BmaSearch.exe" set installed=YES
if %installed%=YES echo UnInstalling & msiexec /x \\qpaynet.local\sysvol\QpayNet.local\Policies\{B7D55D1D-7D20-46EB-92F9-FEB42BABC41E}\Machine\Applications\BmaOutlookAddIn-3.6.20.0_x86.msi /quiet
are you guys not reading the subject of this thread?


i clearly stated that i am looking for a way to have the script CHECK THE VERSION OF THE BMASEARCH.EXE file and depending at if it matches 3.6.20.0 then uninstall.

what i have there in the script so far is simply uninstall if the .exe exists period. This is not what i want it to do. so please

is there any way to set a condition where it will check the version of the file???Quote from: jblanc03 on September 29, 2015, 07:16:21 AM

are you guys not reading the subject of this thread?
We apologise for the poor service. You can claim a full refund of your joining fee, and also of the fee you paid for asking your question. Please have your payment reference number ready when making the claim.
nvm

You can use powershell to get the version.

Code: [Select]D:\>for /f "delims=" %%p in ('powershell -Command "(Get-Item C:\Program Files (x86)\Barracuda\Message Archiver\Outlook Add-In\BmaSearch.exe).VersionInfo.ProductVersion"') do set version=%%p

the Product Version of the executable will be saved in %version% and you can compare it.
Or WMIC
Code: [Select]for /f "tokens=2 delims=," %%G in ('wmic datafile where "Name='C:\\Windows\\System32\\cmd.exe'" get Version /format:csv') do set cmdver=%%GThis assumes the executable was compiled with version information. Quote from: Salmon Trout on September 29, 2015, 11:58:56 AM
This assumes the executable was compiled with version information.
Well the information provided has been so clear on how we should solve this problem. We are all just grasping at straws. Not sure where else we would get the version information of the install. I guess it could be in the registry but I do not have this program installed to check if that is the case or not.Quote from: Squashman on September 29, 2015, 12:04:27 PM
I guess it could be in the registry but I do not have this program installed to check if that is the case or not.
This is one of the (considerable) stumbling blocks in our path.
Quote from: Squashman on September 29, 2015, 12:04:27 PM
I do not have this program installed to check if that is the case or not.
I would be surprised if you did. Barracuda Message Archivers are a range of hardware appliances that sit on a corporate network and cost $2,000 for the Model 150 (max 150 users) via the Model 450 $10,000 dollars (max 1,000 users) to the model 1050 "request a quote" (max 18,000 users). All models require a mandatory yearly update subscription costing between hundreds and tens of thousands of dollars. So not home stuff. The Outlook add-in needs to have the same major version number as the appliance firmware. I am not an expert, but it seems from a cursory look at the maker's help pages that users with a valid ongoing subscription should be able to get help to keep their deployed software up to DATE. A big element of the publicity for these products is comprehensive security and suitability for use in situations where compliance with statutory or regulatory requirements is important. Audit trails. Pro stuff. So why is a "Barracuda Message Archiver Adminstrator" asking this on here? He was LIKELY promoted to a position he's ill suited for...Only thing worse than doing somebody's homework is doing their job...
5713.

Solve : Windows 98 is totally busted HELP?

Answer»

Ok so I'm just going to start out by saying I have a vast computer knowledge and even I can't figure this one out. Lets start from the beginning:
I'm using a Compaq Presario 1625 "running" Windows 98, but you will see why this is in dos section.
I have been searching on the internet for at least 6 months now but here is what happened
There was a time when I didn't know crap about computers and I made it impossible to boot the hard drive with a virus, so my dad helped me by booting from the compaq restore disk (which reinstalls windows 98) and poof it was good as new, but now it happened again and not from a virus, it just kind of happened, I booted up my laptop one day and nothing happened
it STAYED on the loading screen, i figured since it was old that it was running slow and left it for a few hours (6 to be exact) only to come back and see IT WAS STILL ON THE LOADING SCREEN.

so I shut down the computer and tried again repeatedly until giving up
I pulled out the good ol' restore disk and this is what happened when I tried to boot from CD-ROM drive. Made some internal beeps while at the same time desplaying about 15 ascii characters each time it beeped and then it stopped, I waited and held the enter key until it started beeping everytime i pushed the enter key, or in other words the computer crashed

now that was the end of it
I didn't know what to do?
now... about 3 years later (or 1 year ago) I formatted a FLOPPY disk with my windows xp and made it a boot disk, and for the heck of it i tried booting my windows 98 with it, too my suprise it worked

uh sort of, it actually booted to dos (not ms-dos, just a generic dos prompt) and when it was done loading it said windows millenium in the command line... so I honestly was baffeled and I have been using it to run dos programs, but I've trying to figure out what to do, I have no way to use the CD-ROM drive in dos i did try mscdex but it can't find the driver, my version doesn't support usb on the back of the laptop and I can't find the files on the internet for the windows 98 floppy disk installation files.

Basically I have two options
1:Someone provides me with (or internet location of) windows 98 installation floppy disk set
or
2:Some other way to fix that I am apearantly oblivious of.

Please help, I REALLY need this laptop to work, and I just don't want to spend 100's of $ to take it into a place like the Geek Squad.

If there is any more information you need please feel free to tell me in the comments and I will edit the post.Here is the maintenance/troubleshooting manual for that system:

http://h10032.www1.hp.com/ctg/Manual/c02007377.pdf

I'm not SURE how helpful it will be.

What happens, now, when you attempt to boot to the Hard Disk? If it does what it did before - seemingly stuck on the loading screen - is the HDD activity indicator constantly on?

Can you try safe mode? (press F8 repeatedly while the system is starting up and you should get a Set of options, one of which is Safe Mode)

if safe mode doesn't work, you can try Command Prompt Only (From the menu) From there you can run scandisk and perform a surface scan. (This will take a LOOONG time, so be prepared to wait.)

Quote

uh sort of, it actually booted to dos (not ms-dos, just a generic dos prompt) and when it was done loading it said windows millenium in the command line...
That was MS-DOS 8, the version of MS-DOS embedded into Windows ME, and Windows XP and later for some weird reason create a Windows ME Startup disk.

You can make the CD drive accessible from DOS by using the appropriate driver. CH has an article on that here. (Personally, I just use OAKCDROM.SYS).

If the OP has the original product key, he can use a copy of Windows 98 to bring his computer back up.

Find a Windows 98 boot floppy disk image of the same version as on the hard drive, create a floppy and use it on the laptop to boot to the command prompt.

Then type this command - if it breaks anything then you get to keep all the pieces and I will refund you what you have paid me for this random suggestion:

Code: [Select]sys a: c:
Quote from: BC_Programmer on March 20, 2015, 01:36:29 PM
Here is the maintenance/troubleshooting manual for that system:

http://h10032.www1.hp.com/ctg/Manual/c02007377.pdf

I'm not sure how helpful it will be.

What happens, now, when you attempt to boot to the Hard Disk? If it does what it did before - seemingly stuck on the loading screen - is the HDD activity indicator constantly on?

Can you try safe mode? (press F8 repeatedly while the system is starting up and you should get a Set of options, one of which is Safe Mode)

if safe mode doesn't work, you can try Command Prompt Only (From the menu) From there you can run scandisk and perform a surface scan. (This will take a LOOONG time, so be prepared to wait.)
That was MS-DOS 8, the version of MS-DOS embedded into Windows ME, and Windows XP and later for some weird reason create a Windows ME Startup disk.

You can make the CD drive accessible from DOS by using the appropriate driver. CH has an article on that here. (Personally, I just use OAKCDROM.SYS).

well when I boot to the hard disk, now it loads ms-dos 6.22 and windows 3.11 since I installed them
I have the manual and it's 0 help at all because it has nothing relevant in it.
safe mode isn't a thing, f8 for msdos 6.22 lets me pick which autoexec and config lines to execute
scan disk can not complete because some parts of my hard disk surface are so fragmented/broken that it freezes on one of the spots after 30 minutes of trying to fix it.
I don't have the atapi ide cd driver (and there is a chance the cd drive is busted)Quote from: Geek-9pm on March 20, 2015, 04:55:22 PM
If the OP has the original product key, he can use a copy of Windows 98 to bring his computer back up.

i have the product key, it's my laptop. And it can't do that because like I said the cd drive can't boot properly and besides the disk that came with my copy of win 98 was a restore disk and since I removed the win 98 files a long time ago that doesn't help much.Quote from: Magicrafter13 on April 10, 2015, 07:29:33 PM
well when I boot to the hard disk, now it loads ms-dos 6.22 and windows 3.11 since I installed them

These pieces of the puzzle weren't mentioned, nor the fact that the hard drive is about to die a violent death.

Quote
scan disk can not complete because some parts of my hard disk surface are so fragmented/broken that it freezes on one of the spots after 30 minutes of trying to fix it.
I don't have the atapi ide cd driver (and there is a chance the cd drive is busted)

I must have written my last reply in invisible ink - sorry about that. I confuse the bottles every now and then and wonder why nobody responds to my comments. Silly old bugga I am.

Ok, guys sorry I haven't replied or anything like that, but I did some of my own stuff blaw blaw win 3.1 win 95 (added CD support so that part is solved ) win 98 win 98 sec (_________________ anyway, I'm running but I would like the nostalgic feeling again of my actual experience w/the laptop, if anyone could point me in the direction of system.sav image for a Compaq Presario >>1625<< (obviously the win98 version) that would be amazing and thank you so much because I still have my QUICK restore disc and my serial key... just not the system.sav (Compaq did I dumb thing with having the reinstall as an image of the hard drive and since HP bought them... HP does it now too... Jesus Christ...)Quote from: foxidrive on April 10, 2015, 07:53:09 PM
These pieces of the puzzle weren't mentioned, nor the fact that the hard drive is about to die a violent death.

I must have written my last reply in invisible ink - sorry about that. I confuse the bottles every now and then and wonder why nobody responds to my comments. Silly old bugga I am.

sorry it didn't crash, I actually did that again recently and it turns out they are just some bad clusters (still surface damage though) and it took 4-5 hours (lol omg) but It finally finished and well... that's good I guess
5714.

Solve : Find file names that have a capital letter in them....?

Answer»

I see how you can IGNORE the case of the letter in the file NAME, but I actually want a list of all file names in a folder, that have a capital letter in them.

We have a subversion issue, where some of the developers have created all capital file extensions, first letter capital in the file name... and so on.

As opposed to clicking through 500 folders, (exaggeration) I was hoping there was a way to query this into a list.

Note: a simple file name change will only hurt at this point. I need to open each file and change the way the file name is saved in the form or report. Hence, the need for a list.


If this cannot be done on a command prompt, any suggestions would be much appreciated.

Thank you,
RyanDo you want just the file name & extension as output, or the full driveletter and path as well? The script snippet below shows how to get either.

contents of folder
Code: [Select]Capital1.txt
CAPITAL2.txt
caPital3.txt
capital4.TXT
capital5.Txt
capital6.TxT
lower1.txt
lower2.txt
lower3.txt
simple batch script showing how to pipe DIR output through findstr using regex

In case any aspiring regex wizards decide to query my code, the regular expression implementation in Windows Findstr behaves in a nonstandard way when processing alphabetic ranges e.g. [A-Z] which is why I have used the less compact [ABCDEFGHIJKLMNOPQRSTUVWXYZ].

Code: [Select]@echo off
SET folder="c:\Batch\Test\After 04-07-2012\findcapital"
for /f "delims=" %%A in ( ' dir /b %folder% ^| findstr /R "[ABCDEFGHIJKLMNOPQRSTUVWXYZ]" ' ) do (
echo full path %%~dpnxA
echo just name %%~nxA
echo.
)

Output:
Code: [Select]full path c:\Batch\Test\After 04-07-2012\findcapital\Capital1.txt
just name Capital1.txt

full path c:\Batch\Test\After 04-07-2012\findcapital\CAPITAL2.txt
just name CAPITAL2.txt

full path c:\Batch\Test\After 04-07-2012\findcapital\caPital3.txt
just name caPital3.txt

full path c:\Batch\Test\After 04-07-2012\findcapital\capital4.TXT
just name capital4.TXT

full path c:\Batch\Test\After 04-07-2012\findcapital\capital5.Txt
just name capital5.Txt

full path c:\Batch\Test\After 04-07-2012\findcapital\capital6.TxT
just name capital6.TxTI will have to look up those echo parameters so I understand more about the output. Either way, I like your idea.

Thank you for this, I will give it a shot right now.Quote from: YeeP on August 01, 2012, 02:42:47 PM

I will have to look up those echo parameters so I understand more about the output.

if %%A is a file name %%~dA is the drive, %%~pA is the path, %%~nA is the bare name and %%~xA is the extension. You can combine them so %%~dpnxA is the whole drive letter, path and name.
5715.

Solve : More for loop troubles?

Answer»

So I was writing a game for fun, and I ran into a for loop problem where it isn't saving %%G into a veriable that I can call. Nor is it reading the full file. Any Idea's?

cities\Buy.bat
Code: [Select]:: %gotoc% = Tipa
:: %vender% = Paxto
setlocal EnableDelayedExpantion


:start
cls
cd %gotoc%\%vender%

for /f %%G in (stock.cur) do (
set vender.item.G=%%G
cd ..
cd ..
cd ..
cd Products
cd %%G
for /f %%G in (Cities.cur) do (
if %%G EQU %gotoc% goto ok
)
Echo ERROR
pause >nul
exit
:ok
for /f "tokens=2 delims==" %%G in ('findstr "%gotoc%" Value.cur') do (
set value=%%G
)
cd %~pd0\%gotoc%\%vender%
echo !vender.item.G!=!value! >>vender.tmp
echo !vender.item.G!
)

echo.
echo Which Item Would You like to Purchase
set /p item=
if %item% EQU "BACK" goto back.to.city

....
cities\Tipa\Paxto\stock.cur
Code: [Select]Fish
Sugar
Products\Fish\Cities.cur
Code: [Select]Tipa
Alexandria
Bastion
Jui
Products\Fish\Value.cur
Code: [Select]Tipa=1
Alexandria=3
Bastion=9
Jui=1

All I'm getting is:
Code: [Select]!vender.item.G!

Which Item Would You like to Purchase


** The .cur files are being treated like .txt
(wrote the files in notepad and used 'rename *.txt *.cur' in cmd)Quote

Expantion

That's not how you spell 'expansion' ...



There is ALSO an issue where %%G is the outer loop VARIABLE and you are reusing %%G in the inner loops. It's wiser to use %%H %%J %%K etc in the inner loops.There is yet another issue: you can't have labels inside loops. As far as the command interpreter is concerned, the INTERIOR of a loop is one long line, and you cannot have a label in a line of code. This is one good reason why the undocumented, unsupported practice of using a double colon to start comment lines is frowned upon. It will break a loop.

And 'vendor' has only one 'e'.




5716.

Solve : problem cmd Run as Administrator?

Answer»

I run cmd as ADMINISTRATOR and then i run my tool , working just fine for 3 weeks but like 3 days ago it doesn't WORK anymore MAYBE one of remote administrators changed soemthing i don't know but when i run my tool i receive: Access is denied.

C:\Windows\system32>cd C:\Users\Admini\Desktop\mytool

C:\Users\Adimini\Desktop\mytool>mytool -V -t 4 -w 30 -l Administrator -P
pass.txt -e nsr -o good.txt -f 5.2.236.64 rdp
Access is denied.Quote from: crokos090 on October 02, 2015, 01:27:51 AM

but when i run my tool i receive: Access is denied.

The error message indicates that you don't have permission to access the resource you are trying to use.

i have administrators and all rights , how can i change that ? any solution for this? must exist a solutionNobody knows what you are really doing and the situation it is being used in.i can give you my messenger or better team VIEWER to take a lookWe do not do TeamViewer here for obvious reasons...

You need to contact the System Administrators on your end to get this resolved...nothing we can do for you here.I AM SYSTEM ADMINISTRATOR BOSSSScmd run as administrator , path tool.exe blah blah.... *censored* ENTER --- > ACCES denied Topic Closed.

patio.
5717.

Solve : If Statement Strange Results?

Answer»

Thank you all in advance for any help you can offer.

If a condition of an IF STATEMENT is true, I want to execute some statements. What I found very puzzling is when the condition is true, it apppears the statements inside the IF statement are read thru and executed but the prompt statement does not get the USER input data. If I remove the IF condition check, then the statements are executed and the prompt statement gets the user input data.

Is there any way I can execute the statements inside an IF statement and gets the input data?

Here are the 2 scripts, ONE with the IF statement and the other one without. I turned the echo on so I can see what's running behind the scene.

If condition is true:
@echo on
set x=29
if /i %x%==29 (
set QN=
echo qn=%qn%=
set /p qn=Enter qn:
echo qn=%qn%=
)

Results:
set x=29
if /I 29 == 29 (
set qn=
echo qn==
set /p qn=Enter qn:
echo qn==
)
qn==
Enter qn:abc
qn==

No IF clause:
@echo on
set x=29
set qn=
echo qn=%qn%=
set /p qn=Enter qn:
echo qn=%qn%=

Results:
set x=29
set qn=
echo qn==
qn==
set /p qn=Enter qn:
Enter qn:abc
echo qn=abc=
qn=abc=
You are inside a code block. You need to use delayed expansion.Thank you very much! That solved my problem.

5718.

Solve : Unable to Rename Copied Files via Windows Command Line?

Answer»

I am trying to create a .BAT script that will read a list of file locations from a CSV (in column 1) and then find that file in a directory and COPY it to a new folder giving it the name specified in column 2 of the CSV file.

The CSV looks like:

U:\source\OHSVols180\A100\B100\C107\F109.DOC,file1
U:\source\OHSVols180\A100\B100\C110\F152.PDF,file2

The .BAT file below currently works in that it accesses the CSV field 1 and copies the file to the new folder. My question is how do I manage to also rename the copied file as per column 2 in the CSV? It can keep the same file extension as previously listed in column 1. At the moment he files are NAMED as ORIGINALLY F109.DOC and F152.PDF but I want them to be called file1.DOC and file2.PDF.

Code: [Select]for /f "tokens=1 delims=," %%L in (U:\ExportList.csv) do copy "%%L" U:\Exported\
Any help greatly appreciated. Not sure how to REFERENCE the second part of the CSV and what code to put to rename the file.Have found the answer below!

Code: [Select]for /f "tokens=1,2 delims=," %%L in (U:\ExportList.csv) do copy "%%L" "U:\Exported\%%M%%~xL"

5719.

Solve : Shortcut with folder name?

Answer»

Perhaps you don't realise that every time you do a cd.. command, the current directory changes?
Quote from: ira on OCTOBER 13, 2015, 10:32:42 AM

Naming the shortcut is not the problem. It is where it puts the shortcut. I have TRIED using you formula but I just cant seem to get a shortcut in the current directory. Below is my directory structure

D:\Users\tertom01\Desktop\BatchFiles\6568\dwg cont\working
this is where I want my shortcut deposited.

D:\Users\tertom01\Desktop\BatchFiles\6568\Drawings-Uncontrolled\Ref
this is the shortcut link address

thanx


So why don't you specify where you want the shortcut to be created?

e.g. D:\Users\tertom01\Desktop\BatchFiles\mkshortcut /target:"%cd%" /shortcut:"D:\Users\tertom01\Desktop\BatchFiles\6568\dwg cont\working\Ref"

This will create a link in the folder "D:\Users\tertom01\Desktop\BatchFiles\6568\dwg cont\working".

The link will be called "Ref.lnk"

The link will point to whatever folder %cd% is at the time the BATCH script is run.

Finally figured it out. See below. Believe it or not I thought about this for hours. But I find my self starting to understand how variables and such thing WORK. thanks again for you time SALMON Trout.

@echo off
cls
set a=%cd%
cd ..\
cd ..\
mkdir "Drawings-Uncontrolled\Ref"
CD "Drawings-Uncontrolled\Ref"
for %%A in (".") do set b=%%~nA
D:\Users\tertom01\Desktop\BatchFiles\mkshortcut /target:"%cd%" /shortcut:"%a%\%b%"

5720.

Solve : If Exists, If Not Exists?

Answer»

I Have a NEED to write a batch file (executed via SQL job STEP) to VERIFY if a file in a folder is present. If so it would move the file to a archive folder. I'd need to also include If Not Exists, so that if there isn't a file to exit.

IF Exist c:\temp move K:\SQL_Backup\HR83CPY\*.* K:\SQL_Backup\HR83CPY\Archive_Backup\
IF File does not exist K:\SQL_Backup\HR83CPY
Exit

Appreciate some guidanceYour description of your task is not reflective of what your code looks like.

You are basically testing if the folder C:\TEMP exists and if it does then move all the FILES in a completely DIFFERENT folder to another folder.
But what I think you want is this.
Code: [Select]IF NOT EXIST "K:\SQL_Backup\HR83CPY\*.*" Exit
IF EXIST "K:\SQL_Backup\HR83CPY\*.*" move "K:\SQL_Backup\HR83CPY\*.*" "K:\SQL_Backup\HR83CPY\Archive_Backup\"
If this is not what you want then you will need to provide a more detailed explanation with examples.
Thanks for your suggestion. I think you have what I was looking for and will give it a try out.

5721.

Solve : Bat script to detect if a file .jpg finish downloading?

Answer»

I have a software under windows 7 that automatically check EVERY 3 seconds if
my digital camera have new images taken if it found it this software automatically
download the last PICTURE from my camera and put under a hotfolder.

I make a script that every 3 seconds automatically check if a new image is found
inside this hotfolder, copy this image to another folder and delete the hotfolder
image to keep the hotfolder always empty.

Everything is running fine but when my script runs at the same time when the other
software are copying the image from my camera the resulting copied file is incomplete.

I was looking for a piece of script that i can ADD to my .bat file that check if the image
(*.jpg) file inside the hotfolder is complete and then copy the file from the hotfolder
to another

Thanks in ADVANCE for your advice !
http://stackoverflow.com/questions/10518151/how-to-check-in-command-line-if-a-given-file-or-directory-is-locked-used-by-any/10520609#10520609Another option is to check the file size and see if it changes.
http://www.robvanderwoude.com/type.php#ShowSize

5722.

Solve : What is the Sort Order in DOS??

Answer»

I know I can sort a list with the SORT command. By I do not understand the sort order. Some characters that are late in the ASCII table show up early in the sort list Where is the order explained?
Do you mean actual MS-DOS/PC-DOS, or are you referring to Windows Command PROMPT?

On Windows the sort order is based on the current system LOCALE. you can use the /l switch to change the system locale.

I'd expect MS-DOS may sort based on ASCII, since I don't think it has any locale information aside from code pagesI am using the SORT command at the command prompt.You should also realize that it does not sort numerically.Quote from: Geek-9pm on October 14, 2015, 04:33:50 PM

I am using the SORT command at the command prompt.

But in which? MSDOS or Win9x or XP etc?OK. I was using the SORT in Windows XP.
What happens is the last things in the ASCII table, the symbols after 'z', end up early in the character set sort. I am in the USA.
Here are last items in the 127 ASCII set:
Quote
x
y
z
{
|
}
~
The four symbols are move up in the sort. Just ahead of the + sign.
Quote
{
|
}
~
+
<
=
>
0
1
2
Far future reference, Is there some place where on can find the sort used by a system in a specific locale?
By default sort.exe sorts according the system locale. You can over ride this by using the /L [locale] switch. Currently the only locale available is the C locale which results in sorting being in binary order.

1. The test file

C:\>type test1.txt
x
y
z
{
|
}
~

2. Sort using default order

C:\>type test1.txt | sort
{
|
}
~
x
y
z

3. Sort using C locale

C:\>type test1.txt | sort /L C
x
y
z
{
|
}
~


Operating system locale charts

IBM i5/OS
Fedora core 6
FreeBSD 5.4
HP-UX 11
SCO OpenServer 6.0.0
SGI IRIX 6.5
SUN OpenSolaris 2008.05
SUN Solaris 10 Sparc
SUN Solaris 10 x86
Windows 2000
Windows XP
Windows Vista

http://collation-charts.org/

Thanks for that link. I will ADD it to my collection.
That link explains that some changes were as recent as 2007, 2009 and 2010. The changes affect both Unicode and SQL.

Interesting to learn that there have been recently altered rules.

5723.

Solve : rename 2 variables on one line with 2 spinners?

Answer»

im trying to make a batch video game for a school project, I was wonder

I'm trying to figure out if it is possible to rename two variables on the same line individually at separate times when called from a goto command from two different spinners. each health ("-------") Is an individual variable that is renamed.

I have a 2 health bars that appear as this.

╔══════╗ | ╔══════╗
health ║ ------- ║ | health ║ ------- ║
╚══════╝ | ╚══════╝

the middle will slowly decrease each time its set through a spinner.
for example...

"-------" will become "------", then "-----", then "----", "---", and so on...

the problem that i am having is that each health bat has its own spinner and i cant figure out how to decrease the health bar by one "-" at a time
when each health status ("-------") has its own variable and is set on the same line attached to that spinner.
another example...

I can make

╔══════╗ | ╔══════╗
health ║ ------- ║ | health ║ ------- ║
╚══════╝ | ╚══════╝

do this

╔══════╗ | ╔══════╗
health ║ ------- ║ | health ║ ---- ║
╚══════╝ | ╚══════╝

but when each spinner is set off and i want to do this.


1 2
╔══════╗ | ╔══════╗
health ║ --- ║ | health ║ --- ║
╚══════╝ | ╚══════╝

the health bar 1 cant save the health when i want the other to decrease by another "-".

I set the whole box on one line using this trick

set nl=^& echo.
echo line1%nl%line2%nl%line3%nl% so on~

the code below line vvvvvvvvvvvvvvvvv

(THE LONG LINE OF CODE WAS TO MUCH TO FIT ON THE BOX BUT THOSE ARE THE HEALTH BARS, IT BUMBED IT SELF ON A NEW LINE BECAUSE IT
NEEDS MORE ROOM TO FIT IN THIS BOX, PASTE IT INTO NOTEPAD AND HIT BACKSPACE TO PUT IT BACK ON THE SAME LINE)... the line looks something like this (" echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»%nl%º ")


-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

@echo on
:START
title Julius Caesar project [JacobgGilbert]
COLOR 17
set nl=^& echo.
set resultA=-------
set resultH=-------
if exist C:\JS\ goto packageskip
start extractmedia.exe
echo Prepairing files
timeout /t 35
:packageskip
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
echo º Julius Caesar by Jacob Gilbertº
echo ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
echo/
echo Picking player at random to go on the first turn.
SET /A ht=%random% %% 6
pause

if %ht%==1 goto player1
if %ht%==2 goto player1
if %ht%==3 goto player1
if %ht%==4 goto player2
if %ht%==5 goto player2
if %ht%==6 goto player2

pause


:player1
cls
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»%nl%º º%nl%º Player (Caesar) ^| Player (Brutus) º%nl%º ^| º%nl%º ÉÍÍÍÍÍÍÍ» ^| ÉÍÍÍÍÍÍÍ» º%nl%º Health º%resultA%º ^| Health º%resultH%º º%nl%º ÈÍÍÍÍÍÍͼ ^| ÈÍÍÍÍÍÍͼ º%nl%º º%nl%ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ%nl%
echo (Caesar) plays first...
echo.
:commandsp1
echo Commands:%nl%1 - attack %nl%2 - block%nl%3 - sharpen sword
set /p command1= "~Command:"
pause
if %command1%==1 goto attackp1
if %command1%==2 goto blockp2
if %command1%==3 goto sharpen_swordp3

:attackp1
SET /A missrange=%random% %% 10
if %missrange%==1 goto miss1
if %missrange%==2 goto worked1
if %missrange%==3 goto miss1
if %missrange%==4 goto worked1
if %missrange%==5 goto miss1
if %missrange%==6 goto worked1
if %missrange%==7 goto miss1
if %missrange%==8 goto worked1
if %missrange%==9 goto miss1
if %missrange%==10 goto worked1

:miss1
echo Sorry your attack missed.
pause
cls
goto jumpp2
:worked1
echo Recieved Damage!
pause
cls

::================================================================
:spinner1
SETLOCAL ENABLEDELAYEDEXPANSION
SET COUNTP1=1

:BEGINCOUNTP1
CLS
SET /A COUNTP1+=1
IF !COUNTP1! EQU 1 goto count1p1
IF !COUNTP1! EQU 2 goto count2p1
IF !COUNTP1! EQU 3 goto count3p1
IF !COUNTP1! EQU 4 goto count4p1
IF !COUNTP1! EQU 5 goto count5p1
IF !COUNTP1! EQU 6 goto count6p1
IF !COUNTP1! EQU 7 goto count7p1
IF !COUNTP1! EQU 7 (
SET COUNTP1=1
) ELSE (

)
GOTO BEGINCOUNTP1


:count1p1
set resultA=-------
set resultI=------
set modified=%resultI:resultH=------
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»%nl%º º%nl%º Player (Caesar) ^| Player (Brutus) º%nl%º ^| º%nl%º ÉÍÍÍÍÍÍÍ» ^| ÉÍÍÍÍÍÍÍ» º%nl%º Health º%resultA%º ^| Health º%resultH%º º%nl%º ÈÍÍÍÍÍÍͼ ^| ÈÍÍÍÍÍÍͼ º%nl%º º%nl%ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ%nl%
goto commandsp1

:count2p1
set result1=------
set modified=%result1:resultH=------
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»%nl%º º%nl%º Player (Caesar) ^| Player (Brutus) º%nl%º ^| º%nl%º ÉÍÍÍÍÍÍÍ» ^| ÉÍÍÍÍÍÍÍ» º%nl%º Health º%resultB%º ^| Health º%resultI%º º%nl%º ÈÍÍÍÍÍÍͼ ^| ÈÍÍÍÍÍÍͼ º%nl%º º%nl%ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ%nl%
goto commandsp1
pause

:count3p1
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»%nl%º º%nl%º Player (Caesar) ^| Player (Brutus) º%nl%º ^| º%nl%º ÉÍÍÍÍÍÍÍ» ^| ÉÍÍÍÍÍÍÍ» º%nl%º Health º%resultC%º ^| Health º%resultJ%º º%nl%º ÈÍÍÍÍÍÍͼ ^| ÈÍÍÍÍÍÍͼ º%nl%º º%nl%ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ%nl%
goto commandsp1
pause

:count4p1
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»%nl%º º%nl%º Player (Caesar) ^| Player (Brutus) º%nl%º ^| º%nl%º ÉÍÍÍÍÍÍÍ» ^| ÉÍÍÍÍÍÍÍ» º%nl%º Health º%resultD%º ^| Health º%resultK%º º%nl%º ÈÍÍÍÍÍÍͼ ^| ÈÍÍÍÍÍÍͼ º%nl%º º%nl%ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ%nl%
goto commandsp1
pause

:count5p1
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»%nl%º º%nl%º Player (Caesar) ^| Player (Brutus) º%nl%º ^| º%nl%º ÉÍÍÍÍÍÍÍ» ^| ÉÍÍÍÍÍÍÍ» º%nl%º Health º%resultE%º ^| Health º%resultL%º º%nl%º ÈÍÍÍÍÍÍͼ ^| ÈÍÍÍÍÍÍͼ º%nl%º º%nl%ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ%nl%
goto commandsp1
pause

:count6p1
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»%nl%º º%nl%º Player (Caesar) ^| Player (Brutus) º%nl%º ^| º%nl%º ÉÍÍÍÍÍÍÍ» ^| ÉÍÍÍÍÍÍÍ» º%nl%º Health º%resultF%º ^| Health º%resultM%º º%nl%º ÈÍÍÍÍÍÍͼ ^| ÈÍÍÍÍÍÍͼ º%nl%º º%nl%ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ%nl%
goto commandsp1
pause

:count7p1
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»%nl%º º%nl%º Player (Caesar) ^| Player (Brutus) º%nl%º ^| º%nl%º ÉÍÍÍÍÍÍÍ» ^| ÉÍÍÍÍÍÍÍ» º%nl%º Health º WIN! º ^| Health º LOSE! º º%nl%º ÈÍÍÍÍÍÍͼ ^| ÈÍÍÍÍÍÍͼ º%nl%º º%nl%ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ%nl%
echo CAESAR IS THE WINNER!!!!
pause
goto start
::================================================================

:player2
cls
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»%nl%º º%nl%º Player (Caesar) ^| Player (Brutus) º%nl%º ^| º%nl%º ÉÍÍÍÍÍÍÍ» ^| ÉÍÍÍÍÍÍÍ» º%nl%º Health º-------º ^| Health º-------º º%nl%º ÈÍÍÍÍÍÍͼ ^| ÈÍÍÍÍÍÍͼ º%nl%º º%nl%ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ%nl%
echo (Brutus) plays first...
echo.
:commandsp2
echo Commands:%nl%1 - attack %nl%2 - block%nl%3 - sharpen sword
set /p command= "~Command:"
pause
if %command%==1 goto attackp4
if %command%==2 goto blockp5
if %command%==3 goto sharpen_swordp6


:attackp4
SET /A missrange=%random% %% 10
if %missrange%==1 goto miss2
if %missrange%==2 goto worked2
if %missrange%==3 goto miss2
if %missrange%==4 goto worked2
if %missrange%==5 goto miss2
if %missrange%==6 goto worked2
if %missrange%==7 goto miss2
if %missrange%==8 goto worked2
if %missrange%==9 goto miss2
if %missrange%==10 goto worked2

:miss2
echo Sorry your attack missed.
pause
cls
goto returnp2
:worked2
echo Recieved Damage!
pause
cls

::================================================================
:spinner1
SETLOCAL ENABLEDELAYEDEXPANSION
SET COUNTP2=1

:BEGINCOUNTP2
CLS
IF !COUNTP2! EQU 1 goto count1p2
IF !COUNTP2! EQU 2 goto count2p2
IF !COUNTP2! EQU 3 goto count3p2
IF !COUNTP2! EQU 4 goto count4p2
IF !COUNTP2! EQU 5 goto count5p2
IF !COUNTP2! EQU 6 goto count6p2
IF !COUNTP2! EQU 7 goto count7p2
IF !COUNTP2! EQU 7 (
SET COUN2=1
) ELSE (
SET /A COUNT2+=1
)
GOTO BEGINCOUNTP2


:count1p2
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»%nl%º º%nl%º Player (Caesar) ^| Player (Brutus) º%nl%º ^| º%nl%º ÉÍÍÍÍÍÍÍ» ^| ÉÍÍÍÍÍÍÍ» º%nl%º Health ºresultAº ^| Health ºresultDº º%nl%º ÈÍÍÍÍÍÍͼ ^| ÈÍÍÍÍÍÍͼ º%nl%º º%nl%ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ%nl%

pause

:count2p2
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»%nl%º º%nl%º Player (Caesar) ^| Player (Brutus) º%nl%º ^| º%nl%º ÉÍÍÍÍÍÍÍ» ^| ÉÍÍÍÍÍÍÍ» º%nl%º Health º-------º ^| Health º----- º º%nl%º ÈÍÍÍÍÍÍͼ ^| ÈÍÍÍÍÍÍͼ º%nl%º º%nl%ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ%nl%
echo 2
pause

:count3p2
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»%nl%º º%nl%º Player (Caesar) ^| Player (Brutus) º%nl%º ^| º%nl%º ÉÍÍÍÍÍÍÍ» ^| ÉÍÍÍÍÍÍÍ» º%nl%º Health º-------º ^| Health º---- º º%nl%º ÈÍÍÍÍÍÍͼ ^| ÈÍÍÍÍÍÍͼ º%nl%º º%nl%ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ%nl%
pause

:count4p2
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»%nl%º º%nl%º Player (Caesar) ^| Player (Brutus) º%nl%º ^| º%nl%º ÉÍÍÍÍÍÍÍ» ^| ÉÍÍÍÍÍÍÍ» º%nl%º Health º-------º ^| Health º--- º º%nl%º ÈÍÍÍÍÍÍͼ ^| ÈÍÍÍÍÍÍͼ º%nl%º º%nl%ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ%nl%
pause

:count5p2
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»%nl%º º%nl%º Player (Caesar) ^| Player (Brutus) º%nl%º ^| º%nl%º ÉÍÍÍÍÍÍÍ» ^| ÉÍÍÍÍÍÍÍ» º%nl%º Health º-------º ^| Health º-- º º%nl%º ÈÍÍÍÍÍÍͼ ^| ÈÍÍÍÍÍÍͼ º%nl%º º%nl%ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ%nl%
pause

:count6p2
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»%nl%º º%nl%º Player (Caesar) ^| Player (Brutus) º%nl%º ^| º%nl%º ÉÍÍÍÍÍÍÍ» ^| ÉÍÍÍÍÍÍÍ» º%nl%º Health º-------º ^| Health º- º º%nl%º ÈÍÍÍÍÍÍͼ ^| ÈÍÍÍÍÍÍͼ º%nl%º º%nl%ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ%nl%
pause

:count7p2
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»%nl%º º%nl%º Player (Caesar) ^| Player (Brutus) º%nl%º ^| º%nl%º ÉÍÍÍÍÍÍÍ» ^| ÉÍÍÍÍÍÍÍ» º%nl%º Health º WIN! º ^| Health º LOSE! º º%nl%º ÈÍÍÍÍÍÍͼ ^| ÈÍÍÍÍÍÍͼ º%nl%º º%nl%ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ%nl%
pause
::================================================================


-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Thank you guys for the help i added in Echo's with character so that you know where the spinner lands you because i am also finding that the spinner keeps mistaking
that location :count1p1 is :count1p2 when i set SET /A COUNT2+=1 under )ELSE( inside the spinners. could anyone just help me with the whole solution, im not EVEN close to being done but i've worked forever trying to figure this out. Im only 17 so and this is due next monday so i need help asap... thank you
the bottom spinner hasnt been tested but ive realized that if i wanted to change one bar's health it would be difficult without affecting the other when i call back from the spinnerthe block and sharpen sword options hasn't been added yet, if anyone one would like to help on that too i would be very thankful for everything
dang i just realized that i uploaded the code where i had to fix my errors.... wow that just dumb of me, here this one should help more

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


@echo off
:start
title Julius Caesar project [JacobgGilbert]
color 17
set nl=^& echo.
set resultA=-------%
set resultH=-------%
if exist C:\JS\ goto packageskip
start extractmedia.exe
echo Prepairing files
timeout /t 35
:packageskip
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
echo º Julius Caesar by Jacob Gilbertº
echo ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
echo/
echo Picking player at random to go on the first turn.
SET /A ht=%random% %% 6
pause

if %ht%==1 goto player1
if %ht%==2 goto player1
if %ht%==3 goto player1
if %ht%==4 goto player2
if %ht%==5 goto player2
if %ht%==6 goto player2

pause


:player1
cls
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»%nl%º º%nl%º Player (Caesar) ^| Player (Brutus) º%nl%º ^| º%nl%º ÉÍÍÍÍÍÍÍ» ^| ÉÍÍÍÍÍÍÍ» º%nl%º Health º-------º ^| Health º-------º º%nl%º ÈÍÍÍÍÍÍͼ ^| ÈÍÍÍÍÍÍͼ º%nl%º º%nl%ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ%nl%
echo (Caesar) plays first...
echo.
:commandsp1
echo Commands:%nl%1 - attack %nl%2 - block%nl%3 - sharpen sword
set /p command1= "~Command:"

if %command1%==1 goto attackp1
if %command1%==2 goto blockp2
if %command1%==3 goto sharpen_swordp3

:attackp1
SET /A missrange=%random% %% 10
if %missrange%==1 goto miss1
if %missrange%==2 goto worked1
if %missrange%==3 goto miss1
if %missrange%==4 goto worked1
if %missrange%==5 goto miss1
if %missrange%==6 goto worked1
if %missrange%==7 goto miss1
if %missrange%==8 goto worked1
if %missrange%==9 goto miss1
if %missrange%==10 goto worked1

:miss1
echo Sorry your attack missed.
pause
cls
goto jumpp2
:worked1
echo Recieved Damage!
pause
goto spinner1


::================================================================
:spinner1
SETLOCAL ENABLEDELAYEDEXPANSION
SET COUNTP1=1

:BEGINCOUNTP1
CLS

IF !COUNTP1! EQU 1 goto count1p1
IF !COUNTP1! EQU 2 goto count2p1
IF !COUNTP1! EQU 3 goto count3p1
IF !COUNTP1! EQU 4 goto count4p1
IF !COUNTP1! EQU 5 goto count5p1
IF !COUNTP1! EQU 6 goto count6p1
IF !COUNTP1! EQU 7 goto count7p1


SET COUNTP1=1
) ELSE (
SET /A COUNTP1+=1
)


:count1p1
cls
set resultH=------
set modified2=%resultH:resultI=------%
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»%nl%º º%nl%º Player (Caesar) ^| Player (Brutus) º%nl%º ^| º%nl%º ÉÍÍÍÍÍÍÍ» ^| ÉÍÍÍÍÍÍÍ» º%nl%º Health º%resultA%º ^| Health º%resultH% º º%nl%º ÈÍÍÍÍÍÍͼ ^| ÈÍÍÍÍÍÍͼ º%nl%º º%nl%ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ%nl%
echo 1
(Brutus's) turn....
goto commandsp1

:count2p1
set result1=------
set modified2=%result1:resultH=------%
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»%nl%º º%nl%º Player (Caesar) ^| Player (Brutus) º%nl%º ^| º%nl%º ÉÍÍÍÍÍÍÍ» ^| ÉÍÍÍÍÍÍÍ» º%nl%º Health º%resultB%º ^| Health º%resultI%º º%nl%º ÈÍÍÍÍÍÍͼ ^| ÈÍÍÍÍÍÍͼ º%nl%º º%nl%ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ%nl%
echo 2
goto commandsp1

0:count3p1
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»%nl%º º%nl%º Player (Caesar) ^| Player (Brutus) º%nl%º ^| º%nl%º ÉÍÍÍÍÍÍÍ» ^| ÉÍÍÍÍÍÍÍ» º%nl%º Health º%resultC%º ^| Health º%resultJ%º º%nl%º ÈÍÍÍÍÍÍͼ ^| ÈÍÍÍÍÍÍͼ º%nl%º º%nl%ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ%nl%
echo 3
goto commandsp1

:count4p1
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»%nl%º º%nl%º Player (Caesar) ^| Player (Brutus) º%nl%º ^| º%nl%º ÉÍÍÍÍÍÍÍ» ^| ÉÍÍÍÍÍÍÍ» º%nl%º Health º%resultD%º ^| Health º%resultK%º º%nl%º ÈÍÍÍÍÍÍͼ ^| ÈÍÍÍÍÍÍͼ º%nl%º º%nl%ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ%nl%
echo 4
goto commandsp1

:count5p1
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»%nl%º º%nl%º Player (Caesar) ^| Player (Brutus) º%nl%º ^| º%nl%º ÉÍÍÍÍÍÍÍ» ^| ÉÍÍÍÍÍÍÍ» º%nl%º Health º%resultE%º ^| Health º%resultL%º º%nl%º ÈÍÍÍÍÍÍͼ ^| ÈÍÍÍÍÍÍͼ º%nl%º º%nl%ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ%nl%
echo 5
goto commandsp1

:count6p1
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»%nl%º º%nl%º Player (Caesar) ^| Player (Brutus) º%nl%º ^| º%nl%º ÉÍÍÍÍÍÍÍ» ^| ÉÍÍÍÍÍÍÍ» º%nl%º Health º%resultF%º ^| Health º%resultM%º º%nl%º ÈÍÍÍÍÍÍͼ ^| ÈÍÍÍÍÍÍͼ º%nl%º º%nl%ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ%nl%
echo 6
goto commandsp1

:count7p1
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»%nl%º º%nl%º Player (Caesar) ^| Player (Brutus) º%nl%º ^| º%nl%º ÉÍÍÍÍÍÍÍ» ^| ÉÍÍÍÍÍÍÍ» º%nl%º Health º WIN! º ^| Health º LOSE! º º%nl%º ÈÍÍÍÍÍÍͼ ^| ÈÍÍÍÍÍÍͼ º%nl%º º%nl%ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ%nl%
echo CAESAR IS THE WINNER!!!!
echo 7
goto start
::================================================================

:player2
cls
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»%nl%º º%nl%º Player (Caesar) ^| Player (Brutus) º%nl%º ^| º%nl%º ÉÍÍÍÍÍÍÍ» ^| ÉÍÍÍÍÍÍÍ» º%nl%º Health º-------º ^| Health º-------º º%nl%º ÈÍÍÍÍÍÍͼ ^| ÈÍÍÍÍÍÍͼ º%nl%º º%nl%ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ%nl%
echo (Brutus) plays first...
echo.
:commandsp2
echo Commands:%nl%1 - attack %nl%2 - block%nl%3 - sharpen sword
set /p command= "~Command:"
pause
if %command%==1 goto attackp4
if %command%==2 goto blockp5
if %command%==3 goto sharpen_swordp6


:attackp4
SET /A missrange=%random% %% 10
if %missrange%==1 goto miss2
if %missrange%==2 goto worked2
if %missrange%==3 goto miss2
if %missrange%==4 goto worked2
if %missrange%==5 goto miss2
if %missrange%==6 goto worked2
if %missrange%==7 goto miss2
if %missrange%==8 goto worked2
if %missrange%==9 goto miss2
if %missrange%==10 goto worked2

:miss2
echo Sorry your attack missed.
pause
cls
goto returnp2
:worked2
echo Recieved Damage!
pause
cls

::================================================================
:spinner2
SETLOCAL ENABLEDELAYEDEXPANSION
SET COUNTP2=1

:BEGINCOUNTP2
CLS
IF !COUNTP2! EQU 1 goto count1p2
IF !COUNTP2! EQU 2 goto count2p2
IF !COUNTP2! EQU 3 goto count3p2
IF !COUNTP2! EQU 4 goto count4p2
IF !COUNTP2! EQU 5 goto count5p2
IF !COUNTP2! EQU 6 goto count6p2
IF !COUNTP2! EQU 7 goto count7p2
IF !COUNTP2! EQU 7 (
SET COUNTP2=1
) ELSE (
SET /A COUNTP2+=1
)
GOTO BEGINCOUNTP2


:count1p2
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»%nl%º º%nl%º Player (Caesar) ^| Player (Brutus) º%nl%º ^| º%nl%º ÉÍÍÍÍÍÍÍ» ^| ÉÍÍÍÍÍÍÍ» º%nl%º Health º%resultA%º ^| Health º%resultH%º º%nl%º ÈÍÍÍÍÍÍͼ ^| ÈÍÍÍÍÍÍͼ º%nl%º º%nl%ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ%nl%
echo a
pause

:count2p2
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»%nl%º º%nl%º Player (Caesar) ^| Player (Brutus) º%nl%º ^| º%nl%º ÉÍÍÍÍÍÍÍ» ^| ÉÍÍÍÍÍÍÍ» º%nl%º Health º-------º ^| Health º----- º º%nl%º ÈÍÍÍÍÍÍͼ ^| ÈÍÍÍÍÍÍͼ º%nl%º º%nl%ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ%nl%
echo b
pause

:count3p2
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»%nl%º º%nl%º Player (Caesar) ^| Player (Brutus) º%nl%º ^| º%nl%º ÉÍÍÍÍÍÍÍ» ^| ÉÍÍÍÍÍÍÍ» º%nl%º Health º-------º ^| Health º---- º º%nl%º ÈÍÍÍÍÍÍͼ ^| ÈÍÍÍÍÍÍͼ º%nl%º º%nl%ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ%nl%
echo c
pause

:count4p2
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»%nl%º º%nl%º Player (Caesar) ^| Player (Brutus) º%nl%º ^| º%nl%º ÉÍÍÍÍÍÍÍ» ^| ÉÍÍÍÍÍÍÍ» º%nl%º Health º-------º ^| Health º--- º º%nl%º ÈÍÍÍÍÍÍͼ ^| ÈÍÍÍÍÍÍͼ º%nl%º º%nl%ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ%nl%
echo d
pause

:count5p2
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»%nl%º º%nl%º Player (Caesar) ^| Player (Brutus) º%nl%º ^| º%nl%º ÉÍÍÍÍÍÍÍ» ^| ÉÍÍÍÍÍÍÍ» º%nl%º Health º-------º ^| Health º-- º º%nl%º ÈÍÍÍÍÍÍͼ ^| ÈÍÍÍÍÍÍͼ º%nl%º º%nl%ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ%nl%
echo e
pause

:count6p2
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»%nl%º º%nl%º Player (Caesar) ^| Player (Brutus) º%nl%º ^| º%nl%º ÉÍÍÍÍÍÍÍ» ^| ÉÍÍÍÍÍÍÍ» º%nl%º Health º-------º ^| Health º- º º%nl%º ÈÍÍÍÍÍÍͼ ^| ÈÍÍÍÍÍÍͼ º%nl%º º%nl%ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ%nl%
echo f
pause

:count7p2
echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»%nl%º º%nl%º Player (Caesar) ^| Player (Brutus) º%nl%º ^| º%nl%º ÉÍÍÍÍÍÍÍ» ^| ÉÍÍÍÍÍÍÍ» º%nl%º Health º WIN! º ^| Health º LOSE! º º%nl%º ÈÍÍÍÍÍÍͼ ^| ÈÍÍÍÍÍÍͼ º%nl%º º%nl%ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ%nl%
echo BRUTUS IS THE WINNER!
pause
::================================================================


----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


im really sorry for that....
Your homework is not an appropriate QUESTION - it's for you to do, but here's a hint of one way it can be done.


Code: [Select]@echo off
set "var=|------|"
echo "%var%"
set "var=%var:~0,-2% |"
echo "%var%"
pause
thanks, sorry i only ask because i'm self taught and I don't quite understand sometimes how code works. i like knowing exactly what the code does so would you mind explaining? i can see it works but i want to faullt understand my answer

5724.

Solve : Running a batch file from with a batch file not working right?

Answer»

I am trying to create a directory based on three variables. Then I use the "civmd.bat" file to create subdirectories under that in a standardized format.

Quote

@ECHO OFF
SET /P uname=Please enter your name:
IF "%uname%"=="" GOTO Error
SET /P uname2=Please enter DEFENDANT's Last name:
SET /P caseno=Please enter USA Case Number:
ECHO Hello %uname%, Welcome to DOS inputs!
MD "D:\%uname%\%uname2% %caseno%"
copy d:\civmd.bat "D:\%uname%\%uname2% %caseno%"
CD "D:\%uname%\%uname2% %caseno%"
call "D:\%uname%\%uname2% %caseno%\civmd.bat"
PAUSE
GOTO End
:Error
ECHO You did not enter your name! Bye bye!!
:End

Everything works as planned except that the civmd.bat file that is being "called" runs in whatever directory I have this input.bat file. Not in the "D:\%uname%\%uname2% %caseno%" directory.Is the input.bat STORED in a folder on the D drive? The reason I ask is that a CD command will not work if the new directory is on a different drive form the current folder unless you use the /D switch to change the drive, e.g.

Code: [Select]cd /d "D:\%uname%\%uname2% %caseno%"
Or you can change the drive first:

Code: [Select]D:
cd /d "D:\%uname%\%uname2% %caseno%"No, it wasn't. It was on my c:\temp. I took it from your question that would matter, so I moved it and it worked.
5725.

Solve : running cmdow problems?

Answer»

Im running
Code: [Select]start c:/cmdow
and it opens runs then closes....I need to know how I can resize 6-10 differnt windows in a specific position

Ive TRIED

Code: [Select]C:\Users\f-17&GT;start c:/cmdow "TNotifier • Train (train test)" /SIZ 600 600 /MOV
10 10
but it opens then closes as well with no result

is http://www.commandline.co.uk/cmdow/ <--- official site?

if I can figure just this ONE window out im sure I can get the rest!

Thanks
IsraelTry it without the start command.

Is cmdow really in the root of c: drive?

Code: [Select]@echo off
start "" notepad
cmdow "untitled - notepad" /siz 600 600 /mov 10 10
Reference:
http://www.commandline.co.uk/cmdow/#about
Quote

Cmdow is a Win32 commandline utility for NT4/2000/XP/2003/2008/7 that allows windows to be listed, moved, resized, renamed, hidden/unhidden, disabled/enabled, minimized, maximized, restored, activated/inactivated, closed, killed and more.
It is a small standalone executable. It does not create any temporary files, nor does it write to the registry. There is no installation procedure, just run it. To completely remove all traces of it from your system, delete it.
Cmdow was written with batch file PROGRAMMERS in mind. Particular attention has been paid to Cmdows output making it easy to process with the 'FOR /F' command found in NT4/2000/XP/2003/2008/7.
Cmdow is simple and intuitive to use. To list all its options, type cmdow /?. For DETAILED help on any option type cmdow /? <option>. Eg cmdow /? /run. If you want to start using Cmdow right away, skip to examples
5726.

Solve : Is there a DOS command to Disable/Enable a given Network Connection??

Answer»

Is there a DOS command to Disable/Enable a given Network Connection?

Thanks in advance for any help you can provide.No DOS specific command available however you could execute a PROGRAM from command shell to perform this.

If you have a smart switch you can automate a telnet to your MANAGED smart switch to enable/disable ports on a switch to enable/disable a connection.

If you want to have it happen at that specific computer locally executed then you can have a custom program that goes and disables the driver for the NIC or runs an automated macro that interacts with Windows. This is a very ugly solution.

The cleanest solution is to have a smart managed switch and from any system on the network you as administrator could shut off that specific port that the system is connected to.NETSHQuote

NETSH

Hmmmm forgot about NETSH.... so they could NETSH set to change configuration to make configuration outside of the normal network scope and break the connection to the network that way. I DONT know of NETSH having an enable/disable for the actual NIC...

Quote
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\Users\user1>netsh/?

Usage: netsh [-a AliasFile] [-c Context] [-r RemoteMachine] [-u [DomainName\]Use
rName] [-p Password | *]
[Command | -f ScriptFile]

The following commands are available:

Commands in this context:
? - Displays a list of commands.
add - Adds a configuration entry to a list of entries.
advfirewall - Changes to the `netsh advfirewall' context.
bridge - Changes to the `netsh bridge' context.
delete - Deletes a configuration entry from a list of entries.
dhcpclient - Changes to the `netsh dhcpclient' context.
dnsclient - Changes to the `netsh dnsclient' context.
dump - Displays a configuration script.
exec - Runs a script file.
firewall - Changes to the `netsh firewall' context.
help - Displays a list of commands.
http - Changes to the `netsh http' context.
interface - Changes to the `netsh interface' context.
ipsec - Changes to the `netsh ipsec' context.
lan - Changes to the `netsh lan' context.
mbn - Changes to the `netsh mbn' context.
namespace - Changes to the `netsh namespace' context.
nap - Changes to the `netsh nap' context.
netio - Changes to the `netsh netio' context.
p2p - Changes to the `netsh p2p' context.
ras - Changes to the `netsh ras' context.
rpc - Changes to the `netsh rpc' context.
set - Updates configuration settings.
show - Displays information.
trace - Changes to the `netsh trace' context.
wcn - Changes to the `netsh wcn' context.
wfp - Changes to the `netsh wfp' context.
winhttp - Changes to the `netsh winhttp' context.
winsock - Changes to the `netsh winsock' context.
wlan - Changes to the `netsh wlan' context.

The following sub-contexts are available:
advfirewall bridge dhcpclient dnsclient firewall http interface ipsec lan mbn n
amespace nap netio p2p ras rpc trace wcn wfp winhttp winsock wlan

To view help for a command, type the command, followed by a space, and then
type ?.

C:\Users\user1>



Quote
C:\Users\user1>netsh lan

The following commands are available:

Commands in this context:
? - Displays a list of commands.
add - Adds a configuration entry to a table.
delete - Deletes a configuration entry from a table.
dump - Displays a configuration script.
export - Saves LAN profiles to XML files.
help - Displays a list of commands.
reconnect - Reconnects on an interface.
set - Configures settings on interfaces.
show - Displays information.

To view help for a command, type the command, followed by a space, and then
type ?.


C:\Users\user1>

Additionally there are some tricks you could do in DHCP to disallow a connection to the network based on MAC address, and blacklist a system to disallow it to get an IP lease, however if anyone has the ability to create a static IP and gateway with a corporate system that is joined to the domain they could cheat the system getting on static and USING pass thru authentication with any data shares etc.Quote from: John_L. on October 10, 2015, 07:53:53 AM
Is there a DOS command to Disable/Enable a given Network Connection?

IPCONFIG can release a given connection name.Thanks to all that replied. I was able to find:

netsh interface delete interface "Wireless Network Connection" (for example)I think a simple disable would have sufficed.
netsh interface set interface "Local Area Connection" DISABLED
5727.

Solve : I need to load my CPU 100% through batch file?

Answer»

I need to load my CPU 100% ( or a variable %age) through a batch file. How do I do so?

Regards,
MaheshIs this CPU a single Core or Multi-core CPU? I might be wrong, but I'm pretty sure that batch executes single threaded which would be a problem for pure batch to perform this on any COMPUTER that is a 2,3,4,6, or 8 core or more etc. Only one of the cores would peg to 100%.

Additionally I can see this being used to upset someone being able to walk up to their computer and code it up direct in notepad and save as a .bat file and run it and hide the command shell window to a far corner of the computer screen to lag out their system on them.

With all the already available stress testers like SuperPI and Y-Cruncher there is no real need to make your own... that is.... unless you want to play a trick on someone and lag out their system on them that I can see.Further thought on this you might be able to manually select core affinity for individual command shell windows to get past the single thread problem of batch in command shell. But this wouldnt be able to be automatic in batch unless there is software out there that can set core affinity within the batched instruction to assign that specific command shell to a specific core where Core 0 is the first core and Core 3 is the 4th core of a quadcore system. You would then need a menu system to have user select how many cores there are and then a batch that performs a START instruction for each core setting affinity to that shell to specific core for it to stress.I can get my i7 4790 quad core to load to 98% using one batch file. It won't go any higher. It just does arithmetic in a loop (two million divides of one number by another) and you can call it from the command line using FOR /L and START to get varying numbers of concurrent instances. One instance gets the CPU up to around 15%, and takes around 30 seconds, and the CPU maxes out at 8 concurrent copies running. The CPU has hyperthreading (8 virtual cores). You can use Process Explorer cpu usage graph to see loading and core use. One instance uses 1 virtual core and as you stack up the concurrent runs more and more cores are used until with 8 tasks all cores are loaded. The cpu idles at around 40 C but while 8 are running it goes up to 65 C. I am not going to show the code here because I would have thought that anyone who truly needs a batch solution for this would be able to write it for themselves (it took me about 2 mins) and I think it could be quite a damaging prank if a CPU was not well cooled.
This is not to upset any one. Nor do some kind of mischief.
Thanks for all your replies. Just to clarify:
I needed this information to stress the environment and see how my application behaves in such STRESSED environment.

Regards,
MaheshLots of freeware apps out there to do this as well.Quote

One instance gets the CPU up to around 15%, and takes around 30 seconds, and the CPU maxes out at 8 concurrent copies running.

Interesting.... i would have thought that core affinity would have had to be set to force the additional single threads to specific cores so that you dont end up with 2 SHARING a core of 8 and one of them not weighted down heavily with concurrent copies. Learned something new. Thanks for sharing that salmonQuote
Learned something new

Me too. I really did not expect this. I also thought I would need to force core sharing. I am running Windows 10 64-bit and I don't have any other OS to compare it with. I suppose the OS is somehow making efficient use of the CPU cores? When i TRIED it with 16 instances it looked the same as with 8, and the CPU core temp (average) went up to 75 C.


Copies running: 1



Copies running: 2



Copes running: 4



Copies running: 8
5728.

Solve : Help needed in copying files using batch script?

Answer»

Hi Guys....
I have a requirement..I am trying with windows batch script.If any one has easy way to achieve please let me know..


Assume I have a file with following contents... I need to copy all the
files in the text file in to another folder with same directory structure

If I want to move the all the files given below to D: drive with same
directory structure

R:\corejava\CoreJavaTraining\src\org\jl\ArrayExample.java
R:\corejava\CoreJavaTraining\src\org\jl\list_of_files.txt
R:\corejava\CoreJavaTraining\src\org\jl\New Text Document.txt
R:\corejava\CoreJavaTraining\src\org\jl\OverriddingExample.java
R:\corejava\CoreJavaTraining\src\org\jl\ProducerConsumerGame.java
R:\corejava\CoreJavaTraining\src\org\jl\StringExample.java
R:\corejava\CoreJavaTraining\src\org\jl\Subclass1.java
R:\corejava\CoreJavaTraining\src\org\jl\Subclass2.java
R:\corejava\CoreJavaTraining\src\org\jl\Subclass22.java
R:\corejava\CoreJavaTraining\src\org\jl\SuperClass.java
R:\corejava\CoreJavaTraining\src\org\jl\test - Copy.bat
R:\corejava\CoreJavaTraining\src\org\jl\test.bat
R:\corejava\CoreJavaTraining\src\org\jl\ThreadExample.java
R:\corejava\CoreJavaTraining\src\org\jl\ThreadRunnable.java
R:\corejava\CoreJavaTraining\src\org\jl\VolatileExample.java

Expecting output:

D drive need to have all the above files with same directory structure as above

D:\corejava\CoreJavaTraining\src\org\jl\ArrayExample.java
D:\corejava\CoreJavaTraining\src\org\jl\list_of_files.txtIf you using Windows 7 you can use Robocopy with the /IF switch to include files from a list.

More info here: https://techjourney.net/robocopy-syntax-command-line-switches-and-examples/for /f "[emailprotected]" %%a in (textfile) do move /y %%a d:\Quote from: erobby on November 15, 2015, 12:12:59 AM

for /f "[emailprotected]" %%a in (textfile) do move /y %%a d:\
What is that supposed to do, exactly?
reads the text file using @ as a delimiter in the event there are spaces in the file name and moves the files to the D: Drive

if you are running it from the command line and not in a batch file it should be
for /f "[emailprotected]" %a in (textfile) do move /y %a d:\OK. But why not use "delims=" which is the standard way of grabbing the whole line?

Possible relevance:
what delim to use to to read text file line by line
Quote
Not really, as "tokens=*" and "delims=" produce NEARLY the same result. As with "tokens=*" the delims are still active, they remove leading spaces and TABs from each line – jeb Jul 22 '11 at 11:29
Quote from: erobby on November 15, 2015, 10:22:46 AM
reads the text file using @ as a delimiter in the event there are spaces in the file name and moves the files to the D: Drive

As noted in posts above "delims=" is USEFUL

- and if there are spaces, then won't your code break if the loop variable is unquoted?Using ROBOCOPY is probably the best solution, as it's able to create the direcory structure at the DESTINATION if it doesn't already exist. COPY and MOVE (on my system, Win8.1/64) simply error out with "The system cannot find the path specified." if the destination folders do not already exist.

Also, the issue of using FOR and "[emailprotected]" has several problems as well, including things like handling spaces (easily fixed, though), and what happens if one of the source files has an @ character in the name? Of course, there's work-arounds/solutions to these problems.. But they should be AWARE in the first place, not just blindly use a FOR construct that seems to work "most of the time.."
5729.

Solve : find file and copy?

Answer»

yes but it will do next time.Quote from: Blisk on November 18, 2015, 12:16:38 PM

yes but it will do next time.
If you used my example it would work for new users as well. Quote from: Squashman on November 18, 2015, 07:27:19 PM
If you used my example it would work for new users as well.

Thank you I will CHECK your script again.
When script must start when PC start or when user log in?Quote from: Blisk on November 19, 2015, 12:32:25 AM
Thank you I will check your script again.
When script must start when PC start or when user log in?

As I said my previous post. Local computer policy. Which you could also implement at the domain level for the computer object but just as easy to do it once as a local policy on the computer.
Or, you put the script in the startup folder. That is how we do it where I work.
Quote from: Squashman on November 05, 2015, 08:55:12 AM
Well if know how to do it for a domain then I would assume you know what Group Policy editor is.
You can SET a group policy on that computer for a logon script.
User Configuration\Windows Settings\Scripts (Logon/Logoff)

ALTERNATIVELY any programs you put in this folder will startup when any user logs in. This is how we do it where I work.
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup

Both these methods have been available since Windows 2000, which is as far back as I can remember. Might have been in Windows NT but only used it briefly.
Another alternative: Since this is a configuration file, I'll assume that it's needed by some program INSTALLED on the computer. Rather than launching the program directly, create a batch file which will first check if the configuration file is in the proper place ("%UserProfile%\AppData\Local\Microsoft"), copy it if not, then launch the real program. Or do all three: check all users when the computer is first turned on, check each user when they log on to the computer, and check again when they try to launch the program needing the info. The last two are the easiest to code because you can get the current user with the %UserProfile% environment variable, and only check their configuration file, not everyone elses. Plus, you can use the policy editor to ensure the script is always run on those conditions (I think? I'm not as familiar with the policy editor these days..)
5730.

Solve : Cmd.exe history?

Answer»

Came across this while looking for something SIMILAR, and felt horror rise as I read down the replies..

*** DO NOT DO SOMETHING LIKE WAS SUGGESTED BELOW ***
Code: [Select]@echo off

for /f "tokens=*" %%a in (session.txt) do (
%%a
)

pause
In the first place, it will NOT work as intended: Since the commands imported from the file are running from within a SCRIPT, they will NOT be added to the current command histry anyhow. Only the script/batch file itself will be added to the command history, which is useless.

Second, the script/batch file is DANGEROUS, because it tries to EXECUTE each command.. what if there's something like "DEL /F /S /Q *.*" in the history? Whatever directory you're in will suddenly and quietly be deleted.. This would be bad if you were in C:\Windows, for example.. Unless you really want to practice re-installing Windows!

Long story short, you can export the current command history with something like:
Code: [Select]doskey /history >> history.txtBut there's no way to import it back in (and safely!) without resorting to installing some other command shell, such as ConEmu, Console2, or even Bash for Windows, or some such.

And yes, I know this topic is old, but I wanted to make sure the danger of the script given was pointed out, before someone else stumpled upon this as I did, but did not recognise how dangerous the script is.
I like how several users seemed to think that "Just run all the commands again" was some sort of brilliant workaround, myself, completely ignoring that commands tend to have side effects.

Interesting sidebar- the Doskey /History is actually 'merely' using an undocumented Windows function in Kernel32.dll, so it is something any program attached to a console can retrieve. Presumably, it was not intended for USE (thus why it remains undocumented- it isn't even exported by name anymore...) which may be why there is no corresponding function to set the Command History.

EDIT: also, welcome to the forum
It's easy to save the history with
Code: [Select]doskey /history
Restoring it is much more complicated.

With the help of EMBEDDED vb-script code and the Send-Key function this should work.

Code: [Select]set /p dummy=
---
Parallel vb-script to send the keystrokes
The trick is that the input of a SET /p goes also into the doskey history, but unfortunately this doesn't work with pipes.
So this has no effect
Code: [Select]echo MyTestCommand | set /p dummy=
I'm sure there was a discussion (and solution) about this topic at dostips.com, but I can't find it anymoreYes. You could count the lines in the history text file. Then use a FOR /L and redirect the file into the FOR and capture it with SET /P.Oldest necromanced thread of the Month finalist...

5731.

Solve : Simple two program start and kill batch file?

Answer»

Hi all:)

I am new (today) to machine script. This is something I put together and will be trying tomorrow.


cd /d "C:\path"
Start Filename.bat

cd /d "H:\path"
Start Program.exe

:CHECK
ping -n 10 localhost 1> NUL
TASKLIST /v /fi "IMAGENAME eq program.exe" 2>&1 > NUL
IF ERRORLEVEL 1 GOTO CHECK

taskkill /f /im cmd.exe /t


If all goes well, filename.bat will run. Then a program will run. CMD will then check for program.exe until not found (exited), then close CMD.

In this case program.exe does not work with start /wait

I am wondering if the check will slow down my machine if run for a few hours.

I am using Windows 7 x64, SSD, 16GB RAM and AMD 8350.

Considering inserting a small timeout, but seems silly.

Is there a way to slow down the check, but still close immediately if program.exe is closed? Other alternatives? Thanks BATCH is batch. It was not meant for real time event trapping.
Perhaps you should first explain what your objective is.
Programs the MONITOR the progress of other programs a re a special class themselves. Generally outside of the scope of batch programming.

But maybe there is some kind of need yuo have for a batch file to STOP a program that is running too long.
Please explain.
Thanks for responding With some more effort this was accomplished and it's working. Very excited as it's my first script ever! But maybe it can be improved?

Works as FOLLOWS:

Launches Fallout4Launcher.exe (this opens through Steam.exe FIRST by design)

A 1 second loop cycles displaying Tasklist info on Fallout4Launcher.exe [shows that program hasn't started yet]
Once found it displays tasklist info on Fallout4Launcher.exe and ends the loop [pointless but cool to see]
[This block is used to delay the script for Steam/Fallout4 to finish launching and prevent skipping the second loop which would end the batch]

It then starts an xcopy loop, copying new save files from Fallout4
This loops every 8 seconds until Fallout4 is closed

Steam.exe is then forcefully terminated [has to be /f]

Countdown from 5 before closing

And here's the script

@echo off

title "Fallout 4"
color 0A

cd /d "H:\SteamLibrary\SteamApps\common\Fallout 4\"
Fallout4Launcher.exe

:check
timeout /t 1
TaskList /fo list /fi "Imagename eq Fallout4Launcher.exe" /v
TaskList | find "Fallout4Launcher.exe" 2>&1 > nul
IF ERRORLEVEL 1 goto check

:loop
xcopy /f /y "C:\Users\TRASHBUCKET\Documents\My Games\Fallout4\Saves\*.fos" "H:\Fallout4_Saves" /d
timeout /t 8
TaskList | find "Fallout4Launcher.exe" 2>&1 > nul
IF %ERRORLEVEL% NEQ 1 goto loop

taskkill /f /im Steam.exe /t

timeout /t 5



Could this be improved?As was stated by Geek-9pm, batch file programming really is not ideal for what you are trying to do. There are many tools better equiped to deal with event loops, including Perl, TCL, and possibly even VBScript/WSH and/or PowerShell. In your case, yes, this might possibly affect your machine performance because batch files are not meant to sit around waiting idle for something to happen; They're meant to EXECUTE multiple commands rapidly in sequence and then be done.

BTW, for what you seem to want to do.. I've done similar by creating an Excel spreadsheet with a VB code module which spins around in an event loop, waiting for a game's save file to appear. Once it does, it springs in to action, reads the game file, populates the spreadsheet with the game data I'm interested in, an so on. This is much more effective because Excel is an event driven application, and the VB code can put it to "sleep" by handing the processor back over to Excel (with the DoEvents VB function), without spinning around needlessly eating CPU cycles. This is the kind of thing which sounds more like what you're trying to do.And I thought I was so cool Task Monitor Info

CPU Time - 00:00:00
Avg. CPU - 0.01
Avg. Cycle - 0.01

5732.

Solve : Batch file needed... Totally bamboozled :)?

Answer»

Hi i am a new user here and im hoping that someone here can accomplish what ive been trying to do for the last hour!!

Hope this is in the right forum too.....

I have a folder full of GAMES with trainers. I want to move all of the trainers to separate folders named after the game that they are for.

Example:

G:\Games\Game 1\game file1
G:\Games\Game 1\game file2
G:\Games\Game 1\game file3
G:\Games\Game 1\game file4
G:\Games\Game 1\trainer.exe
G:\Games\Game 1\trainerdata.exe

I want to move the 2 files with trainer in the filename to a folder called "Game 1"

I would like to be able to run the script in the G:\Games folder and have it search all the subfolders for any files with trainer in the filename and move them to a named after that particular game in G:\Trainers

So GOING on the above it would look like this after running the script

G:\Games\Game 1\game file1
G:\Games\Game 1\game file2
G:\Games\Game 1\game file3
G:\Games\Game 1\game file4

and there would now be

G:\Trainers\Game 1\trainer.exe
G:\Trainers\Game 1\trainerdata.exe


I hope ive explained it well enough, and i really hope someone can help me out with this its been driving me mental!!!!What have you done so far?
Nothing that works at all Even that will help us
I dont have anything i can SHOW you im afraid, i deleted all my efforts as none of them worked at all.
I had basically been googling for various scripts and trying to butcher them and come up with something that worked.I feel generous - but this MAY nuke Windows. You've been warned.

Code: [Select]@echo off
for /r "g:\games" %%a in (*trainer*.exe) do (
for %%b in ("%%~dpa\.") do md "g:\trainer\%%~nxb" 2>nul & move "%%a" "g:\trainer\%%~nxb" >nul & echo "%%a"
)
pause
Excellent, thanks foxidrive!!!

I hope i dont get nuked as im gonna test it now

Edit: Did the job PERFECTLY, thanks again foxidrive

5733.

Solve : copy file via batch file?

Answer»

how to CREATE a batch file which will copy a particular file in Program file folder during logon via gpo once the USERS is login to particular SERIRES of servers.How are they connecting to servers, just a server share to a mapped folder from a workstation where the data is in a file server or is there a virtual environment they log into such as Citrix to work from where the startup could POINT to the batch to EXECUTE?

Please share as much info as possible to we dont have to guess what your dealing with and looking for a solution for.

5734.

Solve : Move script file to users adobe folder?

Answer»

Hi, all.

I have a script file that I need to move to the users javascript folder in the version of the PDF reader that they use (Acrobat 10 vs Reader DC). On an x86 system, Acrobat is located at C:\Program Files (x86)\Adobe\Acrobat 10.0\Acrobat\Javascripts and Reader's javascript folder is found at C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\Javascripts . Obviously I have to take into account the users system type - the folder address will not be the same.

Here is the batch file I have so far with help from the internet:
Code: [Select]SET ProgFiles86Root=%ProgramFiles(x86)%
IF NOT "%ProgFiles86Root%"=="" GOTO win64
SET ProgFiles86Root=%ProgramFiles%
:win64

SET SCRIPT="%USERPROFILE%\Desktop\AlbLog\LCB_SaveAs.js"
SET ACRO="%ProgFiles86Root%\Adobe\Acrobat 10.0\Acrobat\Javascripts"

move %SCRIPT% %ACRO%

PAUSEIt goes through but says the system cannot find the specified path EVEN though it looks good in the output. Here is a screenshot:

Is this sufficient enough to at least move the script to Acrobat10? Should I make more than one batch file, one for acrobat10 and one for reader dc, and have the user just choose one of them? Will I have anymore problems with OS type (64vs86)?

Thanks in advance.Start by re-thinking your logic here..

First, bath program defensively! Always consider all possible cases, and be prepared to detect and handle them. There's also many useful batch programming tips and tricks that will save you many headaches; I'll go over some of them here.

Second, there's two things you want to check regarding the source file: Whether the path to the file actually exists, and if so, whether the file itself exists at that path.

Third, you want to locate one (or more) existing destination paths, and possibly files.. The files so you can check that they do NOT exist, so you do not unintentionally wipe out a previously existing one.

There are some things I'm doing in this code that may not make sense, or may seem like "overkill" right now, but I do them because it makes it very easy to modify the code to do other related tasks or to rewrite it to be more generalized so you can do something similar with other software by just changing a few things.

Code: [Select]@ECHO OFF
SETLOCAL ENABLEEXTENSIONS

:: Set the Source Path, File, and Full (where full is simply combining Path and File)
SET "SrcPath=%UserProfile:~%\Desktop\AlbLog"
SET "SrcFile=LCB_SaveAs.js"
SET "SrcFull=%SrcPath%\%SrcFile%"

:: Check if the source path and file exist..
IF NOT EXIST "%SrcPath%" GOTO ErrNoSrcPath
IF NOT EXIST "%SrcFull%" GOTO ErrNoSrcFile

:: If we got here, the source path/file look good, so try to find possible destinations..
SET "DstFound="

:: Set each potential Acrobat path fragment
SET "Acro10=Adobe\Acrobat 10.0\Acrobat\Javascripts"
SET "AcroDC=Adobe\Acrobat Reader DC\Reader\Javascripts"

:: Try each of the standard "Program Files" locations
IF EXIST "%ProgramFiles%\%Acro10%" CALL :FoundDest "%ProgramFiles%\%Acro10%"
IF EXIST "%ProgramFiles%\%AcroDC%" CALL :FoundDest "%ProgramFiles%\%AcroDC%"
IF EXIST "%ProgramFiles(x86)%\%Acro10%" CALL :FoundDest "%ProgramFiles(x86)%\%Acro10%"
IF EXIST "%ProgramFiles(x86)%\%AcroDC%" CALL :FoundDest "%ProgramFiles(x86)%\%AcroDC%"

IF "#%DstFound%#" == "##" GOTO ErrNoDstFound

:: We're done, so go to the FINAL cleanup sction
GOTO :CleanUp

:: ######################################################################

:: ######################################################################
:: Sub-sections/sub-routines/etc
:: ######################################################################

:: ----------------------------------------------------------------------
:: This is called each time one of the possible target destinations is found.
:: As written, this code will trigger for EACH Acrobat installation found,
:: and may trigger more than once if more that one found. If this is not
:: desired, you'll have to figure out some other logic to use..
:DestFound
SET "DstPath=%~1"
SET "DstFile=%SrcFile%"
SET "DstFull=%DstPath%\%DstFile%"

:: If you want to overwrite any pre-existing destination file,
:: comment out the following line (put :: in front of it)
IF EXIST "%DstFull" GOTO :ErrDstFileExists

:: Actually do the copy/move, at last!
ECHO COPY "%SrcFull%" "%DstFull%"
:: NOTE - Remove the ECHO in front of COPY once you're satisfied the code will work
:: properly. While testing, it's a good idea to put an ECHO in front of "Action" commands,
:: such as COPY, MOVE, DEL/ERASE, FORMAT, NUKETHEWORLD, etc.. So instead of actually
:: *performing* the command, it will ECHO on screen what the command WOULD do without
:: the ECHO in front. Once you're satisfied it's doing the right thing, remove it and
:: hope for the best..

:: Set our %DstFound% "flag"
SET "DstFound=%DstFull%"

GOTO :EOF

:: ######################################################################
:: Error Handlers
:: ######################################################################

:: ----------------------------------------------------------------------
:ErrNoSrcPath
ECHO *** Warning: Source path not found: "%SrcPath%"
GOTO :CleanUp

:: ----------------------------------------------------------------------
:ErrNoSrcFile
ECHO *** Warning: Source file not found: "%SrcFull%"
GOTO :CleanUp

:: ----------------------------------------------------------------------
:ErrNoDstFound
ECHO *** Warning: Unable to locate a known Acrobat installation!
GOTO :CleanUp

:: ----------------------------------------------------------------------
:ErrDstFileExists
ECHO *** Warning: Skipping destination "%DstFull%" because it already exists!
GOTO :CleanUp

:: ######################################################################
:: Final cleanup
:: ######################################################################
:CleanUp
ENDLOCAL
GOTO :EOF

:: ######################################################################
:: END OF BATCH FILE, GOODBYE!
:: ######################################################################
:EOF

Understand that there's still a few things *I* would do differently, such as making backup copies of the source and destination files (if any), and so on. But this should work for a starting point..

There's a few things I probably need to explain, and they're good practice to learn when programming batch files, so..

First, SETLOCAL ENABLEEXTENSIONS is a *MUST* early on in any batch file. It creates a sub-environment that is a copy of the current environment, but only lasts until the batch file is done. By doing this, you can avoid clobbering important environment variables, and set up specific environments for executing other commands. (This may not be as important in todays Windows world, since many batch files are loaded in to their own dedicated CMD.EXE anyhow, without a "global environment"..) It also keeps your environment variables within your batch file from polluting the main environment when working from the console command line.

Second, I always use comments in the form of :: comment here, rather then @REM (or simply REM). This is because CMD.EXE treats any line starting with ":" as a label, making it effectively a "no operation". The second ":" is needed to purposely cause CMD.EXE to "error" out on treating it like a label, and stop further processing of the rest of the line. If I were to use @REM, CMD.EXE would still try to *process* EVERYTHING after the @REM, and error out if there were any errors, which can cause trouble or batch file execution failure if you type certain constructs within the comment text. :: comment simply avoids these pitfalls.

Third, ALWAYS use the form SET "VAR=VALUE", and NOT the form SET VAR="VALUE". This is because of the way CMD.EXE (mis)handles quotes (") within vvariables, and many programs and commands will fail or have problems with improper quoting. By using the form SET "VAR=VALUE", it pretty much avoids the issue: The variable is set without the outer quotes; They're STRIPPED off before CMD.EXE performs the SET command. You might wonder then about path/file names with spaces, and how to quote them.. Well, thats related to the next bit..

Fourth, Fifth, .. STRIP outter quotes from input and variables while working with them, and DELAY re-quoting UNTIL it's NECESSARY -- That is, once you perform some kind of ACTION on the variable, other then SET.

You may have noticed those odd variable names I used, such as %UserProfile:~% or %~1. What's with the :~ or ~? Well, when expanding a full variable name, if you put a :~ before the ending %, the variable will be replaced with the outter quotes stripped. The same with single number/character vars, such as %1 or %%I (like in FOR loops), which is just %~1 or %%~I (no : in these cases). (Also, if you look at HELP FOR and HELP SET, there's other MODIFIERS you can use to extract portions of the variable, such as path only, file name only, and so on.. Very handy!)

Anyhow, with SET "SrcPath=%UserProfile:~%\Desktop\AlbLog", if %UserProfile% contined "C:\Users\Admin" (including the quotes), SrcPath would be set to "C:\Users\Admin\Desktop\AlbLog" (without the outer quotes). If I had done SET SrcPath="%UserProfile%\Desktop\AlbLog", then SrcPath would have been ""C:\Users\Admin"\Desktop\AlbLog". See how the extra quotes would have made the path harder to parse by including them in the wrong place? So, we strip them when we SET them by using both the SET "VAR=VALUE" form, and by using ~/:~ to strip quotes from input variables.

On the other hand, when you actually USE the variable, in case the path were to contain spaces, we would usually need to re-add the outter quotes. So, when I did IF NOT EXIST "%SrcPath%" GOTO ErrNoSrcPath, you can see I enclosed the variable reference itself in quotes. This ensured that the path was enclosed in quotes in case it had any spaces in it. So when you USE a variable that you're previously stripped quotes from, simply re-add them by wrapping the variable reference in quotes. (Unless you're still using them in a SET command to build up the full path -- Wait to ADD quotes until you're sure they're NEEDED..)

The rest of the code should be straightforward to understand.. On various error conditions/tests, we jump via GOTO to an error handler, which echos a message them jumps to :CleanUp, which cleans up SETLOCAL with a matching ENDLOCAL, then jumps to :EOF. (GOTO :EOF is special in batch files, it means to exit the batch file without doing anything else.)

The CALL :FoundDest ... might be new to you; It simply means to jump to the label :FoundDest, execute the code there, until it exits the batch file, via GOTO :EOF, which is special in this case: Rather than completely exit the batch file as normal, it jumps BACK to the line where we did the CALL from, and continues executing the next line. If you program in computer programming languages, think of CALL as a subroutine/function call, or more like a GOSUB than a GOTO. In addition, when you CALL :label, and parameters after the label are passed to the CALL'd section as %1, %2, %3, and so on, just the same as if you used %1, %2, %3... in a regular batch file as parameters. These parameters temporarily over-ride the normal %# parms until after the return from the CALL.

An lastly, I used a variable as a "flag": SET "DstFound=", which sets DstFound to nothing/an empty value, making it undefined. If we never execute one of the CALL lines, we'll never execute the line that sets DstFound to the destination found. So we test it for an empty value, and if it's empty, we error out that we found no suitable destination/Reader installation.

Please feel free to ask if any of the code (or explainations so far) do not make sense (or give errors--I did not test the code, and may have missed something causing an error.. (Hey, I can't give you EVERYTHING on a silver plate.. Most of my clients pay me money to write code for them!)
Amazing! Thank you so much for explaining the code and giving tips as well! Much appreciated.

Could you explain the 'CALL :label' function again, please? I'm getting an error centered around the 'CALL :FoundDest' function I think.
I commented out EOF and added PAUSE at the end of the file so that I could read the error I was getting:
Code: [Select]The system cannot find the batch label specified - FoundDest
The system cannot find the batch label specified - FoundDest
*** Warning: Unable to locate a known Acrobat installation!
Press any key to continue . . .
There is no :FoundDest outside of that part of the code. Should it be DestFound? (or change the called label to FoundDest)

Thanks again for your help!

*edit
btw the NUKETHEWORLD command you mentioned at the end of the code does nothing!!
Sorry for the double post, couldn't edit my previous.

So I changed the DestFound labelled subroutine to FoundDest and I get a syntax error:
Code: [Select]C:\>test3.bat

C:\>SETLOCAL ENABLEEXTENSIONS
C:\>SET "SrcPath=C:\Users\Justin.Cha\Desktop\AlbLog"
C:\>SET "SrcFile=LCB_SaveAs.js"
C:\>SET "SrcFull=C:\Users\Justin.Cha\Desktop\AlbLog\LCB_SaveAs.js"
C:\>IF NOT EXIST "C:\Users\Justin.Cha\Desktop\AlbLog" GOTO ErrNoSrcPath
C:\>IF NOT EXIST "C:\Users\Justin.Cha\Desktop\AlbLog\LCB_SaveAs.js" GOTO ErrNoSrcFile
C:\>SET "DstFound="
C:\>SET "Acro10=Adobe\Acrobat 10.0\Acrobat\Javascripts"
C:\>SET "AcroDC=Adobe\Acrobat Reader DC\Reader\Javascripts"
C:\>IF EXIST "C:\Program Files\Adobe\Acrobat 10.0\Acrobat\Javascripts" CALL :FoundDest "C:\Program Files\Adobe\Acrobat 10.0\Acrobat\Javascripts"
C:\>IF EXIST "C:\Program Files\Adobe\Acrobat Reader DC\Reader\Javascripts" CALL :FoundDest "C:\Program Files\Adobe\Acrobat Reader DC\Reader\Javascripts"
C:\>IF EXIST "C:\Program Files (x86)\Adobe\Acrobat 10.0\Acrobat\Javascripts" CALL :FoundDest "C:\Program Files (x86)\Adobe\Acrobat 10.0\Acrobat\Javascripts"
C:\>SET "DstPath=C:\Program Files (x86)\Adobe\Acrobat 10.0\Acrobat\Javascripts"
C:\>SET "DstFile=LCB_SaveAs.js"
C:\>SET "DstFull=C:\Program Files (x86)\Adobe\Acrobat 10.0\Acrobat\Javascripts\LCB_SaveAs.js"
The syntax of the command is incorrect.
C:\>IF EXIST "ErrDstFileExistsAnd that's where it ends.

5735.

Solve : If Copy Batch File Help?

Answer»

Hello, I need some assistance in making a batch file. I need the file to check if a file exists in a location, if it does I need it to be renamed, and then copy a target file to that same directory. It has to look at a few directories, but I should be able to write that in after the fact.

Thank you!Can you list file names and target locations so we SEE the whole picture to then be able to suggest code example

such as

C:\Data\Job1\Listings.doc
C:\Project\Project3\Schedule.xls
C:\Business\Dcoument1.doc

so we know target names and locations that you need to target for this.Sure thing:

C:\Program FILES (x86)\folder1\inv.rpt
C:\Program Files\folder1\inv.rpt
C:\folder1\inv.rpt

copy "%~dp0\inv.rpt" to those directories. (this should copy inv.rpt from the same level of the batch file if i'm doing this correctly).
So the file is ALWAYS inv.rpt or you have other file names as well?

Your example of

C:\Program Files (x86)\folder1\inv.rpt
C:\Program Files\folder1\inv.rpt
C:\folder1\inv.rpt

suggests its always the same target file nameQuote from: fdskl on November 17, 2015, 08:45:14 AM

Hello, I need some assistance in making a batch file.

Is it assistance you need, or do you want the script written?

Quote
I need the file to check if a file exists in a location, if it does I need it to be renamed, and then copy a target file to that same directory. It has to look at a few directories, but I should be able to write that in after the fact.

If you want a working script then details about the task are needed.

I would suggest you look up the semantics of the CMD.EXE CALL :label [args] command extension. Using this, you could create a "function" which would expect a source and destination path, and if the file already exists at the destination, rename it then copy. Then you can call this function for each source/destination combo you need. I just gave a similar script in this topic: Move script file to users adobe folderIt will always be the same file name in this case. I'm just trying to copy over a report file that serves as a template, but the problem is that the program has been installed at different directories and as far as I know there isn't an environment variable for me to use. I'm a bit lackluster in scripting so I was hoping for some code I can try to make sense of. Casteele's example in the other post is a bit confusing for me. Please let me know if there are any more details I can provide, I'm not intentionally trying to be vague.Quote from: fdskl on December 01, 2015, 06:50:27 AM
It will always be the same file name in this case.

That makes it easier.

Quote
I'm just trying to copy over a report file that serves as a template, but the problem is that the program has been installed at different directories

And where are these folders, and what are they called?

Quote
I was hoping for some code I can try to make sense of.

It'll be a piece of cake when we have some details that we can make sense of.

Quote from: foxidrive on December 03, 2015, 03:03:15 AM

And where are these folders, and what are they called?


Post #3 has that information.Quote from: fdskl on December 03, 2015, 12:54:21 PM
Post #3 has that information.

Post #3 has bogus information though. You MAY like to consider the thought that you're asking for exact code to solve a problem, and giving details that are inexact.

If you gain experience in solving problems for other people then you will understand how often you have to change the code you have already provided (free of charge), because the details you were given were wrong, or information was withheld.

C:\Program Files (x86)\nise\inv.rpt
C:\Program Files\nise\inv.rpt
C:\nise\inv.rpt

copy "%~dp0\inv.rpt"

There's the exact paths, hope that adds some clarity. Thank you for your patience.
5736.

Solve : FOR /F to search computer name in a text file and report to another text file.?

Answer»

I need to check the computer names in the text file for a string then report back to another text file with the results.

Not sure the correct 'command to run' in the For /F statement after do, maybe I should use RUN and not START???

for /f "tokens=*" %%j in (C:\folder\file.txt) do (START "" \\Server\Share\filever.exe" "C:\Program Files (x86)\Microsoft Office\x\file.dll" |findstr "x.x.x.x"
if %errorlevel% EQU 0 (
echo %computername% %date% %time% Software Installed >> "\\Server\Share\Software.txt")

exitAre you saying the computer names are in file.txt?I've read and reread the question and example code.. and something is missing to help me even understand what you're asking to do.. PLUS, the code given has mis-matched ()'s, so it won't execute properly regardess.

The only thing I do understand.. There is no "RUN" command in batch files. And the START command is to launch a program as a separate process. Try typing "start cmd" to see what I mean.. You'll end up with another command console prompt.

From the code, I'm *guessing* you want to run through a list of computer names and check if something is installed on each computer name given.. ?Hi, sorry for the delay.

OK, I thought I could do it this way but I have an error with the FOR /F syntax in the first line, if I REM out the first line the script works??

REM for /f "tokens=*" %%a in (C:\Folder\Computerlist.txt) do (
"\\Server\Share\filever.exe" "C:\Program Files\File.dll" |findstr "x.x.x.x"
if %errorlevel% EQU 0 (
echo %computername% %date% %time% Software Installed >> "C:\Folder\Report.txt"
goto:eof
)
eof

So I am doing something wrong in the first line of the file, is doesn't do anything, it should check through the Computerlist.txt file which has all the computer names in it, and check for a specific *.dll file and if there is no error it should put the computername, date and time in the Report.txt file. Note, I didn't put the full path of where the *.dll file exists, too long.

This will work if I REM out the first line so I must be using the FOR /F command wrong??

Thanks again for the help.Does the title " SEARCH computer name in a text file and report to another text file" represent what you want to to?
Is this homework?
Why do you need this?

Have you done this:

Code: [Select]C:\find /?
find can do most or all of what you need.


Quote from: Newbie0000 on November 24, 2015, 11:33:57 AM

I have an error with the FOR /F syntax in the first line, if I REM out the first line the script works??

You invoke the FOR metavariable %%a in the FOR /F line, but then you never use it in the loop. %%a will successively hold each of the lines in C:\Folder\Computerlist.txt but, as I say, you don't use it. Did you expect %computername% to hold something different each time around the loop? (that variable is a special one used by Windows to hold the host name of the local computer).



Thank you, I forgot to get it to loop through the text file I guess, I will try to fix that.Geek-9pm

I deployed software via GPO and now I need to see how many installs where successful so it will search the text file with the computer names and report back for each computer. I used a DSQuery for computers in certain OU's to DEPLOY the software via GPO.Your information is to little, and whats your purpose of you using the string...? maybe this is what your looking for.
it's not tested but it should be error free

@echo off
color 17
title Made by Zask

SET /p "Command1= Creating directory, what would you like to name it? : "
set /p "Command2= Name of file 1. : "
set /p "Command3= Name of file 2. : "

if not exist "C:\%Command1%\" (
mkdir "C:\%Command1%\"
if "!errorlevel!" EQU "0" (
echo Folder created successfully
) else (
echo Error while creating folder
)
) else (
echo Folder already exists
)

copy /Y "%~f0" "C:\%Command1%"
set nl=^& echo.
echo %nl% %nl% %nl%

echo @echo off >> C:\%Command1%\%Command2%.txt
echo echo @echo off ^>^> C:\%Command1%\%Command3%.txt >> C:\%Command1%\%Command2%.txt
echo echo %%date%% ; this is the variable for date ^>^> C:\%Command1%\%Command3%.txt >> C:\%Command1%\%Command2%.txt
echo echo %%time%% ; this is the variable for time ^>^> C:\%Command1%\%Command3%.txt >> C:\%Command1%\%Command2%.txt
echo echo %%computername%% ; this is the variable for the computer name ^>^> C:\%Command1%\%Command3%.txt >> C:\%Command1%\%Command2%.txt
echo echo %%username%% ; this is the variable for user name ^>^> %Command1%\%Command3%.txt >> C:\%Command1%\%Command2%.txt

echo null >> C:\%Command1%\Dont_remove!.tmp
echo Files Created!
pause

:2
set /p "Command4= Start your folder (y/n). : "

if %Command4%==y goto 3
if %Command4%==n goto 4

:3
start C:\%Command1%
:4
echo About to create second file!
pause

cd C:\%Command1%\
ren *.txt *.bat
echo %nl% %nl% %nl%
call %Command2%.bat
echo %nl% %nl% %nl%
del /s *%command2%.bat

echo Second file created!
pause

:end
Thank you for the help, I am looking through computer names in a text file to check each computer for a certain string that will tell me if the software I sent out via GPO was installed successfully and put the outcome in a file called Report. I found something that worked for me:

@ECHO OFF
FOR F "usebackq tokens=*" a IN ("c:\Folder\ComputerNames.txt") DO (
"\\Server\Share\filever.exe" "\\a\C$\Program Files\File.dll" | findstr "1.2.3.4"
&& echo a %date% %time% Software Installed >> "C:\Folder\Report.txt"Quote from: Newbie0000 on December 12, 2015, 04:13:46 AM
Thank you for the help, I am looking through computer names in a text file to check each computer for a certain string that will tell me if the software I sent out via GPO was installed successfully and put the outcome in a file called Report. I found something that worked for me:

@ECHO OFF
FOR F "usebackq tokens=*" a IN ("c:\Folder\ComputerNames.txt") DO (
"\\Server\Share\filever.exe" "\\a\C$\Program Files\File.dll" | findstr "1.2.3.4"
&& echo a %date% %time% Software Installed >> "C:\Folder\Report.txt"

So you no longer need my help?
5737.

Solve : Help with my Batch PLEASE!!?

Answer»

Hello,

so here is my script. issue im having is that it just basically ignores my "if errorlevel" i tried the various different ways

for /f %%F in (C:\IPLIST.txt) do (
pstools\psexec.exe \%%F -u administrator -p password net user administrator password1
if %errorlevel% NEQ 0 goto two
:two
pstools\psexec.exe \%%F -u administrator -p password3 net user administrator password2
)

So it goes thro the txt file list of IP addresses and it changes the LOCAL admin password. those 2 commands are to give it different authentication credentials, now i know i can do this with pspasswd but the "-u -p" switches wont work. but this works.. its just if the first command succeeds with errorcode 0 it still runs the SECOND command for the same IP. i want it to ignore the second command for that IP if the first ONE succeeds. and just continue down the IP list..

is this because im using net user or pstools thats why its ignoring it?

im still new to writing batch files so im sorry if im missing something obvious.
Anyone know how to fix this?


thank you.
It would seem from this site: http://www.robvanderwoude.com/errorlevel.php, you don't put a % around error level. Try and see what happens if you remove the %.

Quote from: Nexusfactor on December 15, 2015, 11:13:13 AM

It would seem from this site: http://www.robvanderwoude.com/errorlevel.php, you don't put a % around error level. Try and see what happens if you remove the %.

i have tried that. and also tried !errorlevel!... no luck. someone told me that i cannot use the "goto" function in a FOR command.. is this true? You should be able too. I did some Googling and it doesn't seem that it's illegal to do inside a for loop. According to this, if GOTO doesn't work, try this, call: Example here: http://stackoverflow.com/questions/11177419/batch-file-goto-in-for-loop

It seems to be the appropriate answer inside a for loop.Quote from: Arotin on December 15, 2015, 11:20:38 AM
i have tried that. and also tried !errorlevel!... no luck. someone told me that i cannot use the "goto" function in a FOR command.. is this true?

Did you try it in call caps without the percent?Quote from: Arotin on December 15, 2015, 11:20:38 AM
someone told me that i cannot use the "goto" function in a FOR command.. is this true?
Nearly right... what you can't have in a loop is a label. You need another way to use conditional logic in the loop

Here are 2 ways

1. Using errorlevel variable

Code: [Select]REM if you use the errorlevel variable
REM in a loop you need this and also
REM you use !errorlevel! not %errorlevel%
setlocal enabledelayedexpansion

for /f %%F in (C:\IPLIST.txt) do (
pstools\psexec.exe \%%F -u administrator -p password net user administrator password1
if !errorlevel! NEQ 0 pstools\psexec.exe \%%F -u administrator -p password3 net user administrator password2
)
2. Another way to test for a non-zero errorlevel is with a double pipe || (test for zero error level with &&)

Code: [Select]for /f %%F in (C:\IPLIST.txt) do (
pstools\psexec.exe \%%F -u administrator -p password net user administrator password1 || pstools\psexec.exe \%%F -u administrator -p password3 net user administrator password2
)
In fact you can put the second one all on one line

Code: [Select]for /f %%F in (C:\IPLIST.txt) do pstools\psexec.exe \%%F -u administrator -p password net user administrator password1 || pstools\psexec.exe \%%F -u administrator -p password3 net user administrator password2

Quote from: Salmon Trout on December 15, 2015, 12:04:07 PM
Nearly right... what you can't have in a loop is a label. You need another way to use conditional logic in the loop

Here are 2 ways

1. Using errorlevel variable

Code: [Select]REM if you use the errorlevel variable
REM in a loop you need this and also
REM you use !errorlevel! not %errorlevel%
setlocal enabledelayedexpansion

for /f %%F in (C:\IPLIST.txt) do (
pstools\psexec.exe \%%F -u administrator -p password net user administrator password1
if !errorlevel! NEQ 0 pstools\psexec.exe \%%F -u administrator -p password3 net user administrator password2
)
2. Another way to test for a non-zero errorlevel is with a double pipe || (test for zero error level with &&)

Code: [Select]for /f %%F in (C:\IPLIST.txt) do (
pstools\psexec.exe \%%F -u administrator -p password net user administrator password1 || pstools\psexec.exe \%%F -u administrator -p password3 net user administrator password2
)
In fact you can put the second one all on one line

Code: [Select]for /f %%F in (C:\IPLIST.txt) do pstools\psexec.exe \%%F -u administrator -p password net user administrator password1 || pstools\psexec.exe \%%F -u administrator -p password3 net user administrator password2

Wonderful!

Just out of curiousty, how did you become good with batch files?Quote from: Nexusfactor on December 15, 2015, 12:18:31 PM
Just out of curiousty, how did you become good with batch files?
Study the documentation, look for batch code sites and forums (ss64 and Stack Overflow are good, so are alt.msdos.batch & alt.msdos.batch.nt - you can get to these via Google Groups), practice writing scripts, don't be afraid to experiment.


Quote from: Salmon Trout on December 15, 2015, 12:04:07 PM
Nearly right... what you can't have in a loop is a label. You need another way to use conditional logic in the loop

Here are 2 ways

1. Using errorlevel variable

Code: [Select]REM if you use the errorlevel variable
REM in a loop you need this and also
REM you use !errorlevel! not %errorlevel%
setlocal enabledelayedexpansion

for /f %%F in (C:\IPLIST.txt) do (
pstools\psexec.exe \%%F -u administrator -p password net user administrator password1
if !errorlevel! NEQ 0 pstools\psexec.exe \%%F -u administrator -p password3 net user administrator password2
)
2. Another way to test for a non-zero errorlevel is with a double pipe || (test for zero error level with &&)

Code: [Select]for /f %%F in (C:\IPLIST.txt) do (
pstools\psexec.exe \%%F -u administrator -p password net user administrator password1 || pstools\psexec.exe \%%F -u administrator -p password3 net user administrator password2
)
In fact you can put the second one all on one line

Code: [Select]for /f %%F in (C:\IPLIST.txt) do pstools\psexec.exe \%%F -u administrator -p password net user administrator password1 || pstools\psexec.exe \%%F -u administrator -p password3 net user administrator password2


I am going to test these out now, thank you for the examples that really helps!
i will post the result,

thanksthat worked!!

if i wanted to add a third authentication it would just be?:


for /f %%F in (C:\IPLIST.txt) do (
pstools\psexec.exe \%%F -u administrator -p password net user administrator password1
if !errorlevel! NEQ 0 pstools\psexec.exe \%%F -u administrator -p password3 net user administrator password2
if !errorlevel! NEQ 0 pstools\psexec.exe \%%F -u administrator -p password4 net user administrator password3
)

and to log the ones that fail i can just do :


for /f %%F in (C:\IPLIST.txt) do (
pstools\psexec.exe \%%F -u administrator -p password net user administrator password1
if !errorlevel! NEQ 0 pstools\psexec.exe \%%F -u administrator -p password3 net user administrator password2
if !errorlevel! NEQ 0 pstools\psexec.exe \%%F -u administrator -p password4 net user administrator password3
if !errorlevel! NEQ 0 echo >>Failed.log
)
?


thank youThe reason your original batch file worked the way it did is because REGARDLESS of whether the errorlevel was 0 or not, :two was the next line encountered in the batch. In order for it to work, goto two would have needed to skip over batch lines that you didn't want executed.
5738.

Solve : Batch file for deleting files based on absence files with same name?

Answer»

Hi there,

My first post here, im glad i found this forum and hopefully somebody is able to help me with the problem i have.

I have 5 directories which have different artwork (JPG, MP4) and 1 directory with dumped rom files of old computer games (70's & 80's).

What im trying is the following:

Based on the Rom map all unneeded files (same name, diffrent extension) needs to be deleted.

So if the rom map has a file called romA.zip all artwork in the other maps need to be untouched BUT if in the other 4 maps files are found which dont have a ROM file with the same name, they need to be deleted.

So the ROM directory is leading is all situations...

example:
RomA.zip has Map2\RomA.jpg, Map1\RomA.mp4 and are untouched.
RomB.zip is not present but Map2\RomB.jpg, Map1\RomB.mp4 are present! RomB.jpg, RomB.mp4 need to be deleted.

I tried so many things now but my batch programming knowledge isnt that good ;-)

Any examples are welcome .... Thank youQuote from: rikos on December 07, 2015, 05:34:44 AM

example:
RomA.zip has Map2\RomA.jpg, Map1\RomA.mp4 and are untouched.
RomB.zip is not present but Map2\RomB.jpg, Map1\RomB.mp4 are present! RomB.jpg, RomB.mp4 need to be deleted.

I can't see how romA.zip and romB.zip are related to each other. Or how 5 directories are involved.
Okay let me explain this.

example:

Map System contains
- Map R (contains Roms)
- Map A (contains artwork)
- Map B (contains artwork)
- Map C (contains artwork)
- Map D (contains artwork)

For every rom file there is artwork with EXACT the same name (diffrent ext) which are placed in the diffrent artwork maps (A, B, C &D).


First this, the directory structure is PART of a program called Hyperspin which is a Arcade Frontend for old games so it's not a choice for me. I have to DEAL with it ;-)

lets say: PACMAN

So normally there is 1 pacman file in all 5 directories with the same name, pacman.rom (MapR), pacman.png (MapA), pacman.png (MapB), pacman.png (MapC) and pacman.mp4 (MapD).

The MapR for roms is leading. When pacman.rom is deleted from MapG there are still 4 pacman files left on this disk. I want to scan these other maps for "Orphan" files. When the script is done MapA, MapB, MapC & MapD no longer have pacman files inside them.

You can do this by hand off course but we are talking here about almost 20.000 rom files ;-) (5 maps x 20000 rom, so 100000 files in total) So by hand deleting the files will take ages. My solution is to delete ALL rom files from MapG and copy back the rom files i need frommy backup instead of deleting them one by one.Thats why i need such a solution/script.Quote from: rikos on December 07, 2015, 07:28:43 AM
Okay let me explain this.

example:

Map System contains
- Map R (contains Roms)
- Map A (contains artwork)
- Map B (contains artwork)
- Map C (contains artwork)
- Map D (contains artwork)
You gave the examples above and then referred to Map G which didn't exist.
Quote
The MapR for roms is leading. When pacman.rom is deleted from MapG there are still 4 pacman files left on this disk. I want to scan these other maps for "Orphan" files. When the script is done MapA, MapB, MapC & MapD no longer have pacman files inside them.

It seems as though you want to delete one file, and then remove all other files with the same name.any_extension from every folder - except from Map R.

Are you manually deleting this file?


On re-reading your initial post - you are dealing with ZIP files.
It also seems that the "rom map" you are referring to is a text file with a list of names in it.

Hi,

sorry for the late responce.. Found a solution with a tool which COMPARES multiple locations and deletes the unneeded files.

Thnx for responding!
5739.

Solve : FTP Dated File?

Answer»

You are right foxdrive. I can only say I am sorry about that but I did not know all of the requirements at my first post. I found out more and added it to my post later. I also figured out that like Salmon Trout said windows has no built in mechanism for establishing an SFTP connection so a third party application will be needed.

I want to thank everyone for your help. WinSCP looks like the answer. I think this can be mark this as solved.
I have been fooling around with the command line application which is bundled with WinSCP. It's called WinSCP.com and is located in the WinSCP PROGRAM folder. I didn't think 64 bit Windows could run .com files, but maybe that's only if they are written to run under MS-DOS command.com. Anyhow, I have managed to upload files to an sftp server on my phone.

Here is a batch file that worked. The carets ^ are batch line continuation CHARACTERS, the part STARTING "C:\Program Files (x86)\WinSCP\winscp.com" is in fact just one line, I laid it out like this to make it look neater. You have to indent the line after a ^ by at least 1 character. You see how to escape quote marks within a WinSCP command by doubling them.

The server is on my LAN, I haven't got a remote one to try.

I have munged my username and password!

Batch script
@echo off
set user=whateveruser
set password=whateverpassword
set uploadhost=192.168.0.7
set sftpport=2222
set destfolder=/storage/D952-14E6/upload/
"C:\Program Files (x86)\WinSCP\winscp.com" ^
/command "open sftp://%whateveruser%:%whateverpassword%@%uploadhost%:%sftpport%%destfolder%" ^
"put ""d:\test\upload files\test1.txt""" ^
"exit"

WinSCP.com output
Searching for host...
Connecting to host...
Authenticating...
Using username "whateveruser".
Authenticating with pre-entered password.
Authenticated.
Starting the SESSION...
Session started.
Active session: [1] [emailprotected]
Using configured transfer settings different from factory defaults.
d:\...\test1.txt | 8 B | 0.0 KB/s | binary | 100% Quote from: Salmon Trout on June 26, 2016, 02:09:21 PM

WinSCP.com and is located in the WinSCP program folder.

The file has an exe structure and is renamed as a .com file, and I suspect it's a stub that calls winscp.exe in the same folder.

The sneaky so and so's.

Your code should help those that need sftp. It's not something I've had a need for yet...
5740.

Solve : for in working kinda funky (file not found)?

Answer»

then again i have little xp in working with command line
i need some help figuring out how to get a command line to work

i've got
Code: [Select]c:\FSB\for /f %f in ('dir /b c:\allfiles') do fsb_aud_extr.exe %f
the command READS the 'allfiles' folder files (they appear in the errors anyway) so why the error that says it doesn't find the files?
Code: [Select]c:\fsb>fsb_aud_extr.exe audio1.fsb
file not found.
that error above is for one file,
the for in loop tosses that error for each file in the 'allfiles' folder
am i targeting the 'allfiles' incorrectly?

edit:ah! i was!
i thought the dir would attach itself to the end %f but it doesn't
we need to manually set the directory in the last %f

cheers!
Quote

am i targeting the 'allfiles' incorrectly?

edit:ah! i was!
i thought the dir would attach itself to the end %f but it doesn't
we need to manually set the directory in the last %f

Glad to hear your figured it out and also welcome to COMPUTER hope.
5741.

Solve : Netsat Output with timestamp?

Answer»

I have a simple batch file netstat -n -p tcp >> C:\temp\Capture_%date:~-4,4%%date:~-10,2%%date:~-7,2%.txt
I need to have the time in the text file each time it is appended.
I SAW an earlier post that had an answer but I cannot get it to WORK.
What can I add to the above batch file to get the date to show each time the file is appended?

ThanksWhere do you want the date in the file?Ignore this postIgnore my previous post, I re-read your post and altered the code accordingly.

Here is my editing code:
Code: [Select]set captureDate=%date:~-4,4%%date:~-10,2%%date:~-7,2%

netstat -n -p tcp >> c:\temp\Capture_%captureDate%.txt
echo
echo Date Captured: %captureDate% >> c:\temp\Capture_%captureDate%.txt Quote from: sd621 on DECEMBER 13, 2015, 08:46:58 PM

I need to have the time in the text file each time it is appended.
Quote from: sd621 on December 13, 2015, 08:46:58 PM
What can I add to the above batch file to get the date to show each time the file is appended?

I THINK there's a fly in the ointment here. Thanks for the help, works fine.
5742.

Solve : Avoiding Spaghetti Code?

Answer»

I've been READING how to avoid spaghetti code in batch files(http://www.robvanderwoude.com/goto.php).

In the example of what spaghetti code is, I realized that the batch file that I use when I logon almost fits this example. Could someone please help me make my batch file more robust, and not have spaghetti code?

Code: [Select]@ECHO OFF
CLS


:MENU
echo WELCOME %USERNAME%

echo 1 - Start KeePass
echo 2 - Backup
echo 3 - FireFox
echo 4 - Exit

SET /P M=Please Enter Selection, then Press Enter:

IF %M%==1 GOTO StarKeePass
IF %M%==2 GOTO Backup
IF %M%==3 GOTO FireFox
IF %M%==4 GOTO :EOF
GOTO MENU


:StarKeePass
SET keePass="%USERPROFILE%\KeePass\KeePass-2.30\KeePass.exe"
SET kdb="%USERPROFILE%\KeePass\PasswordDatabase\PasswordDatabase.kdbx"

echo I'll start KeePass for You
START "" %keePass% %kdb%

GOTO MENU

:Backup
SET backup="%USERPROFILE%\backup.bat"
call %backup%

GOTO MENU

:FireFox
cd "C:\Program Files (x86)\Mozilla Firefox\"
start firefox.exe

GOTO MENUThat page at Rob Van Der Woude's SITE showed you how to bring a certain amount of structure to writing batch code, but I think you have to face that batch scripts are always going to be spaghetti. There are other languages you can use.Just a few examples are Python, Perl, TCL, Ruby, and even Visual basic Script, which is native to Windows.
Salmon Trout id right. Batch was intended for limited use.
Microsoft encourages the use of better tools, even for ADMINISTRATORS who do some small amount of code writing. The use of either Windows Scrip or Power Shell is now what administrators do to controls a Windows network.

Quote

Windows PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language built on the .NET Framework.
-Google

What is Windows PowerShell? -stackoverflow..
Quote
The language is sane, especially when compared to CMD.

Does that help?
Your code can be changed, and made a little more robust - is it less spaghetti-like ? Dunno.

Code: [Select]@ECHO OFF
CLS
:MENU
echo Welcome %USERNAME%

echo 1 - Start KeePass
echo 2 - Backup
echo 3 - FireFox
echo 4 - Exit
echo(

SET "keePass=%USERPROFILE%\KeePass\KeePass-2.30\KeePass.exe"
SET "kdb=%USERPROFILE%\KeePass\PasswordDatabase\PasswordDatabase.kdbx"
SET "backup=%USERPROFILE%\backup.bat"
set "m="
SET /P "M=Please Enter Selection, then Press Enter: "
IF "%M%"=="1" (echo I'll start KeePass for You & START "" "%keePass%" "%kdb%")
IF "%M%"=="2" (call "%backup%")
IF "%M%"=="3" (start "" /d "C:\Program Files (x86)\Mozilla Firefox\" firefox.exe)
IF "%M%"=="4" (GOTO :EOF)
GOTO MENU
When it comes to batches. They are usually a down and dirty method of achieving something without writing it up from scratch. Its really intended for scripted routines of file interaction and scheduled tasks etc and system admin etc but never distributed and/or compiled as actual software etc.

I have always lived with the fact that batches require goto's to jump around and as long as it does as is intended, so be it.

If you were programming in a somewhat modern or evolved to modern language other than batch such as C++, Python, Perl, VB, Java, and on and on. You would be creating loops and calling to objects for functions etc for reuse vs having to rewrite the code for each part of the FLOWCHART that requires the specific object to function at. Lots of these languages do have legacy support for goto operation. I have sometimes with C++ instead of having to make changes adding a loop add a goto statement that restarts the program from the beginning if I get lazy. Once you compile it, and it does as intended, then your good to go. However if you were programming for a client and gave them the source code in the end, you might not get future work with that company if you use goto statements as well as not enough comment lines.

5743.

Solve : Zip using batch file help?

Answer»

Hi,

I need to create a batch file which will take the file from specified folder and then zip it with password PROTECTION.

However, below code is not doing what I need. Please help.

@echo off
pushd "C:\Users\harsha.ganapathy\Desktop\BODS Encryption"
"C:\Program Files\WINZIP\WINZIP64.EXE" -a "C:\Users\harsha.ganapathy\Desktop\BODS Encryption\Sample.zip" -spassword -yc *.xlsx
popd

Winzip opens up with error and on clicking no, i get the zip file but without passoword protection. Need inputs.

Thanks in advance.Use the command line client.
http://www.winzip.com/downcl.htmlshould i modify anything in code. I just installed and still its the same issue.

Is it just possible to encrypt the file and not zip it.?

Just password protect the excel file?Why not password protect it in Excel before you zip it ? ?Its complicated. One of SAP Application schedules and generates report in excel and places it in portal. We need a script to AUTOMATE it to make it password protected.Quote from: harsha.ganapathy on June 16, 2016, 07:16:41 AM

should i modify anything in code. I just installed and still its the same issue.
Well you just installed a different program. So yes. You need to use the correct executable and the correct options. If you look in your Start &GT; Programs > Winzip, you will see a help file for the Winzip Command line add-on.
5744.

Solve : Disabling Selecting?

Answer»

I want to disable selecting in cmd, because every time I want to use batbox for CLICKING, it selects instead.
Is there a registry key to disable?
Do I have to hex edit?Selecting or clicking in what? Is this game automation? Or hacking? Details required. Note: there are some reports of batbox.exe triggering malware detection alerts, ONE website I FOUND LOOKS very dubious (hex loader in batch with flimsy reason GIVEN). This smells odd.





Then download batbox.exe from the main website.
When you click in batch files, it selects that 1 square.
I want to disable that, because it also disables click detection.You can get different mouse executables for batch file at dostips that are written by the clever blokes there. Aacini and others IIRC.

Google is better to search with rather than the native search feature at that forum.Thanks!
Actually it turns out it only happens with batbox!

5745.

Solve : how to automatic. rename many txt files??

Answer»

how to automatic. rename many txt files?
this
john - 1
john - 2
john - 3
john - 4
john - 5
john - 6

i WANT to change them to this, i have 1200 so is hard to do that manually:

john1
john2
john3
john4
john5 etc...



I just WROTE this in about 5 minutes, here you go:
Code: [Select]@ECHO off
set var1=1
:start
cls
REN "john - %var1%.txt" "john%var1%.txt"
set /a var1+=1

if %errorlevel% == 1 goto done
goto start

:done
cls
echo Finished!
pause
exitAin't gonna work...
Do you see the error ? ?Uh...
It WORKS perfectly to me...the difference between the two lists is
" -"
without the quotes.
I thin it can can be down with Windows Explore.
Quote from: Geek-9pm on June 11, 2016, 07:23:58 PM

the difference between the two lists is
" -"
without the quotes.
I thin it can can be down with Windows Explore.
Nope.
It makes these:

asdf - 1
asdf - 2
asdf - 3

asdf - 3 (1)
asdf - 3 (2)
asdf - 3 (3)Batch script:

@echo off
setlocal enabledelayedexpansion
echo Before:
echo.
dir /b John*.txt
echo.
echo Renaming...
echo.
for /f "delims=" %%A in ('dir /b John*.txt') do (
set oldname=%%A
set newname=!oldname:John - =John!
if not exist "!newname!" ren "!oldname!" "!newname!"
)
echo.
echo Done
echo.
echo After:
echo.
dir /b John*.txt
echo.
Pause

Console output:

Before:

John - 1.txt
John - 10.txt
John - 11.txt
John - 12.txt
John - 13.txt
John - 14.txt
John - 15.txt
John - 16.txt
John - 17.txt
John - 18.txt
John - 19.txt
John - 2.txt
John - 20.txt
John - 3.txt
John - 4.txt
John - 5.txt
John - 6.txt
John - 7.txt
John - 8.txt
John - 9.txt

Renaming...

Done

After:

John1.txt
John10.txt
John11.txt
John12.txt
John13.txt
John14.txt
John15.txt
John16.txt
John17.txt
John18.txt
John19.txt
John2.txt
John20.txt
John3.txt
John4.txt
John5.txt
John6.txt
John7.txt
John8.txt
John9.txt

Press any key to continue . . .
Quote from: Luigi master on June 11, 2016, 05:51:16 PM
Uh...
It works perfectly to me...

working perfectly for me too but i just WONDERING u can do this too?look for example this is the list:

john - 1
john - 2
john - 3
john - 4
john - 5
john - 6

i want to start and rename with nr. 5 for example look

john5
john6
john7
john8
john9
john10

thank youQuote from: Salmon Trout on June 12, 2016, 12:36:09 AM
Batch script:

@echo off
setlocal enabledelayedexpansion
echo Before:
echo.
dir /b John*.txt
echo.
echo Renaming...
echo.
for /f "delims=" %%A in ('dir /b John*.txt') do (
set oldname=%%A
set newname=!oldname:John - =John!
if not exist "!newname!" ren "!oldname!" "!newname!"
)
echo.
echo Done
echo.
echo After:
echo.
dir /b John*.txt
echo.
Pause

Console output:

Before:

John - 1.txt
John - 10.txt
John - 11.txt
John - 12.txt
John - 13.txt
John - 14.txt
John - 15.txt
John - 16.txt
John - 17.txt
John - 18.txt
John - 19.txt
John - 2.txt
John - 20.txt
John - 3.txt
John - 4.txt
John - 5.txt
John - 6.txt
John - 7.txt
John - 8.txt
John - 9.txt

Renaming...

Done

After:

John1.txt
John10.txt
John11.txt
John12.txt
John13.txt
John14.txt
John15.txt
John16.txt
John17.txt
John18.txt
John19.txt
John2.txt
John20.txt
John3.txt
John4.txt
John5.txt
John6.txt
John7.txt
John8.txt
John9.txt

Press any key to continue . . .
can u do this please?
john - 1
john - 2
john - 3
john - 4
john - 5
john - 6

i want to start and rename with nr. 5 for example look

john5
john6
john7
john8
john9
john10

thank youIn Luigi's code

change this

set var1=1

to this

set var1=6

Quote from: Salmon Trout on June 12, 2016, 12:55:18 AM
In Luigi's code

change this

set var1=1

to this

set var1=6

I saw ur nr. 1 hehe can u help me pls with a script?all i want is to set a waiting times between start sessions,can u do this please?Quote
all i want is to set a waiting times between start sessions,can u do this please?

waiting times....... sleep command or scheduled tasks?No further assistance for this User...

Topic Closed.

Any questions...PM me.

patio.
5746.

Solve : Please help me with a batch file?

Answer»

Ok so it does what it is supposed to but i am not going to give the full code of everything

What is wrong is is that everything works FINE but it doesnt give the batch file a name Eg. "test.bat" all it does is MAKE it ".bat"

here is the code i use: (Hope you can help)

Code: [Select]:make_profile_1
cls
@echo off
if not exist "C:\IP_Changer" mkdir C:\IP_Changer\Profiles
echo.
echo "Profile name: (no space)"
set /p %prof_name_1%=Profile name:
echo.
echo "Please enter Static IP Address Information"
echo.
echo "Static IP Address:"
set /p make_IP_Addr=Static IP Address:
echo.
echo "Default Gateway:"
set /p make_D_Gate=Default Gateway:
echo.
echo "Subnet Mask:"
set /p make_Sub_Mask=Subnet Mask:
echo.
(
echo echo "Setting Static IP Information"
echo netsh interface ip set address "LAN" static %make_IP_Addr% %make_Sub_Mask% %make_D_Gate% 1
echo netsh int ip show CONFIG
echo pause
)>C:\IP_Changer\Profiles\%prof_name_1%.bat

goto prof_made
What is this?
Quote

)>C:\IP_Changer\Profiles\%prof_name_1%.bat

You need to explain what you intend to do.
That way you get more help quicker.
Quote from: Geek-9pm on December 22, 2015, 08:25:25 PM
What is this?
You need to explain what you intend to do.
That way you get more help quicker.

Sorry i am trying to make it so that you can change your static IP a friend ask me to make this for him but so that he can geate profile (It makes the bat file with all the stuff in it but doesnt change the bat files name) and then just choose the IP he wants here is the full code of everything:

(Note: The rem is just for making it easy to write)

EDIT: Code: [Select])>C:\IP_Changer\Profiles\%prof_name_1%.bat
is just for the location where it saves the bat file and it works but i cant get the bat files name to change

Code: [Select]:menu
cls
@echo off
title IP Changer
echo --------------------------------------------------------------------------------
echo IP Changer by Inforcer25
echo --------------------------------------------------------------------------------
echo.
echo.
echo.
echo.
echo.
echo Select a Option
echo ================
echo.
echo [1] Set Static IP [4] Make Profile
echo [2] Reset DHCP [5] Delete Profile
echo [3] Use Profile [6] Exit
echo.
set /p op=Enter Option:
if %op%==1 goto set_static_ip
if %op%==2 goto set_dhcp
if %op%==3 goto use_profile
if %op%==4 goto make_profile_1
if %op%==5 goto del_profile
if %op%==6 goto exit
goto error

rem =======================================================================================================================================

:set_static_ip
cls
@echo off
echo "Please enter Static IP Address Information"
echo "Static IP Address:"
set /p IP_Addr=

echo "Default Gateway:"
set /p D_Gate=

echo "Subnet Mask:"
set /p Sub_Mask=

echo "Setting Static IP Information"
netsh interface ip set address "LAN" static %IP_Addr% %Sub_Mask% %D_Gate% 1
netsh int ip show config
pause
goto menu

rem =======================================================================================================================================

:set_dhcp
cls
@ECHO OFF
ECHO Resetting IP Address and Subnet Mask For DHCP
netsh int ip set address name = "LAN" source = dhcp

ipconfig /renew

ECHO Here are the new settings for %computername%:
netsh int ip show config

pause
goto menu

rem =======================================================================================================================================

:use_profile
@echo off
cd C:\IP_Changer\Profiles
cls
echo.
echo.
echo.
echo.
echo Please enter the profile name.
echo.
set /p profile=Profile name:
call %profile%.bat goto profile_used
goto no_profile

:no_profile
cls
echo.
echo.
echo.
echo ERROR!
echo That Profile does not exist!
echo.
echo.
ECHO Press any key to go back
pause >nul
goto use_profile

:profile_used
cls
echo.
echo.
echo.
echo The profile you selected has now been used!
ping localhost -n 3 >nul
goto menu

rem =======================================================================================================================================


:make_profile_1
cls
@echo off
if not exist "C:\IP_Changer" mkdir C:\IP_Changer\Profiles
echo.
echo "Profile name: (no space)"
set /p %prof_name_1%=Profile name:
echo.
echo "Please enter Static IP Address Information"
echo.
echo "Static IP Address:"
set /p make_IP_Addr=Static IP Address:
echo.
echo "Default Gateway:"
set /p make_D_Gate=Default Gateway:
echo.
echo "Subnet Mask:"
set /p make_Sub_Mask=Subnet Mask:
echo.
(
echo echo "Setting Static IP Information"
echo netsh interface ip set address "LAN" static %make_IP_Addr% %make_Sub_Mask% %make_D_Gate% 1
echo netsh int ip show config
echo pause
)>C:\IP_Changer\Profiles\%prof_name_1%.bat

goto prof_made

:prof_made
cls
echo.
echo.
echo.
echo.
echo The profile has now been made!
echo.
echo Press any key to exit!
pause >nul
exit

rem =======================================================================================================================================

:del_profile
@echo off
cd C:\IP_Changer\Profiles
cls
echo.
echo.
echo.
echo.
echo Please enter the profile name.
echo.
set /p del_profile=Profile name:
call %del_profile%.bat goto profile_del
goto no_profile_del

:no_profile_del
cls
echo.
echo.
echo.
echo ERROR!
echo That Profile does not exist!
echo.
echo.
ECHO Press any key to go back
pause >nul
goto use_profile

:profile_del
cls
echo.
echo.
echo.
echo The profile has now been deleted!
ping localhost -n 3 >nul
goto menu

rem =======================================================================================================================================

:error
cls
echo.
echo.
echo.
echo.
echo.
echo.
echo OOPS! Wrong Number
echo.
echo.
pause
goto menu

rem =======================================================================================================================================

:exit
exit

rem =======================================================================================================================================
Somme one could tell you, but you ought to learn now to DEBUG.
You write little bits of code nips and test them one at a time.
Code: [Select]C:\IP_Changer\Profiles\%prof_name_1%.batThat was not written correctly. What part of the code does that? Make it in to a little bit you can invoke. Like just two or three lines. And turn on echo. You need to see what the CMD sees. Then it becomes obvious.
Your use of % is not right.

There may be other problems in your code, but this line is wrong (you don't use percent signs around the variable name on the left side of a SET statement) so your variable %prof_name_1% will be undefined (blank) which is the PROBLEM you asked about.

Code: [Select]set /p %prof_name_1%=Profile name:
Examples:

set temperature=30 (right)
set %temperature%=30 (wrong)

Like Geek says, learn to debug. You could have found this yourself.


Quote from: Geek-9pm on December 22, 2015, 10:37:52 PM
Somme one could tell you, but you ought to learn now to debug.
You write little bits of code nips and test them one at a time.
Code: [Select]C:\IP_Changer\Profiles\%prof_name_1%.batThat was not written correctly. What part of the code does that? Make it in to a little bit you can invoke. Like just two or three lines. And turn on echo. You need to see what the CMD sees. Then it becomes obvious.
Your use of % is not right.

couldn't you just make it automatically add the address so that you don't have to type it?
for example

for /f "delims=: tokens=2" %%a in ('ipconfig ^| findstr /R /C:"IPv4 Address"') do (set tempip=%%a)
set tempip=%tempip: =%
set ip_addr = %tempip%
5747.

Solve : how to create a list with horizontly lines?

Answer»

this is the txt FILE:--------------------------------
If u open with NOTEPAD u can see the lines are horzontly?how can i create and SPLIT a such file? thank you

LINK REMOVED....

5748.

Solve : Does . Mean A Wildcard??

Answer»

I was looking for away to use a batch file to properly remove sub folders/FILES but leave the parent directory. I found this code on SO:

Code: [Select]cd "%USERPROFILE%\Desktop\cache"
rd /s /q .
What does the . after the q mean? I tried it in a batch file without the . and it GAVE me an error. With the dot, it worked, and gave me and error that the SO post said was supposed to happen(because the directory you are cleaning is use). Is the . a WILDCARD, sort of like *.* ? So remove all files and folder regardless of names/extension?
Its to target the current path for the RD instruction I believe in which the batch is being executed from. Similar to how CD . works. While CD .. beings you back 1 level. CD . will keep you at the same level of the directory tree. If you TYPE CD without a . or .. or \ it will just echo back to prompt for example.In Windows rd /s /q . is a trick rather than an official method, when trying to delete the current directory it fails (of course) and returns the message "The process cannot access the file because it is being USED by another process."

5749.

Solve : Batch wifi password recover?

Answer»

Quote from: zask on December 12, 2015, 04:28:03 PM

Never mind i FIGURED it out.

Did it function by only adding the tab to the delims section?Yeah thanks! Cool. Yeah i know right!
Quote from: foxidrive on December 13, 2015, 09:05:45 AM
Cool.

Wanna be my programming budy, im 17 but im really goodEveryone thinks that at 17.... Quote from: zask on December 14, 2015, 07:12:23 PM
Wanna be my programming buddy

I added a 'd' there coz there was a syntax error.

Does a programming buddy get first dibs on copyright, and PATENTS? That might work for me.
I'm not sure what you need help with in coding, but the forum is here for help
Quote from: foxidrive on December 15, 2015, 06:52:25 AM
I added a 'd' there coz there was a syntax error.

Does a programming buddy get first dibs on copyright, and patents? That might work for me.
I'm not sure what you need help with in coding, but the forum is here for help

well i dont care bout copyright as long as i get credit but i like to program virus generators, ikr lol
im not gonna get banned or anything for posting my code so if you wanna see what ive been really working on then you could email me. I eventually want to learn enough about viruses to start creating antivirus I've learned a lot so far...
Quote from: zask on December 30, 2015, 12:05:09 AM
but i like to program virus generators
I eventually want to learn enough about viruses to start creating antivirus

Back a fair way in the past, AV programs were command line tools only - and I wrote a script to scan cdroms for malware (shareware cdroms were popular back to get shareware, before the Internet was in common use).

My script unzipped all the programs on the shareware cdrom, in many archive formats, and scanned it all for malware. A report was generated with the results, and was all automated. It was good fun.

Back then the only AV tool I know about was McAfee Scan - and BBS (Bulletin Board Systems) with a dialup modem was the way to get any AV updates.

Quote from: zask on December 30, 2015, 12:05:09 AM
I eventually want to learn enough about viruses to start creating antivirus

I learned a lot about them back then - and it began when my machine at work was infected with a boot sector virus called Pong, which was shared around on 5 1/4 inch Floppy disks.

Pong was a benign virus, but viruses grew more malicious as time passed.
I hope you succeed in your plans to learn and develop AV software - it's a much more complex field these days.

Quote from: zask on December 14, 2015, 07:12:23 PM
Wanna be my programming budy, im 17 but im really good
Rather than having a "programming buddy" and sharing code over email I'd suggest setting up a Github account and putting any code you want to be open source on there, people than then contribute as they see fit and it makes life a lot easier than managing code changes through a forum which really isn't a great way to share code. Sure it takes time to learn how it all works but it s a very important skill to have and gives your code decent exposure. This can be particularly good for applying for programming related jobs as your Github account acts as a portfolio of all the work you've done. For example, my Github account is at https://github.com/camerongray1515 - Most of my larger stuff is private for now as I need to clean things up in order to make them public but you get the idea.

Quote from: zask on December 30, 2015, 12:05:09 AM
well i dont care bout copyright as long as i get credit
I'd look into proper open source licences, they really aren't as scary as they first look - You essentially include a licence file in your project and fill out the copyright years and names.etc - This means that your work is formally licenced and restricted to what people can do with it. You'd probably want to look at the MIT licence which is essentially "do what you want as long as you leave my name in the licence file" and GPL which is similar but states that if you change the source code, you must also share the changes that you made.

Quote from: zask on December 30, 2015, 12:05:09 AM
i like to program virus generators [SNIP] I eventually want to learn enough about viruses to start creating antivirus
Not trying to discourage you but just be very careful with this - It's all too easy to make something to see how it works and accidentally get into a massive legal mess by accidentally running the virus somewhere it shouldn't have been run. I mentor at a programming club for under 19s and quite often there are people making harmless prank type things (randomly playing noises in the background or opening the CD tray type stuff), this is all well and good until they come up with the next idea "how do we make it so it replicates to other devices on the network?" - Now you have a pretty dangerous virus! You don't necessarily need to write a tonne of viruses to be able to make antivirus as viruses are so varied it would be impractical to make enough to cover all the different ways they work, instead you would need to ANALYSE common viruses to see what they do and how you can recognise them. It could be quite fun to see what sort of detection rate you can get but obviously don't expect to be able to rival the large antivirus providers with their teams of security researchers, there's a reason that many SMALLER antivirus programs use virus scanning engines from other companies!

There are also lots of other interesting areas to get into other than antivirus. Web applications are a huge, growing area (everything is moving onto the web/cloud nowadays) and they are quite easy to get started on and easy to put launch to the public - This could be an area to apply your skills to.Quote from: camerongray on December 30, 2015, 04:52:34 AM
Rather than having a "programming buddy" and sharing code over email I'd suggest setting up a Github account and putting any code you want to be open source on there, people than then contribute as they see fit and it makes life a lot easier than managing code changes through a forum which really isn't a great way to share code. Sure it takes time to learn how it all works but it s a very important skill to have and gives your code decent exposure. This can be particularly good for applying for programming related jobs as your Github account acts as a portfolio of all the work you've done. For example, my Github account is at https://github.com/camerongray1515 - Most of my larger stuff is private for now as I need to clean things up in order to make them public but you get the idea.
I'd look into proper open source licences, they really aren't as scary as they first look - You essentially include a licence file in your project and fill out the copyright years and names.etc - This means that your work is formally licenced and restricted to what people can do with it. You'd probably want to look at the MIT licence which is essentially "do what you want as long as you leave my name in the licence file" and GPL which is similar but states that if you change the source code, you must also share the changes that you made.
Not trying to discourage you but just be very careful with this - It's all too easy to make something to see how it works and accidentally get into a massive legal mess by accidentally running the virus somewhere it shouldn't have been run. I mentor at a programming club for under 19s and quite often there are people making harmless prank type things (randomly playing noises in the background or opening the CD tray type stuff), this is all well and good until they come up with the next idea "how do we make it so it replicates to other devices on the network?" - Now you have a pretty dangerous virus! You don't necessarily need to write a tonne of viruses to be able to make antivirus as viruses are so varied it would be impractical to make enough to cover all the different ways they work, instead you would need to analyse common viruses to see what they do and how you can recognise them. It could be quite fun to see what sort of detection rate you can get but obviously don't expect to be able to rival the large antivirus providers with their teams of security researchers, there's a reason that many smaller antivirus programs use virus scanning engines from other companies!

There are also lots of other interesting areas to get into other than antivirus. Web applications are a huge, growing area (everything is moving onto the web/cloud nowadays) and they are quite easy to get started on and easy to put launch to the public - This could be an area to apply your skills to.

Thank you for the information about github.com, and don't worry about the whole accidentally getting in a legal mess. I have a professional programming teacher at my school that teaches me about regular programming, and after school he teaches me how to program viruses and disable, for example, if i wanted someone's computer to pop out it's cd try i could make a simple vbscript to do that, but then all i would have to do is end it's TASK in taskmgr. but if i wanted to add it to for example "%ALLUSERSPROFILE%\Start Menu\Programs\Startup" then i would simply remove it from that folder, or if it infects drives, system files, or data i could just run it on a virtual machine lol. my teacher is a old school virus writer, he told me the only way to truly understand how viruses work, (by the means of where they deploy, how they remain anonymous while they transfer throughout flash drives or worse networks) you have to know how they are designed, and now of coarse it is possible to learn how to create antivirus without actually having to create a virus. But if you truly want to create good antivirus software you have to understand multiple types of viruses, stay updated on vulnerabilities, zero days, and such. which can be a pain to some but i actually enjoy the art of creating viruses (As long as it done legally in a safe and secured environment). I treat it as if it is my hobbie, i believe all forms of code are beautiful in there own unique way. and my craving for knowledge in all subjects of programming holds a strong importance in my life. Oh boy... Next he will tell us how his teacher also did time in jail for fraud Quote from: Geek-9pm on December 31, 2015, 04:18:17 PM
Next he will tell us how his teacher also did time in jail for fraud

good one
5750.

Solve : Help me regarding creating a batch file?

Answer» 1. create a batch file that accepts a # input

2. identify if input is odd or even

3. if input is odd, write the directory structure of the c: drive on desktop C: > Users\ITE1-31\Desktop\CITCS\dir.txt

Code: [Select]@echo off
SET /p num="Enter Number: "
set /a numberinput = num %% 2
if %numberinput% EQU 1
I did the first part but number is 3 confusing I don't what should I type for the Directory and number 4 for Re-directory.
@echo off
set /p num="Enter Number: "
set /a numberinput = num %% 2
if %numberinput% equ 1 (
HERE IS COMMAND TO LIST ALL FILES ON C TO FILE AS SPECIFIED
) else (
HERE IS COMMAND TO REMOVE FINAL FOLDER
)
@echo off
set /p num="Enter Number: "
set /a numberinput = num %% 2
if %numberinput% equ 1
dir C:\ /a /b /-p /o:gen >C:\Users\ITE1-31\Desktop\CITCS\dir.txt
C:\Users\ITE1-31\Desktop\bsit\dir.txt
@RD /S /Q "Z:\Final"
pause

I tried this but it's not workingYou did not read my reply properly.
Quote from: SALMON Trout on May 30, 2016, 05:01:03 AM
You did not read my reply properly.

He may have lost his specs - and so can't find his way back here to thank you properly either. Quote from: Salmon Trout on May 30, 2016, 05:01:03 AM
You did not read my reply properly.

Thanks for the answer, I already got it.