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.

7251.

Solve : If not statement?

Answer»

So first of im back after about a year and trying to finish off the game i started in DOS whiles i have some free time over christmas, doubt anyone will remember me but i remember a few of your names hey all.
Ok so basically I was wondering if this statement is correct, I wanted a if not statement with an and.

Here is the code at the moment:
Code: [Select]if not %MonsterName%==- (
set Flag=Y
)

and here is what i want, not sure if this will work tho, been a long time away from dos
Code: [Select]if not %MonsterName%==- (
if not %MonsterName%==Dead (
set Flag=Y
)
)
So what I want it to do is check if the variable MonsterName equals - or Dead, and if so to set Flag to Y
Thanks in advanced and merry christmas!You wrote "what I want it to do is check if the variable MonsterName equals - or Dead, and if so to set Flag to Y".

Your suggested code looks like it will check if MonsterName is not - and not Dead, and if so set Flag to Y.

That is not the same as what you wrote. So could you be a bit more clear about what you want?


Yea sorry, I did mean " not Dead, and not -" so the flag = Y

As in, if the character does have a name set and is not dead then = YBut you can work it out for yourself. Just write a few LINES of experimental code and play around until you get the results you desire.

For example:

test1.bat

@echo off
:LOOP
set Flag=N
set /p MonsterName="(Q to quit) What is MonsterName? "
if "%MonsterName%"=="Q" goto end
if not "%MonsterName%"=="Dead" (
if not "%MonsterName%"=="-" (
set Flag=Y
)
)
echo Flag=%Flag%
goto loop
:end


C:\>test1.bat
(Q to quit) What is MonsterName? John
Flag=Y
(Q to quit) What is MonsterName? +
Flag=Y
(Q to quit) What is MonsterName? -
Flag=N
(Q to quit) What is MonsterName? Dead
Flag=N
(Q to quit) What is MonsterName? Mary
Flag=Y
(Q to quit) What is MonsterName? Q

C:\>

Nice thanks for the help Happy christmas

- edit

Just noticed you put quotation marks around - and Dead. What difference does that have on the code? Quote from: Risen91 on December 23, 2012, 01:54:10 PM

Just noticed you put quotation marks around - and Dead. What difference does that have on the code?

It is a fairly standard practice (or habit) that many batch scripters have.

Consider the following:

if %var%==x echo Hooray
if %1==debug echo %date% %time% script start > debug.txt

Because variables are expanded, if %var% or %1 were undefined (i.e. empty) then they will EXPAND to (literally) nothing and the script will CRASH (bomb out) when those lines are executed.

these...
if ==x echo Hooray
if ==debug echo %date% %time% script start > debug.txt
... are both ILLEGAL lines.

To protect against that ever happening, many people use enclosing symbols such as quotes around both comparison terms of an IF test. They don't have to be quotes, they just have to be the same so these all work

if "%var%"=="CAT" echo Meow
if [%var%]==[CAT] echo Meow
if {%var%}=={CAT} echo Meow
if abc%var%xyz==abcCATxyz echo Meow

@OP: The other important feature of double quotes is that it handles long filename elements like spaces:

This works:

Code: [Select]@echo off
(set var=DARK CAT)

if "%var%"=="DARK CAT" echo Meow

These three don't work.

if [%var%]==[DARK CAT] echo Meow
if {%var%}=={DARK CAT} echo Meow
if abc%var%xyz==abcDARK CATxyz echo Meow

That's why batchers most often use double quotes.
7252.

Solve : Help with attrib command inside a FOR loop?

Answer»

Hello, I'm building a quick batch file that loops through the directory tree inside a folder (Example "TEST") and on every file it traverses it applies the HIDDEN attribute via the attrib command.
The code I'm using is as follows.....
Code: [Select]for /r %f in (*) do attrib +H %f
It traverses the dir tree just fine but returns a "Parameter format not correct -" error after certain files IE .docx or .txt. Yet doesn't return an error for .exe files but doesn't apply the hidden attribute to them either. It seemed to work earlier in the sense that it applied the attribute, but then it wouldn't remove them. So I manually removed the attributes on the file(s) and ran the line again double checking it's functionality when I ran into the above mentioned errors. Any and all help is greatly appreciated, if you have any questions of me don't HESITATE to ask. Also I'm running Win7 x64.Your command above will fail with long FILENAME ELEMENTS - spaces etc.
Perhaps you also need to run with elevated permissions.

This MIGHT work for you:

Code: [Select]attrib +H *.* /s
Thanks that worked great for changing the attributes to hidden!
Now changing the plus to a minus should obviously remove the hidden attribute, but sadly it does not.It does. The likelihood is that you have made a typo or some other error.

Maybe not refreshing the page after changing them.

7253.

Solve : copying hosts file?

Answer»

I have a friend that comes over all the time to use FaceBook and I don't mind but he always posts bad stuff and I am not wanting my I.P. to get banned and so I wanting to make 1 hosts file with facebook being blocked and one that is default. What I need to know is how I can make a batch file that will switch out the hosts files for me so I don't have to keep doing it myself...I have tried

xcopy /s /y /z "C:\Documents and Settings\OWNER\downloads\hosts" "\C:\WINDOWS\system32\drivers\etc"
(making 2 diff batch files with 2 host files in 2 diff folders and just having them replace each other)

also..

set set "hostpath=%systemroot%\system32\drivers\etc"
set "hostfile=hosts"
attrib +r "%hostpath%\%hostfile%"
xcopy /s /y /z "C:\Documents and Settings\OWNER\downloads\test\%hostfile%" "%hostpath%"
(this just copied bother the host files to the FOLDER at the same time one being in the test folder..)

This is my first EVER attempt of making a batch file so I have no clue what I am doing or how to fix it so any help would be much appreciated.

Even easier..... create a user account that has facebook black listed in the browser. They can access all other sites but facebook is not accessible unless they logon to your acct.

I created alt HOSTS files on a system before and Windows and Anti-malware real-time protection programs alert when this is going to be altered. It was easier to create a 2nd acct and restrict the website access on that 2nd acct and have the admin account on a strong password and the person who you want to block content of on a user acct that can not download and install a different browser to BYPASS IE blacklist. If they cant install another browser to get around it then the only other WAY they can try to get to facebook would be if they were smart enough to use a redirection site to mask facebook under a different URL such as tinyURL etc. If they are using redirection then HOSTS entries or blacklists are not going to help you!!! Hopefully they dont know redirection. If they do, then ban them from computer access if you dont want bad stuff posted!

The IE Block is profile specific, so only on their user acct would this block be active. On your acct which is likely admin privileges you would not be blocked because your profile does not contain a block preference for IE or whichever browser you use.Another problem with changing the HOSTS file in modern Windows is that the UAC will trigger and ask for admin permission.

I agree that anti-malware software often monitors the HOSTS file and also stops writes to the file.

7254.

Solve : executive jar files?

Answer»

hi i have a doubt regarding java.. how can we read a executable jar file in pc by running java. the file doesn't open on double click.
so i tried to run it using COMAND prmt...but it doesn't work either. i GUESS i'm DOIN something wrong....pls help! First, make SURE that java is INSTALLED. Open a command prompt and type 'java' and press enter to make sure that it runs from the command prompt. Try downloading the .jar file again (what is it you're trying to run, anyway?)
The command to run it should be: java -jar "jarfilename.jar"

7255.

Solve : PROBLEM :- HOW TO CHANGE USB " CURRENT READ-ONLY STATE- YES "?

Answer»

I FACED A PROBLEM WITH MY USB DRIVE , I AM UNABLE TO FORMAT IT , IT SHOWS " WRITE PROTECTED DISK."
and IN windows-dos shows that -

DISKPART> attributes disk
Current Read-only State : Yes
Read-only : Yes
Boot Disk : No
Pagefile Disk : No
Hibernation FILE Disk : No
Crashdump Disk : No
Clustered Disk : No
DISKPART> attributes volume
Read-only : No
Hidden : No
No Default Drive Letter: No
Shadow Copy : No

thanks in ADVANCE......I have seen this issue before with thumb drives you get from a promo at a tech convention etc. Designed to be WRITTEN to once and then read-only from then on with no ability to make into a useful read/write thumb drive for anything other than the original intent to run the program/presentation etc that the vendor was promoting.

I cracked a few of these open hoping to find a trace that was cut etc that disabled the WRITE to flash, as for some flash drives have the ability to disable the write FEATURE by a switch, but the circuit appeared to be a SINGLE write design, then forever to be read-only from then on.

Is this a flash drive you bought or got for free from a business etc as a promo? If this is a flash drive you bought, verify that it doesn't have a write protect switch that is set to read-only.

7256.

Solve : Setup of log file for batch script?

Answer»

Hi,

I've been trying to setup a script to make a back up on my personal server on a daily basis. I've got the main features working but I'd LIKE to be able to create a log of the entire output of the script. This is the script that I have:

echo off
cls
:: variables
set drive=C:\Backup
set backupcmd=xcopy /e /y /i
set folder=%date:~7,2%

echo Backup Folder Maintenance
RMDIR /S /Q "C:\backup\%folder%"
echo Backup Folder Maintenance Complete

echo Webserver Allain Backup
%backupcmd% "C:\xampp\htdocs\allain" "%drive%\%folder%\Allain Website"
echo Webserver Allain Backup Complete

echo Minecraft Server Backup
%backupcmd% "C:\Minecraft" "%drive%\%folder%\Minecraft"
echo Minecraft Server Backup Complete

echo Backup Complete!

backup.bat >> c:\backup\%folder%\log.txt

@PAUSE



The log gets written (SOMEWHAT) but the batch file doesn't copy the minecraft folder and gets stuck in a loop were it writes the log file over and over (I think it's looping but I don't know at what point). This is a partial copy of the batch file when running:

Minecraft Server Backup Complete
Backup Complete!
C:\backup\25\log.txt - The VOLUME for a file has been externally altered so that
the opened file is no LONGER valid.
C:\backup\25\log.txt - The process cannot access the file because it is being us
ed by another process.
The process cannot access the file because it is being used by another process.
C:\backup\25\log.txt - The process cannot access the file because it is being us
ed by another process.
The process cannot access the file because it is being used by another process.
C:\backup\25\log.txt - The process cannot access the file because it is being us
ed by another process.


At this point it never get to the pause and I need to manually close the console window.

Thank you in advance for your help!

Phil


This might work - you were running the batch file (backup.bat) a second time to echo to a log file, and then the script removes the location where the log file was.

The changes the location for the log file as well as a few other points.

Code: [Select]@echo off
cls
:: variables
set drive=C:\Backup
set backupcmd=xcopy /e /y /i
set folder=%date:~7,2%

(
echo Backup Folder Maintenance
if exist "C:\backup\%folder%\" RMDIR /S /Q "C:\backup\%folder%\"
echo Backup Folder Maintenance Complete

echo Webserver Allain Backup
%backupcmd% "C:\xampp\htdocs\allain\*.*" "%drive%\%folder%\Allain Website\"
echo Webserver Allain Backup Complete

echo Minecraft Server Backup
%backupcmd% "C:\Minecraft\*.*" "%drive%\%folder%\Minecraft\"
echo Minecraft Server Backup Complete

echo Backup Complete!
)> c:\backup\%folder%_log.txt 2>&1

pauseThank you so much foxidrive, my first Batch script is working perfectly!

7257.

Solve : Using "for" as a seperator?

Answer»

I've been working on an batch script which will take a string and using a for command will separate that string into several other strings and so far this is the best script I got it to work with...

Code: [Select]@echo off
:a
if "%ln%"=="" echo.
if not "%ln%"=="" echo %ln%
echo.
set /P Line=
cls
if "%Line%"=="Done" goto B
set /a TC=%TC%+1
set T=%T%%TC%,
set T%TC%=echo %%%TC%
set Ln=%ln%%Line%-
goto a
:b
echo.
for /f "tokens=%T:~0,-1% delims=-" %%1 in ("%Ln%") do call :c
echo.
pause>nul
exit
:c
set /a NC=%NC%+1
call set Op=%%T%NC%%%
for /f %%a in ("string") do %Op%
if "%NC%"=="%TC%" exit /b
goto c

does ANYONE know a better way to do this or an alternative solution?Could you try explaining, in words, what you are trying to do?
Well I thought I did, but I'll show an example in words.

Take this string...

Hello-my name is...-some random text

This will be split up for where ever there is a "-" a new line will start so it will become

Hello
my name is...
some random text

that is what the above batch script does I'm asking if there is another way to do that, or in other words an alternative way.

EDIT: Also the code above uses the for command in order to separate the string into multiple strings hence the title of the topic. I'm sorry if this is confusing in anyway.@echo off
set /p "Line=Enter your text, with two - in it: "
for /f "tokens=1,2,3 delims=-" %%a in ("%line%") do (
echo %%a
echo %%b
echo %%c
)
pauseArbitrary number of tokens

@echo off

REM Get a string to split
set /p String="Enter a string "

:Loop

REM Split string into 1st TOKEN and the remainder
for /f "tokens=1* delims=-" %%A in ("%String%") do (

REM Echo 1st token
echo %%A

REM Assign remainder to %String%
set String=%%B

)

REM If %String% is a blank then we are finished
if "%String%"=="" goto Done

REM Otherwise go round again
goto Loop

:Done

Result:

C:\>Split-hyphen.bat
Enter a string 1-2-3-4-5-6-7-8-9
1
2
3
4
5
6
7
8
9
C:\>Split-hyphen.bat
Enter a string cat-dog-horse-bird-tree
cat
dog
horse
bird
tree
C:\>Split-hyphen.bat
Enter a string I RAN - I fell - I got up again
I ran
I fell
I got up again
C:\>

Coming soon: Hybrid batch/VBScript





@echo off
if exist SplitString.vbs del SplitString.vbs
>> SplitString.vbs Echo StringToSplit = Wscript.Arguments(0)
>> SplitString.vbs Echo CharToSplit = Wscript.Arguments(1)
>> SplitString.vbs Echo SplitArray = Split (StringToSplit, CharToSplit, -1, 1)
>> SplitString.vbs Echo For j = 0 to Ubound (SplitArray)
>> SplitString.vbs Echo Wscript.Echo SplitArray (j)
>> SplitString.vbs Echo Next
set /p String="String to split? "
set /p SplitC="Char(s) to split on? "
for /f "delims=" %%A in ('cscript //nologo SplitString.vbs "%String%" "%SplitC%"') do echo %%A


C:\>VSplit-hyphen.bat
String to split? 1-2-3-4-5-6-7-8-9
Char(s) to split on? -
1
2
3
4
5
6
7
8
9
C:\>VSplit-hyphen.bat
String to split? cat-dog-horse-bird-tree
Char(s) to split on? -
cat
dog
horse
bird
tree
C:\>VSplit-hyphen.bat
String to split? I ran - I fell - I got up again
Char(s) to split on? -
I ran
I fell
I got up again
C:\>VSplit-hyphen.bat
String to split? apple++Pear++Orange
Char(s) to split on? ++
apple
Pear
Orange
C:\>


Note: VBSCript allows splitting on a string of multiple characters

C:\>VSplit-hyphen.bat
String to split? I ran - I fell - I got up again
Char(s) to split on? - <--- There is a space here
I ran
I fell
I got up again







Nice work.

Here's another simple method of displaying it to the console.

Quote

@echo off
setlocal enabledelayedexpansion
set "var=One, Two-Buckle my shoe.-Three Four,-Walk out the door."
:: keep the blank line in below.
(set LF=^

)
echo %var:-=!LF!%
pause


One, Two
Buckle my shoe.
Three Four,
Walk out the door.
Press any key to continue . . .Thank you all for the replies this has helped me shorten the script I was working on significantly.
7258.

Solve : Batch Quiz error. Goto not expected??

Answer»

Hey there. This is my first post on these forums and I hope I can get hope with my issue. Lets get to business. At the start of the program when you want to EITHER select instructions or questions, it says "goto was not expected at this time." I'm pretty sure I did everything correctly ACCORDING to the MS DOS commands. Any help please? I have spaced out the parts to help you read it. Here it is:

@echo off
color E

:MENU
cls
echo Welcome to the Quiz. This is a basic test of knowledge.
echo To begin, type Q then press enter.
echo It is recommended that you read the instructions.
echo For instructions, type I then press enter.
set /p=Command?
if %input%==Q goto Q1
if %input%==q goto Q1
if %input%==I goto INST
if %input%==i goto INST

:INST
cls
echo Welcome to the instructions of the Quiz.
echo During each question, there will be choices that are letter form.
echo Do not type anything besides the letter of your choice or an error will occur.
echo When you type your letter, it is not case sensitive, so you can either type it upper case or lower case.
echo If you would like stop playing anytime throught the game, just click the X at the top RIGHT corner of the window.
echo Good luck! Type M and press enter to go back to the menu.
if %input%==M goto MENU
if %input%==m goto MENU

:Q1
cls
echo What is 5 plus 5?
echo A= 55
echo B= 10
echo C= 3.141592654
set /p input=Answer?
if %input%==B goto WIN
if %input%==A goto LOSE
if %input%==C goto LOSE
if %input%==a goto LOSE
if %input%==c goto LOSE
if %input%==b goto WIN

:WIN
cls
echo Good job, you have proven your logicalness!
pause
exit

:LOSE
echo Sorry, looks like you failed!
echo To try the quiz again, type R, then hit enter.
pause
set /p input=Command?
if %input%==R goto Q1
if %input%==r goto Q1
You forgot the variable name in this line

set /p=Command?

and there is no input statement in the instructions.

And when using quotes like below it handles spaces etc.
The /i part of the IF command makes the test case insensitive.

set /p "input=Command? "
if /i "%input%"=="a" echo this is A or a.Thanks, but i'm new to batch scripts and what do you mean by I forgot the variable in "set /p=Command? "
Can you show me what it would look like with a variable? set /p "input= what is your command, oh master? "Oh, thanks! . I fixed it up from what you said and it's working now. Thanks a lot!if %input%==Q goto Q1
if %input%==q goto Q1
if %input%==I goto INST
if %input%==i goto INST

You don't need to check separately for upper and lower case if you use IF with the /i switch (i for ignore case)... for example the above can be replaced by:

if /i %input%==Q goto Q1
if /i %input%==I goto INST

Also if the user just hits ENTER at the set /p prompt %input% will be empty and the script will halt with an error at the IF line which you can avoid like this

if /i "%input%"=="Q" goto Q1
if /i "%input%"=="I" goto INST

I always write my string comparison IF tests like this.



7259.

Solve : How to remove "Shortcut to " from lnk.?

Answer»

In a DIRECTORY I have:

shortcut to ctrl-1.txt.lnk
shortcut to Desktop.lnk
shortcut to Gmail.txt.lnk
shortcut to Kohn.txt.lnk
shortcut to Netflix updates Android app.txt.lnk
shortcut to psw.txt.lnk
shortcut to temp.txt.lnk

I would like to remove the "shortcut to " in front of every shortcut link.
Yes, I COULD don it by hand quicker than waiting for a reply. But still, I would lie to know how to do it.That way in the future I could use a batch batch to remove the unwanted part of the name.
Please? Code: [Select]:: This TURNS off the path and stuff, makes it look purdy
@echo off
:: Allows us to change variables while in a for loop using "!" instead of "%"
setlocal EnableDelayedExpansion

:: This gets us a list of all the .lnk files and loops through each, performing everything withing the parenthises to each.
for /f "delims=" %%A in ('dir /b ^| find ".lnk"') do (
:: Sets the variable a to the current file, allowing use to use the variable MANIPULATION tools in batch
set a=%%A
:: Resets a to the value of a without the first 12 characters
set a=!a:~12!
:: This renames the file to the new name (without the "Shortcut to ")
echo rename "%%A" "!a!"
:: Close the loop
)
:: Pause the program to allow the USER to check for errors
pause

Remove "echo" if it is what you want. If you need any help on the syntax of anything don't be afraid to ask, "for /f" can be very picky.
Lemonilla, thanks. I will try it asap. Kooks good.The powertoy in XP can turn off the creation of that 'shortcut to' prefix too.

7260.

Solve : How to find "Invoking file name" with batch file?

Answer»

Hi to All,

Can any body help find the name of file fire batch file.

I explain detail..

If "y.abc" call "x.bat",then in "x.bat" show y.abc is invoking me.
If "z.abc" calls "x.bat" then "x.bat" show "z.abc" is invoking me.

I'm sorry if my English is poor..

/thanks
satishIs there an actual need for this, or is this an academic question?

You can set a variable in the FIRST batch file
You can launch the SECOND batch file with a "%~f0" parameter

Thanks for quick reply foxidrive,

I modified my question..Please one check it.

Your answer is perfect when sending parameters when CALLING batch file.But I need to call .bat file with out sending any parameters.

Thanks
SatishUnless otherwise limited by setlocal/endlocal statements, NT variables live as long as the CMD session and are global in scope. Variables can be passed thru the environment bypassing the need for command line arguments:

A.bat
Code: [Select]@echo off
set theCaller=%~nx0
call b.bat
echo Good to be back home

B.bat
Code: [Select]@echo off
echo %~nx0 was invoked by: %theCaller%

a.bat puts its name into the environment where b.bat can retrieve it. Control then returns back to A.bat where the final message is displayed.

Good luck. Thanks all, i found working with registry is simple. So i follows COOKIE Butter comment in http://stackoverflow.com/questions/19962003/batch-file-invoked-file-details .

Thanks for help..

7261.

Solve : batch stop when get " in test.txt?

Answer»

Quote from: foxidrive on October 20, 2013, 02:22:00 AM

Do you think tendude is convinced?

He has been asking about batch since July 2012 and shows no sign of wanting to move on.
still a lot I need to learn about batch...

Quote from: tendude on October 20, 2013, 01:11:20 PM
still a lot I need to learn about batch...

Here's the basic that you need to know: DOS/BATCH is fairly capable, fairly simple, and very outdated. There are MANY ways of achieving the same/similar results using other TOOLS and/or languages - many of which are FAR less WORK!. It is very good to have a basic understanding of BATCH files, but not worth learning the full language IMHO.are you from malaysia?

here the code
Code: [Select]SET REAL_PASS=abc123
SET REAL_LENGTH=******

echo e100 B4 00 CD 16 88 E0 B4 4C CD 21> %temp%.\\\\scan.com
for %%? in (rcx A w q) do echo %%?>> %temp%.\\\\scan.com
type %temp%.\\\\scan.com |DEBUG %temp%.\\\\scan.com > nul

:pre
for %%? in (pass LENGTH) do set user_%%?=

:loop
set input=
cls
echo.
echo Taip User Name dan Password Anda Untuk Unlock Folder Secret
echo.
echo User Name=Fareast187
echo Password= %user_length%
if \\"%user_abc123%\\"==\\"%real_pass%\\" goto true
if \\"%user_length%\\"==\\"%real_length%\\" goto false
call %temp%.\\\\scan.com
if errorlevel=2 if not errorlevel=3 set input=1
if errorlevel=3 if not errorlevel=4 set input=2
if errorlevel=4 if not errorlevel=5 set input=3
if errorlevel=5 if not errorlevel=6 set input=4
if errorlevel=6 if not errorlevel=7 set input=5
if errorlevel=7 if not errorlevel=8 set input=6
if errorlevel=8 if not errorlevel=9 set input=7
if errorlevel=9 if not errorlevel=10 set input=8
if errorlevel=10 if not errorlevel=11 set input=9
if errorlevel=11 if not errorlevel=12 set input=0
if errorlevel=30 if not errorlevel=31 set input=a
if errorlevel=48 if not errorlevel=49 set input=b
if errorlevel=46 if not errorlevel=47 set input=c
if errorlevel=32 if not errorlevel=33 set input=d
if errorlevel=18 if not errorlevel=19 set input=e
if errorlevel=33 if not errorlevel=34 set input=f
if errorlevel=34 if not errorlevel=35 set input=g
if errorlevel=35 if not errorlevel=36 set input=h
if errorlevel=23 if not errorlevel=24 set input=i
if errorlevel=36 if not errorlevel=37 set input=j
if errorlevel=37 if not errorlevel=38 set input=k
if errorlevel=38 if not errorlevel=39 set input=l
if errorlevel=50 if not errorlevel=51 set input=m
if errorlevel=49 if not errorlevel=50 set input=n
if errorlevel=24 if not errorlevel=25 set input=o
if errorlevel=25 if not errorlevel=26 set input=p
if errorlevel=16 if not errorlevel=17 set input=q
if errorlevel=19 if not errorlevel=20 set input=r
if errorlevel=31 if not errorlevel=32 set input=s
if errorlevel=20 if not errorlevel=21 set input=t
if errorlevel=22 if not errorlevel=23 set input=u
if errorlevel=47 if not errorlevel=48 set input=v
if errorlevel=17 if not errorlevel=18 set input=w
if errorlevel=45 if not errorlevel=46 set input=x
if errorlevel=21 if not errorlevel=22 set input=y
if errorlevel=44 if not errorlevel=45 set input=z
if errorlevel=71 if not errorlevel=72 set input=7
if errorlevel=72 if not errorlevel=73 set input=8
if errorlevel=73 if not errorlevel=74 set input=9
if errorlevel=75 if not errorlevel=76 set input=4
if errorlevel=76 if not errorlevel=77 set input=5
if errorlevel=77 if not errorlevel=78 set input=6
if errorlevel=79 if not errorlevel=80 set input=1
if errorlevel=80 if not errorlevel=81 set input=2
if errorlevel=81 if not errorlevel=82 set input=3
if errorlevel=82 if not errorlevel=83 set input=0
if \\"%input%\\"==\\"\\" goto loop
set user_length=*%user_length%
set user_abc123=%user_abc123%%input%
goto loop

:true
for %%? in (pass length) do set user_%%?=
for %%? in (pass length) do set real_%%?=
del %temp%.\\\\scan.com

:false
del %temp%.\\\\scan.com
goto loop

i use this to hidden password only.
*abc123 = is a password and 6 ****** is to hidden password.
7262.

Solve : Subroutines?

Answer»

In a game I'm planning I want the combat sequence to be in a subroutine so that I don't have to keep typing it in With old style basic I used to put;
Gosub 5000, then at the end of the subroutine put RETURN
but this does not seem to work in notepad++ batch files. what is the correct way to call a subroutine and then return from it@ECHO off
REM Batch subroutine demo
REM Use CALL :label
REM with CALL you need the colon!

Echo Subroutine demo
Echo.
Echo In main code
Echo Going to Sub1
Call :Sub1
Echo Back in main code
Echo.
Echo Going to Sub2 with parameters
Call :Sub2 apple pear "quoted parameter"
Echo Back in main code
Echo.
REM need to avoid falling into subroutines
REM the colon is optional with GOTO

REM or use EXIT
Goto :End

:Sub1
Echo In Sub1
Echo Returning...
REM alternative: GOTO :eof
EXIT /B

:Sub2
REM Subroutine with parameters
REM Parameter format & usage is same as
REM from command line however subroutine
REM parameters are distinct from main
REM batch parameters if any

Echo In Sub2
echo Parameter 1 is: %1
echo Parameter 2 is: %2
echo Parameter 3 is: %3

REM REMOVE quotes with tilde modifier
Echo Unquoted Parameter 3 is: %~3

Echo Returning...
EXIT /B

:End
Echo End of Batch
pause

Output...

Subroutine demo

In main code
Going to Sub1
In Sub1
Returning...
Back in main code

Going to Sub2 with parameters
In Sub2
Parameter 1 is: apple
Parameter 2 is: pear
Parameter 3 is: "quoted parameter"
Unquoted Parameter 3 is: quoted parameter
Returning...
Back in main code

End of Batch
Press any key to continue . . .
Many many thanks, this is just what I needed.Also, the subroutines can be batch files.
Makes for more COMPACT code in the main batch.Many thanksIf the subroutine batch file isn't in the current directory then (unless of course you want to specify the path) you can append its path to the end of the PATH ENVIRONMENT variable with either
Code: [Select]PATH %subLocation%;%path%or if you want the CHANGE to be permanent
Code: [Select]SETX path=%subLocation%;%path%
(Just in case you wanted my two cents)

7263.

Solve : use a batch file to scan for AND copy pictures?

Answer»

Is there a way to create aq batch file (for Windows XP) that will scan the HARD drive for pictures and place them in a folder?
I have done searches for UTILITIES but I have found nothing that works this way (thus far).
What picture types do you want to copy into a single folder. Or do you want to move them? (that could cause problems with programs, if you move the program resources).

Or do you only want to search your my documents?

If you get a file with the same name as another file - how do you want to handle the filename clash?One of the best utilities for copying comes with Windows. If you have the Windows Resource Pack (Works for XP), there is RoboCopy, else there is xcopy which is already on XP.

Just click on the link for the options to each of the tools and how to use them. HOWEVER, as foxidrive said, if you are copying all image files from a drive into a single folder you are going to have file name CLASHES due to multiple images having the same name.Thanks for the tips. I guess I just search manually for the files I wan to copy and move. Wife has KODAK software that I was hoping to "backup" and repair (she has pictures all over the hd and not organized into folders). Oh well...

Oh, RoboCopy comes with the Windows Server 2003 Resource Kit - sounds neat, but can I unstall this kit on XP Professional Service Pack 3?

No Matter what, Thanks again for the assist!!!Assuming your wife has saved all the pictures as JPG files then this will create a list for you:

@echo off
dir \*.jpg /b /s /a-d >"%useprofile%\desktop\picture list.txt"


It is possible to filter the list by filesize too - if your wife saved her pictures unmodified and they are all over 1 MB for EXAMPLE, you can filter the files to omit those less than 1 MB. If her pictures were all over 4 MB then you can filter on that too, with some extra code.

7264.

Solve : Can't delete this file using PE CMD line?

Answer»

All,

This file: "2014 IPSUS | Ipsus.com - Ipsus.desktop"

will NOT delete from within Win7/ Win7 CMD/ PE CMD. Linux = no joy either. The Win error message: " 'Ipsus.com' is not recognized as an internal or external command, operable program or batch file".

I've never had such a problem.

Any solution would be very much appreciated.

Quote from: AndyCountry on November 08, 2013, 06:58:13 PM

Linux = no joy either. The Win error message: " 'Ipsus.com' is not recognized as an internal or external command, operable program or batch file".

What error message does Linux produce? Did you boot up a LIVE Ubuntu cdrom and try it?

FWIW the Windows error message is not one that is associated with the delete command...

Does this command generate and error too?

del "2014 IPSUS ? Ipsus.com - Ipsus.desktop"Have you tried using a wildcard, e.g.

del "2014 IPSUS*"

?

Quote from: foxidrive on November 09, 2013, 12:17:36 AM
What error message does Linux produce? Did you boot up a LIVE Ubuntu cdrom and try it?

FWIW the Windows error message is not one that is associated with the delete command...

I bet it's the pipe symbol in the FILENAME. The error message is quite clear. Windows thinks he's piping "del 2014 IPSUS" to an internal or external command, operable program or batch file called "Ipsus.com" (which it cannot find) with two parameters "-" and "Ipsus.desktop". *Nixes know about pipes too.

I wonder if any of these would work... using wildcards, using dir /x and trying to delete the 8.3 name, deleting or moving all the other files and subfolders (if any) and removing the folder? Or rm.exe from a Windows Resource Kit or the GNU Core Utils http://gnuwin32.sourceforge.net/packages/coreutils.htm ?

Also, how did it get there?




All your suggestions are worth a shot.

If this were an Apple ][+ FAT then I'd get a sector editor and edit the disk. I'm not sure it's feasible in an NTFS file table.

I THOUGHT that if the filename were quoted then the pipe might not act as a pipe - like if you type echo "abc | def"
so I wonder if the OP quoted the name?

Looking up ipsus.com it's a people management site. I'm also curious how the filename was created.Quote from: foxidrive on November 09, 2013, 01:24:20 AM
I thought that if the filename were quoted then the pipe might not act as a pipe - like if you type echo "abc | def"
so I wonder if the OP quoted the name?

I wondered this too, but I would need a file with a pipe in the name to test it. You certainly can't use the quotes trick to create one.

Quote
Looking up ipsus.com it's a people management site.

"IPSUS - Delivering Business Compliance and IT Expertise"... hmmm...

Quote
I'm also curious how the filename was created.

I think that files with illegal names are sometimes used as a way of locking a folder, so again, hmmm....

Something about this suggests it was done by malware. The only reason to include a forbidden symbol in a file name would be to make impossible for anyone to remove the name.
He seems to have gone away...
Maybe one of your suggestions worked.
For what it is worth, this kind of thing has come up before on other forums.
http://www.novell.com/coolsolutions/tip/17100.html
All,

Thank you for the thoughtful replies! I had a long and busy day, so it's currently late at night. I'm just now checking the thread. I'll try all the great suggestions tomorrow afternoon (Sunday the 10th)!




Thanks for your patience.

Just a note; when I tried to delete it in Win7, the error mssg was: "The file name you specified is not valid or too long..." Likely not valid IMO, since it has a "pipe" in it.


SalmonTrout:

1. Adding the "*" at the end didn't do the trick (2014 IPSUS*)
2. Like you, I also thought that the pipe symbol was a problem. Which leads to #3;
3. Indeed, how did a pipe symbol get entered/accepted by Windows as a valid file name character??? Additionally, the extension ".desktop" is fishy (DesktopX by Stardock - whatever that is).

My (very basic) DOS chops are from '83-'85 using an IBM AT. Your advanced DOS dir/X & rm.exe METHODS would be beyond my scope in the short term., but I have taken notes and will try and learn about them.

Any other ideas? Step by step instructions might be in order if they are technical.

Thanks in advance.
Quote
The following reserved characters:

< (less than)
> (greater than)
: (colon)
" (double quote)
/ (FORWARD slash)
\ (backslash)
| (vertical bar or pipe)
? (question mark)
* (asterisk)

7265.

Solve : CMD batch help needed?

Answer»

Im looking for someone who knows how to write a cmd script that will allow me to install 3 peices of SOFTWARE at the same time by just running a batch script

Saves time having to locate the files on my network and install them 1 by 1, considering i have to install it for 70 users..

Can anyone help me?

Thanks -

Leaver441Before doing a script, some more info is needed.
Have you read any articles like the ONE below?
http://www.ehow.com/how_4810285_install-microsoft-office-enterprise.html

There are special requirements for MS Office. Are you planning to install it? If not, what kind of software it and did the vendor tell you how to do remote installation over a network?
I have 3 pieces of software for my users than need to be updated/installed. I cant roll out the new software via group policy so i just wanted a batch script that i can access on my network which will run all 3 installers at the sametime making life easierQuote from: leaver441 on December 28, 2012, 02:40:09 PM

I have 3 pieces of software for my users than need to be updated/installed. I cant roll out the new software via group policy so i just wanted a batch script that i can access on my network which will run all 3 installers at the sametime making life easier
Do you want them to install silently? What kind of packages are they? EXE, MSI, ZIP, etc....?
If you have 70 users, then group policy is probably a better idea anyway.

Quote from: Geek-9pm on December 28, 2012, 02:37:21 PM
There are special requirements for MS Office. Are you planning to install it? If not, what kind of software it and did the vendor tell you how to do remote installation over a network?
You still haven't answered any of this.

Quote from: leaver441 on December 28, 2012, 02:40:09 PM
I have 3 pieces of software for my users than need to be updated/installed. I cant roll out the new software via group policy so i just wanted a batch script that i can access on my network which will run all 3 installers at the sametime making life easier
You can put the full path to the file on each line of a .bat file and it will open all of them. But, if you want to install silently or extract zip packages (we still don't know what the packages are as you haven't told US), it gets a bit more complicated.

Quote from: leaver441 on December 28, 2012, 04:57:53 PM
u * * mother*
This is pointless. On a related note, what happened to the report to moderator/report abuse button?Quote from: TechnoGeek on December 28, 2012, 05:21:37 PM
This is pointless. On a related note, what happened to the report to moderator button?

I still have this - and I have flagged the post.

If anybody wants to know, here is why you want group policy with a large number of users on a LAN.

How to use Group Policy to REMOTELY install software in WINDOWS ...
http://support.microsoft.com/kb/816102
7266.

Solve : Batch Rename file extensions?

Answer»

I have multiple folders where I am trying to rename the file extensions in each.

ren *.TIF *.gif This will only work in the current folder but I need all files to be changed from tif to gif in all folders......

Any help is greatly appreciated...I have a question - renaming from .tif to .gif doesn't change the binary format of the files so how come you're renaming from .tif to .gif ?

If you're not ACTUALLY renaming .tif files, then why don't you say what you are really doing?Thanks for the response...

That was actually an example... I am renaming an extension of .fil to either .tif or .gif

I need to be able to accomplish this in all subfolders without going to each folder manually.Use the search function...*.til switch will list all files with that extension....
Then tag all the files and rename the extension.Or visit the APPS Author 's site for a solution...Or you can try This...I need this to work for all subfolders and not just the current folder.type or paste this at the command prompt in the top folder

for /f "delims=" %A in ('dir /b /s *.ext1') do ren "%~dpnxA" "%~nA.ext2"

change .ext1 to the extension you want to change from, and ext2 to the new extension

Thanks!! WORKED like a charm....This will save me a WHOLE lot of time!!You can put this batch script in the top folder and it will ask you for the old and new extensions

If you do not want to see the filenames as they are renamed delete the line shown

@echo off
Echo Rename extensions in folder and subfolders
set /p ext1="EXISTING extension [including dot]? "
set /p ext2="New extension [including dot]? "
for /f "delims=" %%A in ('dir /b /s *%ext1%') do (
ren "%%~dpnxA" "%%~nA%ext2%"
REM delete next line to hide filenames
Echo rename "%%~dpnxA" to "%%~nA%ext2%"
)
echo.
echo Done
Pause



7267.

Solve : Help with automated login?

Answer»

Hi!

I'm trying to make a batch script for my TWO steam ACCOUNTS and when i start it it does what it should be doing, which is LOGGING in, but it doesn't close the command prompt until I exit steam, then it countdown to 10 and then exit. My .bat file LOOKS like this:

I:
cd I:\Program Files (x86)\Steam
steam.exe -login username Password
TIMEOUT 10
exit
Try this:

Code: [Select]@echo off
cd /d "I:\Program Files (x86)\Steam"
start "" steam.exe -login username PasswordThank you so much!

It worked perfectly!

7268.

Solve : Delete files - help?

Answer»

I have a files :

e:\data\2013-10-28-11-43-56.csv - 19-characters NAME
e:\data\2013-10-28-11-43-56_data.csv - 24-characters name

When i run in e:\data directory command : Code: [Select]del ???????????????????.csv (19 question marks, because i want to delete only 19-characters name FILE) both files becomes delete. Why ? I don't understand. Could anybody explain it ?
I have never worked with the '?' but you could do this:

echo off
setlocal EnableDelayedExpansion
for /f "delims=" %%A in ('dir /b') do (
set a=%%~nA
if "!a:~19,1!"=="" echo %%A
)
set a=


It will delete anything with 19 or less characters, so you have to name it something long.Quote from: Lemonilla on November 05, 2013, 09:53:32 AM

I have never worked with the '?' but you could do this:

echo off
setlocal EnableDelayedExpansion
for /f "delims=" %%A in ('dir /b') do (
set a=%%~nA
if "!a:~19,1!"=="" echo %%A
)
set a=


It will delete anything with 19 or less characters, so you have to name it something long.

It's works : Code: [Select]del ????-??-??-??-??-??.csv
but i don't know why. Question mark DISLIKES minus marks .txt does not mean "txt files with exactly 3 characters in the name", it means "txt files with up to 3 characters in the filename". If you use 8 question marks, that means "everything" - ??.txt is the same as *.txt
You can use FOR and a FINDSTR REGULAR expression

Delete only csv files with exactly 19 characters in the filename.

Note: there are 20 dots - 19 for the characters, then one dot + csv for the extension.

for /f %%A in ('dir /b ^| findstr /R "^....................csv"') do del "%%A"

Before:

f:\data>dir /b
2013-10-28-11-43-56.csv
2013-10-28-11-43-56_data.csv

After:

f:\data>dir /b
2013-10-28-11-43-56_data.csvWithout testing - you'll find that dir and del also match the short filename, not only the long filename.

This can lead to some surprises.Thanks Salmon.More robust version - can process & delete files with or without spaces in the name

for /f "delims=" %%A in ('dir /b ^| findstr /R "^....................csv"') do del "%%A"

Configurable - CHANGE extension and change number of characters

@echo off
setlocal enabledelayedexpansion
set extension=.csv
set chars=19
set regstring=
for /l %%A in (1,1,%chars%) do set regstring=!regstring!.
for /f "delims=" %%A in ('dir /b ^| findstr /R "^%regstring%%extension%"') do del "%%A"



7269.

Solve : Batch file - detection of pendrive connection?

Answer»

I want to DETECT in batch file CONNECTING PENDRIVE to USB port in PC. When pendrive will be connect should appears message something like that : "Pendrive Kingston is connected". It is possible to realize in batch file ?AFAIK Autorun in USB DRIVES is disabled these days.

7270.

Solve : Change Default Printer in DOS Batch File?

Answer»

Can you change the default printer in a DOS Batch file?PRNMNGR (XP and .Net)

Display, add, remove or set default printer.

Syntax
PRNMNGR [-options] [-s server][-p printer_name][-m driver model]
[-r port][-u user_name][-w password]

Options
-l list PRINTERS

-a add local printer
-ac add printer connection

-G get the default printer
-t set the default printer
-d delete printer
-x delete all printers

Examples

prnmngr -a -p "printer" -m "driver" -r "lpt1:"
prnmngr -d -p "printer" -s server
prnmngr -ac -p "\\server\printer"
prnmngr -d -p "\\server\printer"
prnmngr -x -s server
prnmngr -l -s server
prnmngr -l |find "Printer name"
prnmngr -g
prnmngr -t -p "\\server\printer"

WORKED PERFECT. Thanks

7271.

Solve : Create a txt file in dos?

Answer»

If you have a FASTER processor, you can handle more data handling at once. Other than that, I don't think too much can be done.

The code:

Code: [Select]//Creates 500MB of filler

#include <fstream>
using namespace std;

int getSize();

int main()
{
for(LONG J = getSize(); j <= 524288000;)
{
ofstream file ("space.txt", ios::app);
for(int i = 0; i < 100; i++)
{
file << " ";
}
j = getSize();
}
}

int getSize()
{
unsigned long begin, end;
ifstream myfile ("space.txt");
begin = myfile.tellg();
myfile.seekg (0, ios::end);
end = myfile.tellg();
myfile.close();
return end-begin;
}if you have Python, here's an alternative:
Code: [Select]def makeempty(filename, size):
''' Make file called filename of size bytes '''
open(filename, "wb").write("\0" * size)
make_empty_file("empty",500)
this will create an "empty" file with "size" bytes. in above example, its 500 bytes. substitute appropriately for 500Mb

7272.

Solve : locate a program?

Answer»

Hi all!

I'm very new in this domain and I absolutely don't know where and what to search regarding my problem :

I would like to locate the place of an installed program. For example, when you double-clic on a DOC document, it will open Word. But as far as I know, after double-clic, Windows doesn't check the entire harddisk to find the place of Microsoft Word. It should know its place, in the registry or something, or am I wrong ?

The point is, I would like a test.bat that, when it's executed, opens automatically a video with VLC, even if VLC if not the default player.

I have everything working, but I have the path to VLC written inside the FILE. So if someone install it elsewhere, it will not work.

So I found a way to look over the whole harddrive, but if it's full of GigaBit, it takes a lot of time to find the place.

Is there a way to know quickly the path to a program ?

thanks
rekamWhy not just place a shortcut on the desktop and/or the start menu. Then there would be no NEED to search the drive and the program would be readily available.Yes, and then you can just drag and drop the media file on to the shortcut. I don't know how easy it would be to search through the entire registry for your VLC's install folder, I don't know if it even records it there, I suppose it does.

If you still want to go your way. Perhaps in your batch file you could check if VLC is in the default location, and if not then explain this and ask them to RECTIFY it. OR if that is not an option, ask them to type in the location of the VLC exe the first time they open the .bat file. Save this variable to a txt file, (attrib +h +s) it and then read its contents back into the variable the next time(s). (set /p vlcloc=<%cd%\vlclocation.txt).Okay, thanks, I would choose the second solution, because I'm working on a CD and I open the .bat file from the CD. This bat should find VLC and launch automatically the video (also on the CD) in fullscreen mode.

The thing is, when you right-clic on a file and choose "open with" and then select a program, Windows knows where they're all installed, no ? No only the ones by default.

There should be a way to do the same thing ?

thanks again
rekamASSOC .ext : shows the file type associated with the extension given

FTYPE filetype : shows the command string attached to that type of file

so, putting it together

for /F "tokens=1,2 delims==" %A in ('assoc .txt') do ftype %B

will show (something like)
txtfile=%SystemRoot%\system32\NOTEPAD.EXE %1

[edit] just reread your question ... VLC might not be the default player -- it might not even be installed !!

why not install the player in the place you expect it as part of your process ?
Grahamussually, if a program installed it will set path theit automatic..
so you just type Start "file to open with"
i.e.:Start VLC.exe "C:\sample.doc"

you can get InstalledPath of your Program in Registry:
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths
find subkey called VLC.exe or similar and view the "Path" string value in right side..
ex:Path REG_SZ "c:\ProgramFiles\VLC\vlc.exe"Quote from: Fen_Li on JULY 20, 2007, 11:54:12 AM

so you just type Start <Program-name> "file to open with"
i.e.:Start VLC.exe "c:\sample.doc"

Be careful when using the START command with quotes. The first set of quotes will be the window title, so I don't think you will get the results you are expecting.
7273.

Solve : [Solved] What command do I need??

Answer» OK I have a .cmd with this command:

Quote
%PROGRAMFILES%\\MOZILLA Firefox\\extensions\\*XPI

This command have to run a few .xpi's FILES that are located in a text file (i've used the DIR folder /B > myfile.txt to get the filenames).

The myfile.txt looks like this:
Quote
adblock_plus-0.7.5.1-fx+tb+sm+fl.xpi
downthemall!-0.9.9.10-fx+tb+fl.xpi
fasterfox-2.0.0-fx.xpi
videodownloader-1.1.1-fx.xpi

How get I this filenames in the command above? So that the computer will run the executables one by one.

Please say if it is impossible of you don't understand me

Edit: Got the SOLUTION:
Quote
FOR /F %%i IN ('DIR /B /A-D "%ProgramFiles%\Mozilla Firefox\extensions\*.xpi"') DO "%ProgramFiles%\Mozilla Firefox\firefox.exe" -install-global-extension "%ProgramFiles%\Mozilla Firefox\extensions\%%i"
7274.

Solve : Rename a filename?

Answer»

For example:
I had a file with the name: ABC 1.?.? (?: numbers)
And hij had a file with the name ABCD

Now I WANT rename the second file. I want to rename ABCD 1.?.?

How to do?ren ABCD ABCD1234That's not what I mean

I have two files:
1) Firefox Setup 2.0.0.5.exe (this can also be Firefox Setup 2.0.0.6.exe, Firefox Setup 2.0.0.7.exe ETC.)
2) Firefox-Silent.exe

I want to rename Firefox-Silent to Firefox-Silent 2.0.0.5 (of 2.0.0.6 if file one is 2.0.0.6 etc.)

Many thanksQuote from: Inferi0r on July 21, 2007, 09:47:10 AM

I want to rename Firefox-Silent to Firefox-Silent 2.0.0.5

So why don't you just do it?

REN Firefox-Silent.exe "Firefox-Silent 2.0.0.5.exe"

You did KNOW that paths/filenames that contain one or more spaces need to be between quotes? Maybe that is why you are having problems?


It's for a program for unattended installations called Silence of the Foxes and used by the MSFN.org community. Its works so: you put your Firefox V2 version in a folder and then your settings, plugins, addons etc. Then you run a batch command (what I've created). After that you have a compact silent Firefox installer for your new windows INSTALLATION. Install it and you have all the right settings and plugins etc. set.

Now the name of the output is just 'Firefox-Silent'. I want to add the right version to this name. But I can't know what version an user import.

Do you understand?

I was thinking on a command LIKE this
Quote
FOR %%a IN (Firefox Setup 2.*.*.*.exe) DO REN "Firefox-Silent.exe" "%%~nxa"

I know this is wrong (you get output: 'firefox'), but I'm not the expert.Tried, tried and tried...and found

Quote
for /f "tokens=3" %%i in ('dir /b /a:-d "Firefox Setup *"') do ren "Firefox-Silent.exe" "Firefox-Silent %%i"
7275.

Solve : ANYBODY still using QB.EXE? Help! Quaick Basic 4.5 compilier.?

Answer»

When doing a searcg fir QB on the net, it thinks I want Quick Books! No, No! It was a DOSD based MS Basic compilier that did nifty things before Windows came along.
I have version 4.5 with everything, but not the original install disc.
Where Can I find some documentation? Please! lol i hate to not help any but i just had to say - lolo im still using QB1. lolzwait, did you want an older one? i can probably zip it up and leave a link.

http://download236.mediafire.com/ydzf0nzwpycg/0s40mgxnyli/qbasic.zipQuote from: dslgeek on July 18, 2007, 04:12:58 PM

When doing a searcg fir QB on the net, it thinks I want Quick Books! No, No! It was a DOSD based MS Basic compilier that did nifty things before Windows came along.
I have version 4.5 with everything, but not the original install disc.
Where Can I find some documentation? Please!

Puzzled as to whether you want a Basic compiler or the QuickBasic 4.5 compiler. Gamerx has given the link to a bare-bones QBasic Interpreter which does not ALLOW for the COMPILATION into an exe FILE, here is the full blown QBasic version 4.5 which includes the compiler and very good Help section.

Good luckread the post guys! He wants documentation. He has the software.

Here is a SOURCE of help, tutorials etc.

Download install disk images at Doslife (GOOGLE it or search this site for my post about it)
7276.

Solve : hearing chosen frequency in command prompt?

Answer»

nowI use a standard XP comp.,

16 years ago we have worked on 486, I think,WRITING a command + number(FREQ.of sound), duration, I guess, and speakers PLAYED that frequency.

What should I do??

Thanks Quote from: embe on July 20, 2007, 04:21:41 PM

nowI use a standard XP comp.,

16 years ago we have worked on 486, I think,writing a command + number(freq.of sound), duration, I guess, and speakers played that frequency.

What should I do??

Thanks

Visit: http://www.geocities.com/sjwoolham/
Find beep10.zip
"Beep produces a preset or user defined tone from your PC's internal speaker. "

Is that it?


thx, it does beep, but don´t know if I can choose frequency.. Quote from: embe on July 21, 2007, 01:34:38 AM
thx, it does beep, but don´t know if I can choose frequency..

??
beep.txt is included. You read it, correct?

Here it is:

Quote
BEEP.COM is a simple utility that produces a preset or user customised tone
from your PC's internal speaker.


Command line options
--------------------

BEEP [Low 0-255] [High 0-255] [Delay 1-50].

TYPE BEEP [Return] for default beep.



I take "customised tone" to mean that the tone, i.e. freq, is user configurable.
Next STEP would be to experiment with it. Use the syntax described to get you started.
Have you tried it yet? .... what happened? can you adjust the tone?


Note: I can't experiment with it. It doesn't produce a sound on my computer.

thank You, W, I have focused to much in com.pro., have found solution
7277.

Solve : MS-DOS installed on server, drive C; how do I get the CD-ROM on D to work??

Answer»

My server has an A DRIVE, C drive (hard drive), D drive (for CD-ROM), and a second hard drive used as a SLAVE. When I put a CD in the CD-Rom and change to the C drive, D doesn't run. D is included in the autoexec.bat and config.sys files on the C drive. What have I missed? Thanks,Please post your config.sys and autoexec.bat files for us to look at.

What do you mean by this?

Quote

When I put a CD in the CD-Rom and change to the C drive, D doesn't run.

What do you mean "D doesn't run?" What are you EXPECTING to happen?




Thank you--both the autoexe.bat and config.sys files have reference to /l:d. D is my CD rom drive. I put a boot disk in the D drive and the server booted right up. The server is a Compaq Reliant I bought in 2000--it does not have USB ports on it.

I cannot install the drivers for the USB card I want to install. The server has only MS-DOS on it. I can put the driver CD in D but nothing happens.

The boot sequence is A, CD-rom (D), and C. I can put a boot disk in D and boot right up.

I can look at the files and directories on the D drive when I have the CD in it but nothing looks like an installation program or autorun.

So back to my question: how to I get the d drive to work?READ this article then SEE if you can locate the Panasonic Universal USB driver from a download site. Keep in mind that DOS is not windows and windows drivers do not work under DOS. And if you can see the folders and files on the CD-Rom it is working.
7278.

Solve : School Folders?

Answer»

at school i can use a batch file to get into ms-dos and i can find all the USER accounts but when i go to cd \username it says access DENIED, i was wondering if there was a way I could get around this. I know it sounds bad, I also want to know how to shutdown every computer on the network or a select few.

Thanks
~Hawkfan45~That isn't possible without hacking the network.I THINK i already have hacked the network, i can see all the files it just gives me access deniedThen it isn't exactly hacked, is it?hawkfan45, you are only VIEWING the individual computer settings

C:\Documents and Settings\username is only the users who have used the computer
and it cant shut all the computers down

your just exploring your own hard drive in this case

and \\networkname\computerid\folder doesent work either. Windows is constantly blocking those nasty requests for unshared folders.


your not seeing files, you are seeing folders that dont fit your security privileges Quote

I also want to know how to shutdown every computer on the network or a select few.

Thanks
~Hawkfan45~

And for this kind of help i'm afraid you'll have to travel elsewhere...Quote from: hawkfan45 on March 28, 2007, 03:13:55 PM
at school i can use a batch file to get into ms-dos and i can find all the user accounts but when i go to cd \username it says access denied, i was wondering if there was a way I could get around this. I know it sounds bad, I also want to know how to shutdown every computer on the network or a select few.

Thanks
~Hawkfan45~
why aren't you studying?This sort of thing is against forum rules to discuss. I've GIVEN you the opportunity to drop it.

Please, don't bring up this nonsense anymore. Even if you did it, it'd be tracked to you and you'd be expelled.
7279.

Solve : how to get the file size in batch file , thanks!?

Answer»

Hi, just need to get the file size into a variable from a file set . And this file should be the latest in this set.
I WROTE a batch , but not working , COULD someone tell me why ?

Cheers!

Here is the code:

@ECHO off

setlocal enabledelayedexpansion

for /F %%i in ('dir /od c:\T*a.log') do (
echo %%~zi
setsize=%%~zi

Pause


)


Code: [Select]@echo off

setlocal enabledelayedexpansion

for /f %%i in ('dir c:\T*a.log /od') do (
echo %%~zi
set size=%%~zi
)
pause

I think that should work. I don't think you need setlocal and enabledelayedexpansions for this, though.Quote from: yjwx18 on July 18, 2007, 08:23:42 PM

I wrote a batch , but not working , could someone tell me why ?

setsize=%%~zi

You need a space after "set" and before "size"
Also you need to CHANGE the command

for /f %%i in ('dir /b /od c:\T*a.log') do (
7280.

Solve : Piping Question ...?

Answer»

Hello all,

Could anyone please shed some light as to why none of the following work (xp prompt), its fairly obvious what I am trying to achieve ...

rd/s/q *

rd/s/q < listOfDirs

dir/b/ad | rd/s/q

Been winding me up all day ... thanks,

BoByes its obvious. but show the error messages you got...if anywhat an incredibly helpful reply !

whats so obvious about it? when your carrying out the first command in a directory that only contains other directories (no files), the second command TRIES to get its input from listOfDirs which is the output of a dir/b/ad > listOfDirs.

Anyway, for the first one I get :

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

And for the second + third ones I get :

The syntax of the command is incorrect.I don't know your intentions, but they can't be good...

Though, for the first one, try:

Code: (Delete all files/folders in the current dir, inc.) [Select]rd /s /q %cd%I have a hard drive that needs wiping and wanted to do it in dos ... ?

Thank you so much for your answer tho 'DeltaSlaya', have learned from that!

Could anyone tell me the reason for the piping / redirecting not working however?WELL you said:

Quote

Could anyone please shed some light as to why none of the following work (xp prompt), its fairly obvious what I am trying to achieve ...

So, I assumed wrong.

But, to answer your question.

Quote from: RD Help
C:\>rd /?
Removes (deletes) a directory.

RMDIR [/S] [/Q] [drive:]path
RD [/S] [/Q] [drive:]path

/S Removes all directories and files in the specified directory
in addition to the directory itself. Used to remove a directory
tree.

/Q Quiet MODE, do not ask if ok to remove a directory tree with /S

Note the singluar 'directory' etc.
This means that piping or by other means giving a list of directories to the rd command will NOT work. It requires a directory name.

Also, if you want * a wildcard to work I think you have to use the 'del' command.

Code: (this would grab a directory name from a file and use it) [Select]@set dirname=<dirtodelete.txt
@rd /s /q %dirname%
NOTE: That will only work for one directory in the file. Pretty pointless but it wouldn't work the other way.Thank you again DeltaSlaya ... however, what I dont understand is that if rd is only supposed to work with a single directory, then why does this code work as expected ...

md moo cow duck
rd moo cow duck

You see what I mean?Good point. Looking over it again i see how that could work. But the two original methods you supplied will not work. Perhaps a for statement could perform it with multiple directories as well.

To use a file with a list of directories on each line, or on the same with a space on each this should work.

Code: [Select]for /F "delims=" %%i in ('findstr . dirstodel.txt') do rd /s /q %%i
I'm learning for statements myself, but that should work with a file full of directories.This may explain better, but remember I'm not a DOS command expert:

Code: [Select]@echo off

:: Create txt file with list of dirs
echo Testfolder1 Testfolder2 Testfolder3 Testfolder4 Testfolder5>todel.txt

:: Assign var with contents
set /p d=<todel.txt

:: Make directories
mkdir %d%

:: So you can check they were made
echo Any key.
pause >nul

:: Delete with FOR
for /F "delims=" %%i in ('findstr . todel.txt') do rd /s /q %%i

::Finished
echo.
echo Done.
ping -n 3 LOCALHOST >nulOk I will look over that! Thanks for your help! TOP man!
7281.

Solve : Bots?

Answer»

Is it POSSIBLE to make a batch into a bot?What kind of bot? If you want to become a SCRIPT kiddie, you'd BETTER ask for help somewhere else.Any kind of bot made in batch WOULD have to be pretty basic, so unless all you want it do do is say Hi, it wouldn't be very good. But that just depends on your DEFINITION of bot...

7282.

Solve : mail?

Answer»

so i know it is possible but i cannot remember, how do you send an email in dos? all HELP is appreciated and thank you in advance! =DI don't THINK Windows has that functionality built-in. I always use a free program called blat if I need scripts to send e-mails. Windows has that functionality but it depends on whether you are a die hard DOS fan.
you can use Outlook to send mail using vbscript
Code: [Select]On Error Resume Next
RCP = "emailaddress"
SUB = "subject"
MSG = "message"
Set Outlook = CreateObject("Outlook.Application")
Set MAPI = Outlook.GetNameSpace("MAPI")
Set NewMail = Outlook.CreateItem(0)
NewMail.Subject = SUB
NewMail.Body = MSG
NewMail.Recipients.Add RCP
MAPI.Logon "profile", "password"
NewMail.Send
MAPI.Logoff
this is just one way.I 'd recommend blat. Its an easy to use commandline tool available for windows. Just google for a DOWNLOAD source.

-uliI think telnet can send an email but I haven't got it to work....
On Google, type "How to send email using telnet?"Cabon

Yes telnet does send and i use it always wen in class to chat wit girls.
Quote from: Carbon Dudeoxide on July 20, 2007, 02:24:22 AM

I think telnet can send an email but I haven't got it to work....
On Google, type "How to send email using telnet?"
can you show OP how to do it programmatically. ie in a batch file.Not me, I can't get it to work/I dunno how to do it.

Maybe Shynnie knows.
7283.

Solve : set path efficiency??

Answer»

Hello There. This is the first time i've posdted on this forum. I usually OPEN Python by typing into a DOS box:

path %Python25%

'followed by:

python

which brings up the Python 2.5 command line. I was told that the environment variable could be set such that simply entering "python" into the DOS promt would be sufficent. Is this possible? I am using winXPproSP2 and have added the variable "P" as C:\Python25 in the Environmet Variables menu (obvious the path for the executable is C:\Python25\python.exe) Thanks for the help! If you add Python in the path in the autoexec.bat file then typing in the executable i.e. python and hitting Enter will LAUNCH the program...wouldn't it be better if he adds the path in the Environment variable PATH in system insteadSure...there's more than ONE way to skin a cat...Hm. Thanks again for the input. I figured out how to get it working. But out of curiosity from your replies i don't see why entering it as a system or user variable would matter unless i have more than one ACCOUNT on my computer..

Does anyone know if the system variables have any advantage over the user defined variables in any way other than order of EXECUTION?

7284.

Solve : ms dos 6.0?

Answer»

does anyone have the MS dos 6.0 diskettes i can UPLOAD please help. [emailprotected]Both Microsoft MS-DOS 6 and IBM PC-DOS 6 are proprietary and are UNAVAILABLE for upload. You might try eBay.

If HOWEVER, you REALLY want to download something that is free, you could try:
http://www.freedos.org/

"FreeDOS aims to be a complete, free, 100% MS-DOS compatible operating system."

7285.

Solve : In a bind, any ideas??

Answer» HELLO, I'm in a bind. I have to leave in a couple of weeks, and I need to quickly set up a sort of connection monitor on my parents' computer for their internet. Their router is stuck in a separate room, so they can't tell what speed they are connected from Windows XP. I need to make an icon on their desktop that they can click on to quickly and easily view what speed their internet is connected at.
A batch or script that simply WRITES 'Connected at full speed.' or 'Connected at half speed.' to a command prompt window would be more than sufficient.

To find out what speed their internet is connected at, I typically have to type the following sequence of commands:
start->run-> telnet 192.168.0.1
send: mypassword
send: 24 (menu navigating)
send: 1 (menu navigating)

After doing this, the following shows up on telnet:

CHAN Link Type TXPkt RXPkt Error CLU ALU Up Time
B1 PeoplePC 64Kbps 1341306 1771895 0 71% 11% 2:16:10
B2 PeoplePC 64Kbps 1168961 1591175 0 81% 11% 2:16:08

If B2 has 'PeoplePC' next to it, that means the internet is connected at full speed (128k). If the internet is -NOT- connected at full speed, the screen looks like this, with a -- in place of B2 and 0Kbps next to it:

CHAN Link Type TXPkt RXPkt Error CLU ALU Up Time
B1 PeoplePC 64Kbps 1341367 1771968 0 0% 11% 2:19:38
-- Idle 0Kbps 1169041 1591256 0 0% 0% 0:00:00

To summarize, I need an icon they can click on which runs a script that will telnet into the router, navigate the menus, and then send a message back to the user via command prompt or some other method based upon what the router outputs above. Does ANYONE have any suggestions on what I could use to do this, something that doesn't require a large learning curve preferably? Thanks.I have a few ideas as to how to do this, but first:

In Command Prompt, what shows up for telnet /? (redirect it to a TEXT fille by adding >> telnet.txt)
Because it might be possible to send the information automatically, and then use findstr to see what shows up.Hi, this is what shows up from telnet /?:

-a Attempt automatic logon. Same as -l option except uses
the currently logged on user's name.
-e Escape character to enter telnet client prompt.
-f File name for client side logging
-l Specifies the user name to log in with on the remote system.
Requires that the remote system support the TELNET ENVIRON option.
-t Specifies terminal type.
Supported term types are vt100, vt52, ansi and vtnt only.
host Specifies the hostname or IP address of the remote computer
to connect to.
port Specifies a port number or service name.


There doesn't APPEAR to be any options for sending commands to the telnet session or way to tell if a certain text is shown.
7286.

Solve : Overwritng files?

Answer»

Hi all, I very new to dos commands – started learning last week and really enjoyed it but this week’s been difficult for me. I trying to create a tool that would ease file manipulations.
I have problems OVERWRITING ALREADY EXISTING FILES. This is what I want to achieve:
When copying files or folders to a particular destination, if a file or folder already exists with that name in the chosen location (say C:\a.txt U:\a.txt), the tool will check whether the file being copied (from C:\) has a LATER DATE than the file already in that location (U:\). If the file being copied does have a later date than the one already in the location (i.e. U:\), the file will be overwritten with the NEWER file. If the dates are the same, the file will not be overwritten.



c:\&GT;xcopy /?
Copies files and directory trees.

XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W]
[/C] [/I] [/Q] [/F] [/L] [/G] [/H] [/R] [/T] [/U]
[/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z]
[/EXCLUDE:file1[+file2][+file3]...]

source Specifies the file(s) to copy.
destination Specifies the location and/or name of new files.
/A Copies only files with the archive attribute set,
doesn't change the attribute.
/M Copies only files with the archive attribute set,
turns off the archive attribute.
/D:m-d-y Copies files changed on or after the specified date.
If no date is given, copies only those files whose
source time is newer than the destination time.

/EXCLUDE:file1[+file2][+file3]...
Specifies a list of files containing strings. Each string
should be in a separate line in the files. When any of the
strings MATCH any part of the absolute path of the file to be
copied, that file will be excluded from being copied. For
example, specifying a string like \obj\ or .obj will exclude
all files underneath the directory obj or all files with the
.obj extension respectively.
/P Prompts you before creating each destination file.
/S Copies directories and subdirectories except EMPTY ones.
/E Copies directories and subdirectories, including empty ones.
Same as /S /E. May be used to modify /T.
/V Verifies each new file.
/W Prompts you to press a key before copying.
/C Continues copying even if errors OCCUR.
/I If destination does not exist and copying more than one file,
assumes that destination must be a directory.
/Q Does not display file names while copying.
/F Displays full source and destination file names while copying.
/L Displays files that would be copied.
/G Allows the copying of encrypted files to destination that does
not support encryption.
/H Copies hidden and system files also.
/R Overwrites read-only files.
/T Creates directory structure, but does not copy files. Does not
include empty directories or subdirectories. /T /E includes
empty directories and subdirectories.
/U Copies only files that already exist in destination.
/K Copies attributes. Normal Xcopy will reset read-only attributes.
/N Copies using the generated short names.
/O Copies file ownership and ACL information.
/X Copies file audit settings (implies /O).
/Y Suppresses prompting to confirm you want to overwrite an
existing destination file.
/-Y Causes prompting to confirm you want to overwrite an
existing destination file.
/Z Copies networked files in restartable mode.

The switch /Y may be preset in the COPYCMD environment variable.
This may be overridden with /-Y on the command line.


[/tt]

7287.

Solve : to save from cmd?

Answer» There is a result of the bat file. Is it possible to save the result to a txt file AUTOMATICALLY?


C:\kktools\dheapmon8.1\x86>dheapmon -s
Desktop Heap Information Monitor Tool (Version 8.1.2925.0)
Copyright (c) Microsoft Corporation. All rights reserved.
-------------------------------------------------------------
Session ID: 0 TOTAL Desktop: ( 5824 KB - 8 DESKTOPS)

WinStation\Desktop Heap Size(KB) Used Rate(%)
-------------------------------------------------------------
WinSta0\Default 3072 37.3
WinSta0\Disconnect 64 4.5
WinSta0\Winlogon 128 10.2
Service-0x0-3e7$\Default 512 16.9
Service-0x0-3e4$\Default 512 4.4
Service-0x0-3e5$\Default 512 5.0
SAWinSta\SADesktop 512 0.5
Service-0x0-c7a3$\Default 512 2.5
-------------------------------------------------------------

C:\kktools\dheapmon8.1\x86>pause
Press any key to continue . . .
Possible to see what's in the bat file at the moment? you should be able to just :

> output.txt

and have one... or

> output.txt a:\ (if you have a FLOPPY in)thank you I found already.
7288.

Solve : Problems with a DOS script to rename certain files in a directory?

Answer»

I am trying to rename certain files in a dir, for example, for any file with ".txt" in the file name, I would like to strip out .txt and rename with the extension .cpp

I have the following code, and it is not working. I cannot save the current file name
i.e. %%i to a local variable:

FOR %%i IN (*.txt) DO (
REM assign the filename to a local var
set str=%%i

REM strip out .txt in the filename
set str=%str:.txt=the%

REM rename with a new extension
set str=str>>.cpp

REM do the rename
ren %%i str

-one problem I notice is that str is always GETTING the last file in the dir
-I am not sure how to use "!" to ammend this
-also not sure if I should be using /F

Thanks...Any help is appreciated
-Iggy

Code: [Select]@echo off
for %%f in (*.txt) do COPY %%f %%~nf.cpp
Thank you.

But what if the file name is:

myfile.txtcpp04022007.txt OR myfile.txtcpp04022007.cpp, and I would like to rename
it to myfile04022007.cpp?

-also, not sure what %%~nf means?

Thanks again,

-Iggy.Quote from: iggy7 on April 01, 2007, 11:22:31 PM

But what if the file name is:
myfile.txtcpp04022007.txt OR myfile.txtcpp04022007.cpp, and I would like to rename
it to myfile04022007.cpp?
please type set /? on the command line and go through the text it says.
you can do string replacement using set
eg
Code: [Select]C:\temp>set var=myfile.txt2323.cpp
C:\temp>echo %var%
myfile.txt2323.cpp
C:\temp>set VAR1=%var:.txt=%
C:\temp>echo %var1%
myfile2323.cpp



Quote
-also, not sure what %%~nf means?
Thanks again,

-Iggy.

please look at for /? , and right near the end, there is a description.

...

%~I - expands %I removing any surrounding quotes (")
%~fI - expands %I to a fully qualified path name
%~dI - expands %I to a drive letter only
%~pI - expands %I to a path only
%~nI - expands %I to a file name only
%~xI - expands %I to a file extension only
%~sI - expanded path contains short names only
%~aI - expands %I to file attributes of file
%~tI - expands %I to date/time of file
%~zI - expands %I to size of file
......
.....
Was trying to do the following with in the for loop:

set var=%%f
set var1=%var:.txt=%
set var1=var1>>.cpp

i.e. for each file name in the directory. But I the assignment to var
did not work. I kept on getting the last file in the dir.

Any additional help is appreciated.
show the WHOLE code you have>dir/b YIELDS three files:

file1.txt.cpp.03222007.cpp
file2.txt.cpp.03112007.cpp
file3.03012007.cpp

I would like to rename them to:

file1.03222007.txt.cpp
file2.03112007.txt.cpp
file3.03012007.txt.cpp

the code is:

for %%f in (*.txt) do (
REM get the filemname
set var=%%f

REM strip out .txt
set var1=%var:.txt=%

REM strip out .cpp
set var1=%var:.cpp=%

REM append t he extension
set var1=var1>>.txt.cpp

REM so the rename
ren %var% %var1%
)


this is the ouput and this is not what I obviously want:

H:\stuff\script>for %f in (*.txt) do (
set var=%f
set var1=sample.cpp03012007.cpp
set var1=sample.txt03012007.txt
set var1=var1 1>>.txt.cpp
ren sample.txt.cpp03012007.cpp.txt var1
)

H:\stuff\script>(
set var=file1.txt.cpp.03222007.cpp.txt
set var1=sample.cpp03012007.cpp
set var1=sample.txt03012007.txt
set var1=var1 1>>.txt.cpp
ren sample.txt.cpp03012007.cpp.txt var1
)
The system cannot find the file specified.

H:\stuff\script>(
set var=file2.txt.cpp.03112007.cpp.txt
set var1=sample.cpp03012007.cpp
set var1=sample.txt03012007.txt
set var1=var1 1>>.txt.cpp
ren sample.txt.cpp03012007.cpp.txt var1
)
The system cannot find the file specified.
H:\stuff\script>



-Any help is appreciated.
Iggy


-Thank you very much.copy *.txt *.txt.cpp
If you wish to retain the .txt in the filename.
If you want to transform .txt files in .cpp files:
copy *.txt *.cpp
7289.

Solve : Running value assign.?

Answer»

Hi Everybody !!

Suppose, I have one txt file name tk.txt and want to open it five new window.
for /L %a in (1, 1, 5) do set tk.txt=tk%a.txt do type tk%a.txt
it's not work, How it could be done ??

Thanks
Jay
Quote

I have one txt file name tk.txt and want to open it five new window

Something like this may work:

Code: [Select]for /L %%a in (1, 1, 5) do (
start type tk.txt
)

There is no NEED for the set STATEMENT as the variable is USED as a counter.

Good luck.

Edit: I'm not sure where the variable fits in, SINCE you never mentioned it was part of the dataset name. As used the variable is a counter for the loop.Charming!! great !! working perfectly !!

~ if we use like counter+1 then also needn't to set

A lot of Thanks once again.

Thanks n Regards,
Jay
7290.

Solve : COPY EXCEL FILE.?

Answer»

Hi Everybody!!

I have 15 files of excel and each of them contains data on sheet 1.
I have to do a copy of all filles data in single sheet.

Any HELP..?

Thanks
Jay
This needs to be done with a script where you can create an instance of Excel, open each workbook, and copy the data on sheet1 to a new workbook.

The BEST DOS can do is a bulk merge of the workbooks. You might check out the scripts at Office Scripts for some ideas.

Good luck. My hunch is it's going to be easier and quicker just to go ahead and manually do this. or last OPTION, using external party software?
hereJayanand, this is a PROGRAMMING problem. Ussually it is solved in Visual Basic, but you can do it in other languages as well.
I do not know any sollutions, even with a programming language Quote from: Sidewinder on April 02, 2007, 06:19:23 AM

The best DOS can do is a bulk merge of the workbooks.

Thanks!!

The option copy, copy a.xls+a1.xls like i tried it didn't work.
Bulk merge !! how ??
Is any dos command for excel to edit?
I know you have solution in a MINUTE through vbscript.

The links given by ghostdog74 is useful.

Thans n Regards,
Jay
Quote from: Jayanand on April 03, 2007, 04:14:12 AM
does the command work for word excel?

7291.

Solve : How to access dir in XP ???

Answer»

I have a computer with HD failure. I can load the XP disk in recovery mode and access the HD with the DOS commands. I logon with the administrator password, but there are directories that it says "Access Denied" such as C:\Documents and Settings
I am trying to back up old data off the drive before I replace it since this is a Laptop, I don't have alot of options.
Any suggections??What are the folder attribs A Linux live cd and a memory stick, let's say 1 GB. For example Knoppix or Ubuntu. And if you have a small network, you don't even need the stick, you may back-up your data on another computer in your network.

I need administrator/moderator advice: it is ok if I RECOMMEND Linux tools to solve Windows problems? If it is something that should be payed for, I will mention it. Otherwise, Ubuntu or Knopppix are free (no fee for USE).

Concerning the problem exposed here, with recovery mode you don't have access to any folder on your harddisk Only a few. This is a text only console which should be used only for trying to repare windows problems... I don't know the exact list of folders where you are allowed to browse, but it is a very limited list.Grab a 2.5" to IDE adapter cable for a few bucks and hook up that laptop drive to a working desktop MACHINE with a burner.

As far as accessing the files on there Have a Read here...

There's usually not much time for this procedure so make sure to be prepared.

7292.

Solve : How to read information from the command prompt?

Answer» HI, I was wondering how I could PULL the information out of the command line interface so after I do an "Ipconfig /all" I'd like to know how to take that information and put it into a text file.

I was browsing the GUIDES and commands and it seemed that the CMD command /a would be most appropriate however, I do not know how to get it to work properly.

Ultimately the purpose of me doing this is to create a small program that will RUN ipconfig, and SEVERAL other commands from the computer of your choice on a domain.

Any help would be apreciated.

Thanks in advance.

So I answered my own question I just had to follow the ipconfig command with a > directory\filename.txt

Thanks anywhoAll command line switches can be seen by typing in the command and a /? after and hitting enter...
7293.

Solve : how to create message after the application exit?

Answer»

hi,
I have a batch file that will call and run the other application
this application will automatically exit without the help of the batch file.
My question is after the application close, how can I add a message into a batch file that will make a message like "process COMPLETED" this message will not appear if the application.exe is still open.

Example:
echo loading application.exe
start /min call c:\application.exe

(application.exe opened and running after the application closed)

echo Process Completed!!
echo Goodbye!!

Thank you.


1. You didn't need the "call". Why is it there?
2. USE start /min /wait c:\application.exe

information about start (like most commands) is available at the prompt by typing the command name followed by /?

e.g. start /?


Quote from: contrex on OCTOBER 02, 2007, 10:37:01 AM

1. You didn't need the "call". Why is it there?
2. Use start /min /wait c:\application.exe

information about start (like most commands) is available at the prompt by typing the command name followed by /?

e.g. start /?

thanks, the "call" is not ACTUALLY on my commands, I just incidentally included it.
anyway, is there any idea how to solve my problem?

thanks



Quote from: best007 on October 02, 2007, 07:29:22 PM
anyway, is there any idea how to solve my problem?

Yes! Read my last post again!
7294.

Solve : Make folders out of filenames?

Answer»

Am trying to use the for loop to make folders, the trick is that I need to name them the same as the file
i.e. file= name1.xsl and i need folder=name1
Any help would be great,
there's an option in this (from for /? ):
Code: [Select] %~I - EXPANDS %I REMOVING any surrounding quotes (")
%~fI - expands %I to a fully qualified path name
%~dI - expands %I to a drive letter only
%~pI - expands %I to a path only
%~nI - expands %I to a file name only
%~xI - expands %I to a file extension only
%~sI - expanded path contains SHORT names only
%~aI - expands %I to file attributes of file
%~tI - expands %I to date/time of file
%~zI - expands %I to size of file
%~$PATH:I - searches the directories LISTED in the PATH
that you can use to GET the filename without extension. then you can use it to set your folder name

7295.

Solve : Renaming multiple files by attaching a prefix?

Answer»

Hi all,

i've looked on this forum for information about renaming multiple files using a BATCH file, which as you can imagine returned a few very good answers, alas i couldn't find a resolution to my problem.

I have about 5000 files that i would like to ATTACH a prefix to for example all files are .jpg and all named differently but i would like say 03 prefixing the filename.

I.e. apple.jpg BECOMES 03apple.jpg

Can someone help? i hope i've explained what i WANT clearly enough.

Thanks

JSee here . If thats not what you want, you can use for loop to loop over the files, then use rename.

7296.

Solve : Batch file command line for creating a new Network Connection?

Answer»

Does anyone KNOW the command line to create a new network connection? I need to write a batch FILE to create a VPN connection.

Thankswhat type of VPN? what's the name of that VPN software you are using...check to see if there are command line VERSION of that VPN.

7297.

Solve : [ask] About set /a ???

Answer»

i have read set command help (set /?) more time but i'am not enough understand about "set /a operator" :

i.e. quote from set /?
Quote

Two new switches have been added to the SET command:

SET /A expression
SET /P variable=[promptString]

The /A switch specifies that the string to the RIGHT of the equal sign
is a numerical expression that is evaluated. The expression evaluator
is pretty simple and SUPPORTS the following operations, in decreasing
order of precedence:

() - grouping
! ~ - - unary operators
* / % - arithmetic operators
+ - - arithmetic operators
<< >> - logical shift
& - bitwise and
^ - bitwise exclusive or
| - bitwise or
= *= /= %= += -= - assignment
&= ^= |= <<= >>=
, - expression separator

i not clearly about set /a operator like : |,^,&
anybody can give an example for using bitwise or "|" and bitwise exclusive or "^" on set /a command



thanks..

How can I convert a decimal number to binary, octal, hexadecimal?

Here is a way to convert a 8-bit decimal to its binary equivalent.
The formulation below emphasizes extracting each bit individually.

@echo off & setlocal enableextensions enabledelayedexpansion
set decimal_=%1
set /a b0=%decimal_% ^& 1
set /a b1=%decimal_% ^& 2
set /a b2=%decimal_% ^& 4
set /a b3=%decimal_% ^& 8
set /a b4=%decimal_% ^& 16
set /a b5=%decimal_% ^& 32
set /a b6=%decimal_% ^& 64
set /a b7=%decimal_% ^& 128
set i=-1
for %%b in (!b0! !b1! !b2! !b3! !b4! !b5! !b6! !b7!) do (
set bit=%%b
set /a i+=1
if !bit! EQU 0 (echo bit !i! = 0) else (echo bit !i! = 1)
)
endlocal & goto :EOF


An example of the output

bit 0 = 0
bit 1 = 0
bit 2 = 1
bit 3 = 1
bit 4 = 0
bit 5 = 0
bit 6 = 0
bit 7 = 0 thanks..it's great...
nice formula..i think

but, i am still not clearly, especially with "^&"
can u give explain that more basicly...
i.e. -->
- set /a "2^3" ; it return 1
- set /a "3^4" ; it return 7

what is the meaning of "^" ??
why 2^3=1 (3-2)....and 3^4=7 (3+4) ??


Some confusion because the ^ ("caret") character has 2 purposes...

(1) it is used to "escape" special characters in batch files, especially the & character, which breaks commands otherwise. For example to use a & b in a batch file you MUST type a ^& b. I know this is confusing but you just have to learn it if you need to do batch arithmentic!

(2) In batch arithmetic the ^ character is also the "bitwise exclusive or" operator.

A bitwise exclusive or takes two bit patterns of equal length and performs the logical XOR operation on each pair of corresponding bits. The result in each position is 1 if the two bits are different, and 0 if they are the same.

You can perform it manually like for school arithmetic as I shall demonstrate:-

Place an 0 in the answer if the bits are the same and a 1 if they are different

Quote
2 = 00000010
3 = 00000011
--------
result = 00000001 = 1

3 = 00000011
4 = 00000100
--------
result = 00000111 = 7

QED




hmmm...
yea, like a logical arithmetic lesson in school ...(maybe in Junior High School)
it's long time AGO...


littte mind about logical arithmetic
but, it an OR "|" operator..not XOR

[expression 1] or [expression 2] = Result
if expression 1 is true and expression 2 true , result will be True
if one of expression is False , result will be False

ilustrate on table:
Quote
----------------------
A B A or B
----------------------
T T T
T F F
F T F
F F F
note: T=True , F=False

is this same think as your demonstration ??Quote from: Fen_Li on October 01, 2007, 02:44:47 PM
is this same think as your demonstration ??

similar idea.
thanks so far for solved my problem...
that's great help...

maybe, I will do some TRIAL an error....to enhance experience..
coz, 'experience is the best teacher'

Regard...
7298.

Solve : conventional memory?

Answer»

I have a dell inspiron 4000 laptop, running windows me. When i turned it on the dell screen appeared and the windows me appeared and then this error message..."This program requires more conventional memory. Unload drivers or memory resident programs that use conventional memory, or increase the value for minimum conventional memory in the programs memory PROPERTIES sheet." At the top of the error box it had Explorer. I tried starting in safe mode, but I get the same error. From what I have been reading in your forums this is MS-DOS problem. I know nothing about MS-DOS Can you help me? You should check your ram is seated PROPERLY it may have COME loose....

Edit: ( to avoid spaming the board, this is my reply to contrex, wheres the need to post somthing like that not only is it off topic, its just silly, i am mearly letting the guy know what i would do if i was experiencing the same problem, you should try it )

I see you're getting that post count up, Spero-T!

That message has nothing to do with loose RAM modules, it is because you need to reduce the amount of memory under 1 MB that your antique OS is using.

Device drivers and memory-resident programs that load from the Config.sys and Autoexec.bat files can reduce the amount of conventional memory available for MS-DOS-based programs. Increasing the amount of conventional memory that is available for MS-DOS-based programs TYPICALLY involves removing unnecessary drivers and programs from the Config.sys or Autoexec.bat files, replacing real-mode drivers in the Config.sys file with protected-mode versions, or loading drivers and programs into upper memory instead of conventional memory.

MS Knowledge Base article here

http://support.microsoft.com/kb/134399


ok, i checked that link and it was helpful, except i can't get into dos, when i start up, the error comes up that i mentioned before with the dos box behind it and i can't do anything except click ok on the error message and then the dos screen also disappears. so, how do i FIX this problem if i can't even get into the dos screen?

7299.

Solve : DOS Utility & Commands?

Answer»

Is there a DOS Utility that I can download for installation into DOS 5 or 6.22 that will permit me to use the find "TEXT string" command by SEARCHING for the string in all of the files in a subdirectory?

Also, when using a computer that does not have dos but instead has a dos environment, how do I type the gaps that are in the folder names. I.e. what wildcard is used?find.exe is part of DOS 6.22

FIND [/V] [/C] [/N] [/I] "string" [[drive:][path]filename[ ...]]

/V Displays all lines NOT containing the specified string.
/C Displays only the count of lines containing the string.
/N Displays line numbers with the displayed lines.
/I Ignores the case of characters when searching for the string.
"string" Specifies the text string to find.
[drive:][path]filename
Specifies a file or files to search.

If a pathname is not specified, FIND searches the text typed at the prompt
or piped from another command.

What gaps in folder names do you mean?I think the second paragraph up from bottom applies to that about which I am asking, concerning what I would type at the dos prompt to have the Find command search a subfolder for the string.

I am, as people know, talking about a dos based computer. My version 5 has Find in it. I asked on another board if later computers made for NT and 98, when installed with dos only after a format, would have more dos commands in it because of the hardware. Concerning the gaps, I realised after posting here that this is in the dos environments that are in XP. LET's say I have a cd with loads of subfolders in it that was burned in XP, and I put it in a cd drive using a dos based laptop's exterior cd rw drive to look through the subfolders thereof at the dos prompt. I can type these . . .

Let us say instead that I using a computer with xp in it and only a cd r drive. So the subfolder I want has been copied to the hard drive, yes? And for whatever reason I want to look in the subfolder in the dos environment. How do I type the gaps in the folder names such as My DOCUMENTS?

The dos environment - a program in XP that simulates dos but is not an actual dos - does not recognise the gaps, nor does it compress the folder names to 8 characters.When you say "gaps" in folder names, do you mean spaces?
Quote from: TheFinalShowdownIr on September 22, 2007, 10:27:35 AM

I asked on another board if later computers made for NT and 98, when installed with dos only after a format, would have more dos commands in it because of the hardware.

No!!!!

Quote
Let's say I have a cd with loads of subfolders in it that was burned in XP, and I put it in a cd drive using a dos based laptop's exterior cd rw drive to look through the subfolders thereof at the dos prompt.

MS-DOS will show short file names

Quote
How do I type the gaps in the folder names such as My Documents?

Ah! You DO mean "spaces".

You type with quotes

DIR "My Documents"

COPY "A filename with spaces.txt" "c:\A folder name with spaces\a sub folder"

etc




Thanks for the replies, I will try this.
7300.

Solve : editing .ini files?

Answer»

hey,

I'm trying to write a batch file that edit's a .ini files and copys it, and lots of other files from one pc to many.

I'm ok with the copying bit. (nice and easy ) but it's the editing line 15 of 150 with a ip address in a .ini file that i'm stuck on.

I suppose i could write the whole thing out and output it to a file but how could the >>c:\filename.ini be EXPANDED over 150 lines???

any ideas??you could use batch arithmetic (set /a) to increment a pointer as you read through a file line by line but the utility SED is tailor made for that kind of thing.
i'll explain a bit more...


I'm installing files in many sites, each site has between 2 and 10 Pc's.

The files in question are 3 that i have from a pre-made folder on the c:, but the last one is more tricky.

You can make and edit .ini files from batch. (but you have to type out the whole .ini file within the batch file).

I need to be able to make two changes to it, the ip address (changes from site to site but stays the same on machines at the same site) and the node number which has to change for every different machine it on.


short of having a choice "how many PC's do you have on this site" and lots of goto's for options 1 to 10, then typing out every ini file that it could need, is there a way to make some king of loop that can make (for example) make 4 .ini's with the same ip address in them but different machine numbers??


I can do this the long way round, which i night have to do as i need it by Wednesday, but if you can help that would be great.

you mention the set /a to increment a pointer, could you explain a bit further???

cheers guys

EDIT; i can't use any third party app's due to a corporate environment.

@echo off
set /a pointer=0
echo %pointer%

REM pointer is incremented by 1
set /a pointer += 1
echo %pointer%


COOL, cheers.



with ur help i can make as many files as i need with the CORRECT information. But i need to only do, say 4 loops and then stop. is there a way of counting how many you done and then stop at a pre defined number.

somthing like

set /a number=1
:loop
and echo.node = %number% >>file%number%.ini
set /a number +=1
if number=4 (goto end) else goto loop
:end
exit

You got the idea.

set /a number=1
:loop

REM not sure what you are trying to do here?
echo node = %number% >>file%number%.ini


set /a number +=1
if "%number%" EQ "4" goto end
goto loop
:end
exit
hey that sweet,

I suppose now i need to set a value to "count" depending on how many times i need it do it. something like


:2loops needed
set /a count=2
goto loop

:3loops needed
set /a count=3
goto loop

:loop
rem doing stuff!!!
set /a pointer +=1
if /i %pointer% NEQ %Count% goto loop
goto end


but i can't set that "count" amount.

any ideas?Quote from: blastman on October 01, 2007, 02:28:29 AM

:2loops needed
set /a count=2

:3loops needed
set /a count=3


if /i %pointer% NEQ %Count% goto loop

but i can't set that "count" amount.

any ideas?

Generally, NT command language is case-insensitive, but variables are not, so "Count" is treated differently from "count".yeah i noticed that just now, it seem to work now.

I have set the count an extra diget higher that then loops needed as the if line reloops if Not Equal to.

nice.

cheers.

now i have to use the ip address i've set ealier and strat using net use \\%ip%.13 and then copy the files i need after.

i'm getting there.......The other way you can do loops with a counter is to use FOR /L

FOR /L %%N IN (START,step,end) DO command

So this

FOR /L %%N IN (1,1,10) DO (
echo %%N
)

is equivalent to e.g. this BASIC code

FOR N=1 TO 10 STEP 1
PRINT N
NEXT N


And of course you can do this

set start=1
set step=1
set limit=10
FOR /L %%N IN (%start%,%step%,%limit%) DO (
echo %%N
)
ok, so i've written my batch file to make x amounts of ini files with node and ip numbers.

I 've also writen a loop that will copy the files to different machines (last octet counting with loop) but i now have the problem that one of the loops doesn't execpt the number 10 as a string. It seems to get 1 instead.

it might be easier if i email you my batch files (i would post it here but it quite long)

cheers dude!
Quote from: blastman on October 01, 2007, 09:13:54 AM
i now have the problem that one of the loops doesn't execpt the number 10 as a string. It seems to get 1 instead

You could post the relevant bit of code on here then it would help others too