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.

5051.

Solve : Batch File Transfer over wireless network?

Answer»

Hi please excuse me if I am asking a redundant question.

I would like to create a batch command from one central computer that transfers files from four computers that are on the same wireless network.

Some are using Vista and OTHERS XP. The batch command would check a specific directory every five seconds on each of the four wirelessly NETWORKED computers and if there are files present it would transfer them to its own local directory.

If this wasn't possible from the central computer, we could have a batch command running on each of the four wireless computers do the transfer from each to the central.

A related question also is can a batch command be made to perform a logon to the computer it needs to transfer the files from ?If you try doing this in batch, you'll either end up with a loop that continually sucks up CPU cycles or need prior knowledge of the incoming file name (or both). If you try doing this on the server, you'll find that VBScript is not multi-threaded and can only monitor one directory at a time.

One solution would be to have each local computer run a script to monitor a file CREATION event and copy the file to the server upon arrival.

Code: [Select]strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set fso = CreateObject("Scripting.FileSystemObject")

Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
("SELECT * FROM __InstanceOperationEvent WITHIN 5 WHERE " _
& "Targetinstance ISA 'CIM_Datafile' and " _
& "TargetInstance.Drive = 'C:' And TargetInstance.Path= '\\temp\\'")

Do
Set objLatestEvent = colMonitoredEvents.NextEvent()
Select Case objLatestEvent.Path_.Class
Case "__InstanceCreationEvent"
fso.CopyFile objLatestEvent.TargetInstance.Name servername
End Select
Loop

The above script monitors the c:\temp directory for file creations. When a file is created, it is copied to the server. You need to change servername to something appropriate and to remember to double up on all backslashes in the select statement paths!

Hope this helps. Hi,

Sidewinder suggestion would indeed work, but I would have written a simple batch to map some drives to the remote machines and then check the folders for your files, if there copy them to the local server. I would have then scheduled the batch file to run every 1 minute or so, anymorethen that and the CPU would become over worked.

hope it helps.thank you guys for your help, I haven't tried it yet but will give it a run this week.

cheers.I agree with all above suggestions, but if you want a delay in the batch, you can use the Choice command with a timeout and goto to keep it in a loop. CPU overload is a definate problem as for as soon as the data is sent it may need to resend again. You also will overwork your drives possibly if data changes frequently.

The other situation you could face if if the network connection drops, it could lock up your batch. See it before with hard wired network transfers that bail because of conjestion and a timeout occurs in the batch.All this makes sense thanks. I did map a drive from the server on the notebook and changed the script to reflect the mapped drive but wasnt sure sure about the proper syntax to use. I also assumed that I was saving it as an htm file.

Bottom line is it did not work and I put it down to my lack of knowledge in VBScripts.

here's what the script looks like now, I did modify it some by adding and removing parenthesis:


Code: [Select]strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set fso = CreateObject("Scripting.FileSystemObject")

Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
("SELECT * FROM __InstanceOperationEvent WITHIN 5 WHERE " _
& "Targetinstance ISA 'CIM_Datafile' and " _
& "TargetInstance.Drive = 'c:' And TargetInstance.Path= '\\Photos\\'")

Do
Set objLatestEvent = colMonitoredEvents.NextEvent()
Select Case objLatestEvent.Path_.Class
Case "__InstanceCreationEvent"
fso.CopyFile objLatestEvent.TargetInstance.Drive = Z:\\Images\\transfers\\
End Select
LoopQuote

fso.CopyFile objLatestEvent.TargetInstance.Drive = Z:\\Images\\transfers\\

Any reason you changed .Name to .Drive? The equal symbol is invalid in this context. If the Z drive is mapped you don't need double backslashes (the double backslashes are unique to the query); the output location can be treated as a local drive:

Code: [Select]fso.CopyFile objLatestEvent.TargetInstance.Name Z:\Images\transfers\

But you can use UNC notation for the output location if you prefer:

\\computername\Z$\images\transfers


Not knowing what I was doing I made those changes

the script fails at line: 14 char: 57 error: expected end of statement code: 800A0401, vbscript compilation error.

It seems to have a problem with the Z, but that is the mapped drive. The map name is Images so I removed that name from the path since the mapping put us into that folder, however it made no difference.

I tried it also using the unc but I got a syntax error at char 58

I guess some days are better than others. This should fix you right up. Sorry for any confusion.

Code: [Select]strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set fso = CreateObject("Scripting.FileSystemObject")

Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
("SELECT * FROM __InstanceOperationEvent WITHIN 5 WHERE " _
& "Targetinstance ISA 'CIM_Datafile' and " _
& "TargetInstance.Drive = 'c:' And TargetInstance.Path= '\\Photos\\'")

Do
Set objLatestEvent = colMonitoredEvents.NextEvent()
Select Case objLatestEvent.Path_.Class
Case "__InstanceCreationEvent"
fso.CopyFile objLatestEvent.TargetInstance.Drive, "Z:\\Images\\transfers\\"
End Select
Loop

Save script with a vbs extension and run from the command line as
wscript scriptname.vbs

5052.

Solve : Piping the command output to a variable??

Answer»

Is there a way by which i can do a piping of command output to a variable instead of file?
I require continuing my execution based on the command outputs. I really dont want to create a file while executing my dos commands if it is feasible.

Thanks in advance for the HELP offered.i dont know if PIP cvan do this but u can use this

for /F "delims=" %%i in ('commands') do set r=%%i
echo %r%Thanks mate.
But how actually can I capture the entire o/p set in the variables, as this would allow me just to store just the last line of my o/p in r.Say what the command is and what specific output you are looking for. Unless you give more information we cannot help you.

We are not mind readers.

u can do that but show us the code so we can help u more
setlocal ENABLEDELAYEDEXPANSION
set /a con=1
for /f "delims=" %%i in ('commands') do (
set VAR!con!=%%i
set /a con=!con!+1
)
endlocal
echo %var1%
echo %var2%
.
.
.
Sorry guys for not being clear in conveying my ask.

I am invoking a executable from my batch script, which outputs multiple lines. Currently am outputting the same to a file. Please find below the code snippet

Code: [Select]call %SYS_DIR%powercfg.exe -L | findstr /C balanced > plan.txt
Sample contents of plan.txt would be
Code: [Select]Power Scheme GUID: 382a0719-1dcf-45ae-a357-0b9cedfb0f43 (balanced) *
Power Scheme GUID: 5d73e9ca-7776-4dc3-8eee-dd828ae4f989 (balanced1)
Instead of writing it to a txt file, am interested in storing it in dos variables. Can tat be done ?
Yes. .bat_man has told you how to do it.
yes it can

setlocal ENABLEDELAYEDEXPANSION
set /a con=1
for /f "delims=" %%i in ('^%SYS_DIR^%/powercfg.exe -l ^| findstr /C balanced') do (
set var!con!=%%i
set /a con=!con!+1
)
endlocal
echo %var1%
echo %var2%
.
.
.
he has told you twice now.

5053.

Solve : How to count the number of line in TXT file using DOS??

Answer»

Hi Everyone,

In batch code, is it possible to count the number of files from the text file

For eg.,
Text file "Src.txt" contains the following text....
uuuuu
vvvvvv
xxxxxx
yyyyyy
zzzzzz

I need to find the number of lines available in "Src.Txt" and also i need to print(echo) the 3rd LINE.

Is there any option to resolve this issue..., Please help me to resolve this issue....,

Thank in Advance.

Urs,
Vinoth



I've not been able to figure this out (If it is at all possible)try this
setlocal ENABLEDELAYEDEXPANSION
set /a cont=1
for /f "delims=" %%i in (New.txt) do (
if "!count!" EQU "3" echo %%i
set /a count=!count!+1
)
echo u have !count! lins in New.txt
pause
endlocalHi friend,

When i try to execute your code, the count was not increasing.... Since I am new to DOS envrn, please help me to resolve this issue.....

This is the DOS SCREEN................

D:\>set /a count=1
1
D:\>for /f "delims=" %i in (cbs.txt) do set /a count=%count%+1

D:\>set /a count=1+1
2
D:\>set /a count=1+1
2
D:\>set /a count=1+1
2
D:\>set /a count=1+1
2
D:\>set /a count=1+1
2
D:\>

******************************************************************

Thanks In Advance.(For your timely help)

With Regards,
Vinoth R

u should put the command setlocal ENABLEDELAYEDEXPANSION
or the code will not work
put this code inside abat file and execute it , it will workQuote from: vinoth124 on June 12, 2008, 05:20:02 AM


D:\>for /f "delims=" %i in (cbs.txt) do set /a count=%count%+1


i DIDNT wrote this it was set /a count=!count!+1
5054.

Solve : Ignoring the Ampersand (&) in a Command Line?

Answer»

I'm trying to do a

C:\>net use * \\127.0.0.1\root abcd&d& /USER:administrator

command and UNFORTUNATELY the password used to map the drive happens to have ampersands (&) in it.

So DOS thinks I'm trying to ISSUE two distinct commands instead of one.

How do I get it to stop trying to interpret the ampersand (&) as a special character?

P.S. - We have literally thousands of computers with random passwords generated, so it's not practical to fix the passwords themselves, so please don't make that suggestion.I'm no expert but what happens if you do add an '^' before the '&'

Code: [Select]C:\>net use * \\127.0.0.1\root abcd^&d^& /USER:administrator
If you go to command and type 'echo ^&' it will show the character '&'I believe that was exactly what I was looking for. Thank you.Anytime.

5055.

Solve : how do I include my password file into another batch script??

Answer»

Hi,
how do I include my password FILE into another batch script?
In Unix I would put my password in a separate "Include" file with this line
psw="mypassword"

Then all my Unix SCRIPTS will include that "Include" file and use that password as a variable $psw
. /path/to/Include/file.txt
login $loginID $psw on $SERVER ;

How do I write a DOS script that does similar things as above.?
THANKS in advance.
u can do that by creating a new environment variable by right click on
"my computer"->properties -> ADVANCED press on environment variable create a new one for eg pas
the in any BAT file u can use its value as %pas%

5056.

Solve : Net Send Command and Messenger Service?

Answer»

Does ANYONE know if there is a way to limit incoming windows messages from just certain computers? I would like to use the service but I do not want the spam.

Also is there is way to change the format of the messages? Like change the background color, text size, etc. The gray window is not very appealing.Yes there is a way to edit the background color LETTERS A-F represent a color, and numbers 1 through 9 represent a color/shade for example: Color D1 would make a light purple background with a blue text.

Background Foreground (text)
0 = Black 8 = Gray
1 = Blue 9 = Light Blue
2 = Green A = Light Green
3 = Aqua B = Light Aqua
4 = Red C = Light Red
5 = Purple D = Light Purple
6 = YELLOW E = Light Yellow
7 = White F = Bright White

hope this helps

5057.

Solve : DOS Find Hex String?

Answer»

Hi,
How do I specify a hex string to DOS FIND?
I TRIED to use Line feed hex 25 or Carriage return hex 0D to SEARCH a .txt file
I was unsuccessful. I was successful using a regular string (127.0.0.1).

This is the command that I entered:

Find /C "0x'0D'" C:\Windows\System32\Drivers\etc\Hosts
It failed, returned zero

I tried this:
Find /C "127.0.0.1" C:\Windows\System32\Drivers\etc\Hosts

It worked, returned 8194
ThanksI don't think you can do it with find.
There are a few utilities out there like this one, that might WORK for you:
Find & Replace 1.0

5058.

Solve : task manager??

Answer» HOWDY, just wondering how to either disable taskmanager directly from a batch file, or just the ctrl, alt del buttons. Im a real NOOB so please not too much "hahaha u r 50 n07 1337 pwned lawl"

thanks

If this isn't possible, how would i convert a batchfile into an EXE that cant be closed?Why do you NEED to disable Task Manager and what the heck does all that textspeak mean ? ?Well heres one option try this: CODE: [Select]taskkill /f /im taskmgr.exe
5059.

Solve : cmd.exe in limiter user?

Answer»

Hi,
I have a problem using cmd.exe as a limited user runnig a batch file.

I have a small .com program called REPLY.com, when executed in a batch file, it waits for the user to press a key and reply.com returns the key pressed as an errorlevel. This works fine when I log in as the admin. If I log is as a limited user, the batch file continues past the reply.com with an error:

"C:\WINDOWS\system32\cmd.exe
C:\Ducume~1\Frank\Locals!~1\Temp. A temporary file needed for initialization could not be created or could not be written to. Make sure that the directory path exists, and disk space is available. CHOOSE 'Close' to terminate the application."

That folder is accessible, I have plenty of disk space, so I don't understand what it wants to do that it cannot do.
Does anyone have an idea?
Thanks
Franklog in as admin and change permissions for command.comI have changed permissions for cmd.exe to have full access by by the limited user.
No change.
I changed permissions on command.com as suggested also.
No change.
FrankThis may be a long shot, but maybe ... the temp file was created on a prior use of the reply program and was not deleted for unknown reasons. If it was marked read only, or if it was still in use, then you would likely get that error. Not all programs handle their temp files as well as they should. When I look at my temp folder, I usually find a lot of stranded temp files.

Try deleting all of your temp files and see if any are left. Reboot to safe mode, or as admin, and delete the remaining ones if possible. Then try your reply.com program again with the temp folder open to see what file(s) if any are created, and whether or not they are deleted properly after reply closes.

You could also log in as admin. & watch the admin temp folder while running the program for the same thing. This may be a long shot, but it may give you a clue or two, by knowing which temp files are being created and whether or not they are being deleted properly.

What version of windows do you have? I am not familiar with the C:\Ducuments folder structure. "C:\Ducume~1\Frank\Locals!~1\Temp". (Sorry, I couldn't resist, but seriously, what windows version are you running?)

Quote from: Frank on June 08, 2008, 05:34:36 AM

If I log is as a limited user, the batch file continues past the reply.com with an error:

I'm not sure exactly what you mean by "the batch file continues past the reply.com " Please show us the command line you are using to start reply.com. It may be that we can TWEAK that line a bit.

Is reply.com a freeware, or shareware program? If so please list the link, (or the program) so we can have a look.

Can you explain the errorlevel scheme? It may be possible that someone here could DUPLICATE the program's functions without the need of the additional program.


Quote from: llmeyer1000 on June 08, 2008, 08:04:10 PM
I am not familiar with the C:\Ducuments folder structure. "C:\Ducume~1\Frank\Locals!~1\Temp".

Me neither. If it quacks like a duc..I run Windows XP SP2.
I deleted all files from the that temp folder.
I don't think we need to go into the batch file itself yet because I found another major problem showing the same error.
If I try to just launch command.com (not cmd.exe) as a limited user from the start\run but it fails to complete the launch and gives the same error message as before. No batch file being launched yet. While the error window is shown, the temp folder is still empty. I would like to paste the picture of the window here (but don't know how to).
Frank

PS. Just noticed trying to launch edit.com causes the same error.Frank,
I just googled your error:
A temporary file needed for initialization could not be created or could not be written to.
(I've never included that many search words before!) and WOW! You are not the first to have this problem. It appears that your temp folder may be marked read only and according to others who have experienced this problem, you will not be able to remove the attributes from the folder. (at least without some good old registry editing.) Some of the threads I found point you to a couple of microsoft sites, so the information is probably good. I didn't read through it all, so I suggest that you do some diligent research yourself, before making any of the changes suggested.

Do the google search and read up, before proceeding. Here are a few links that SEEMED appropriate: (Remember, I have NOT had this problem and cannot guarantee any favorable results. Be careful!)
http://www.pcreview.co.uk/forums/thread-94210.php
http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q256614
http://support.microsoft.com/?kbid=326549
llmeyer1000, I did what those websites suggested. No change. It looks like I cannot launch any .com program.

I tried the Guest account - the same.
I created a new limited user account - the same.

I think the problem is deep inside Windows and I think it's broken.
A few weeks ago I had a major virus attack - a rootkit. I had to get rid of it because when I restored a full backup of drive C:, the virus was still there. I found it, removed it with ComboBox. Then restored the full backup again. It all appeared to work. Since I always worked on the machine as an Admin user, I now decided to create a limited user to run the machine to increase security regarding future viruses. Unfortunately, I now have this problem.
Maybe my only solution is going to do a fresh install of Windows and start again. What do you think?
FrankA clean install is always good!, but it does take some time. And you have to remember to backup everything! It is so easy to lose data that you forgot about. If you can't fix it, I don't see where you have a whole lot of choice.

Is there more than one partition on the HD? If not, it wouldn't hurt to also wipe the first part of you drive, to make sure that no corrupted data is carried forword.The only reason for doing a clean new install, in my case, is because I am unable to get the batch file to work properly. If I could replace a couple of 16 bit .com applications with 32 bit apps, my batch file would work. I would not require to run any other 16 bit apps.
This is batch file (menu.bat). It is copied as a skeleton from a book called Supercharging MS-Dos published in 1986:

@echo off
echo {ESC}[m
prompt
:START
cls
rem menu\nocurs.com
%dr%
type menu\menu1.txt
echo Press the required function key on the keyboard:
:GET_REPLY
menu\reply.com
rem echo got here
if errorlevel 69 goto GET_REPLY
if errorlevel 68 goto F10
if errorlevel 67 goto F9
if errorlevel 66 goto F8
if errorlevel 65 goto F7
if errorlevel 64 goto F6
if errorlevel 63 goto F5
if errorlevel 62 goto F4
if errorlevel 61 goto F3
if errorlevel 60 goto F2
if errorlevel 59 goto F1
goto GET_REPLY
:F10
cls
goto :END
:F9
cls
goto START
:F8
cls
goto START
:F7
cls
goto START
:F6
cls
goto START
:F5
cls
goto START
:F4
cls
goto START
:F3
cls
goto START
:F2
echo F2
explorer.exe
goto START
:F1
echo F1
cmd.exe
goto START
:END
%dr%
remmenu\normcurs.com
rem promptrs
exit

There are 3 .com files. These were created by dos debug by scripts.
reply.com by reply.scr
debug < reply.scr
a 100
mov ah,8
int 21
cmp al,0
jnz 10a
int 21
mov ah,4c
int 21

r cx
e
n reply.com
w
q

nocurs.com by nocurs.scr
debug < nocurs.scr
a 100
mov ah,1
mov ch,20
int 10
int 20

r cx
8
n nocurs.com
w
q


And nocurs.com by nocurs.scr
debug < nocurs.scr
a 100
mov ah,0f
int 10
cmp al,7
jz 10d
mov cx,607
jmp 110
mov cx,0b0c
mov ah,1
int 10
int 20

r cx
16
n normcurs.com
w
q

The nocurs.com does not work running cmd.exe. It does work on the other machine using command.com in dosonly in the config.nt. The reply.com I think I found a solution to the batch file problem.
Found a fine called choice.exe (choice.com doesn't work for the same reason that the other .com programs don't).

I need to change the batch file a little around the if errorlevel lines since choice.exe returns with different codes.

One of the command line switches for choice.exe is the /c:?. Where the ? are keys that choice.exe will accept. What do I enter for keys like F1 or F2?
Thanks
FrankChoice does not work with the function keys F1 to F12.
Thank you very much.
I will just have to use the 0-9 keys

About not being able to run .com files, I might ask the Windows Forum.
Frank
5060.

Solve : How to determine the Vista OS in bat??

Answer»

I am able to DETERMINE the system OS by using ver command, but not for Windows Vista.

In windows Vista machine it just outputs -> Microsoft Windows [Version 6.0.6001]
where as in other OS am able to parse for XP, 2003 etc, from the command ver's output.

Is there a way to determine it in Vista.

Thanks in ADVANCE for the help.Not an exact answer, but some information HERE for you.

From the page:
Quote

(The Vista version is 6.0 whereas the XP version is 5.1.)
Thanks mate. It SOLVES my PBM to an extent.Don't check for text such as "XP" or "Vista", check for the number.
5061.

Solve : MS DOS LANGUAGE?

Answer»

Can anyone see whats wrong with this code? when you enter 1 number and enter to get that program up ALL of the programs come up! why? forgott its in swedish but i hope you can help me anyway !

Code: [Select]@echo off
cls
color A
title Arams Understod
echo Skriv vilken siffra du vill ha och sen ENTER

echo skriv 1 for att oppna Kalkylatorn
echo skriv 2 for att oppna Paint
echo skriv 3 for att oppna Internet Explorer
echo skriv 4 for att oppna Utorrent
echo skriv 5 for att oppna Mozilla Firefox
echo skriv 6 for att oppna Windows Update
echo skriv 7 for att oppna Msn Messenger (dock inte 7.5 och gammlare)
echo skriv 8 for att oppna Anteckningar
echo skriv 9 for att oppna Diskrensning
echo skriv 10 for att oppna Windows Media Player
echo skriv 11 for att oppna Skarmtangentbord
echo skriv 12 for att oppna Skarmforstoraren (dra DEN lite nerat sa den blir storre)
echo skriv 13 for att oppna wordpad
echo skriv 14 for att logga ut denna anvandare
echo GJORD AV : ARAM
set /p var=Skriv vilken siffra du vill:

IF '%VAR%' == '1' GOTO calc
IF '%VAR%' == '2' GOTO paint
IF '%VAR%' == '3' GOTO internet
IF '%VAR%' == '4' GOTO utorrent
IF '%VAR%' == '5' GOTO firefox
IF '%VAR%' == '6' GOTO update
IF '%VAR%' == '7' GOTO messenger
IF '%VAR%' == '8' GOTO notepad
IF '%VAR%' == '9' GOTO diskrensning
IF '%VAR%' == '10' GOTO mediaplayer
IF '%VAR%' == '11' GOTO skärm
IF '%VAR%' == '12' GOTO hjälp
IF '%VAR%' == '13' GOTO wordpad
IF '%VAR%' == '14' logoff

echo GJORD AV : ARAM


EXIT

:calc
%SystemRoot%\system32\calc.exe

:paint
%SystemRoot%\system32\mspaint.exe

:internet
"C:\Program\Internet Explorer\iexplore.exe"

:utorrent
"C:\Program\uTorrent\uTorrent.exe"

:firefox
"C:\Program\Mozilla Firefox\firefox.exe"

:update
%SystemRoot%\system32\wupdmgr.exe

:messenger
"C:\Program\Windows Live\Messenger\msnmsgr.exe"

:notepad
%SystemRoot%\system32\notepad.exe

:diskrensning
%SystemRoot%\system32\cleanmgr.exe

:mediaplayer
"C:\Program\Windows Media Player\wmplayer.exe" /prefetch:1

:skärm
%SystemRoot%\system32\osk.exe

:hjälp
%SystemRoot%\system32\magnify.exe

:wordpad
"C:\Program\Windows NT\Tillbehör\wordpad.exe"
[Saving space - attachment deleted by admin]The code appears to be falling thru all your logic after you go to a label. Try putting a goto :eof in every one of your labels:

Example:
Code: [Select]:internet
"C:\Program\Internet Explorer\iexplore.exe"
goto :eof

I don't RECALL a Program directory on any version of Windows. There are other ways to fix this, but this needs the least explanation. Quote from: Sidewinder on June 10, 2008, 12:17:50 PM

The code appears to be falling thru all your logic after you go to a label. Try putting a goto :eof in every one of your labels:

Agreed. Otherwise the code will just execute each line after the label until it reaches the end.

Quote
I don't recall a Program directory on any version of Windows.

You've never seen Swedish Windows, then, in which "C:\Program" is the name of the folder called "C:\Program Files" in English language versions.

You may be interested to know that there quite a few countries in the world where English is not the main language. Many of them have their own-language-version of Windows or other OSs available.

Quote
You've never seen Swedish Windows, then, in which "C:\Program" is the name of the folder called "C:\Program Files" in English language versions. Roll Eyes

You may be interested to know that there quite a few countries in the world where English is not the main language. Smiley Many of them have their own-language-version of Windows or other OSs available.

It's true I've never seen the Swedish version of Windows, and I'm well aware that English is not used everywhere. What is puzzling is why Microsoft would not simply translate "Program Files" (two words) into the local language rather than use "Program" (one word). Shouldn't it be "program ARKIVERA?" (two words)?


Quote from: Sidewinder on June 10, 2008, 02:07:35 PM
Quote
Shouldn't it be "program arkivera?"(two words)?

youre right , it could be that way , but in swdish it sounds better if you have "program" only , program files = program filer in swedish , anywayz i didnt understand how to fix it could you be a little more specific ?

Thx ///aram
oops , quoted all nbut you see understans where i did write Quote
There are other ways to fix this, but this needs the least explanation.

So much for that idea.

Code: [Select]@echo off
cls
color A
title Arams Understod
echo Skriv vilken siffra du vill ha och sen ENTER

echo skriv 1 for att oppna Kalkylatorn
echo skriv 2 for att oppna Paint
echo skriv 3 for att oppna Internet Explorer
echo skriv 4 for att oppna Utorrent
echo skriv 5 for att oppna Mozilla Firefox
echo skriv 6 for att oppna Windows Update
echo skriv 7 for att oppna Msn Messenger (dock inte 7.5 och gammlare)
echo skriv 8 for att oppna Anteckningar
echo skriv 9 for att oppna Diskrensning
echo skriv 10 for att oppna Windows Media Player
echo skriv 11 for att oppna Skarmtangentbord
echo skriv 12 for att oppna Skarmforstoraren (dra den lite nerat sa den blir storre)
echo skriv 13 for att oppna wordpad
echo skriv 14 for att logga ut denna anvandare
echo GJORD AV : ARAM
set /p var=Skriv vilken siffra du vill:

IF '%VAR%' == '1' GOTO calc
IF '%VAR%' == '2' GOTO paint
IF '%VAR%' == '3' GOTO internet
IF '%VAR%' == '4' GOTO utorrent
IF '%VAR%' == '5' GOTO firefox
IF '%VAR%' == '6' GOTO update
IF '%VAR%' == '7' GOTO messenger
IF '%VAR%' == '8' GOTO notepad
IF '%VAR%' == '9' GOTO diskrensning
IF '%VAR%' == '10' GOTO mediaplayer
IF '%VAR%' == '11' GOTO skärm
IF '%VAR%' == '12' GOTO hjälp
IF '%VAR%' == '13' GOTO wordpad
IF '%VAR%' == '14' logoff

echo GJORD AV : ARAM


EXIT

:calc
%SystemRoot%\system32\calc.exe
goto :eof

:paint
%SystemRoot%\system32\mspaint.exe
goto :eof

:internet
"C:\Program\Internet Explorer\iexplore.exe"
goto :eof

:utorrent
"C:\Program\uTorrent\uTorrent.exe"
goto :eof

:firefox
"C:\Program\Mozilla Firefox\firefox.exe"
goto :eof

:update
%SystemRoot%\system32\wupdmgr.exe
goto :eof

:messenger
"C:\Program\Windows Live\Messenger\msnmsgr.exe"
goto :eof

:notepad
%SystemRoot%\system32\notepad.exe
goto :eof

:diskrensning
%SystemRoot%\system32\cleanmgr.exe
goto :eof

:mediaplayer
"C:\Program\Windows Media Player\wmplayer.exe" /prefetch:1
goto :eof

:skärm
%SystemRoot%\system32\osk.exe
goto :eof

:hjälp
%SystemRoot%\system32\magnify.exe
goto :eof

:wordpad
"C:\Program\Windows NT\Tillbehör\wordpad.exe"
goto :eof

This should fix any problems. You don't actually NEED a goto in the :wordpad label, but it may prove useful for future expansion. THANK YOU SO MUCH MATE! IM SO FKIN HAPPY RIGHT KNOW!!!
5062.

Solve : nested for loop and set command?

Answer»

Hello,

I'm tyring to run the command below to output filenames with a specific format to a text file. The script outputs a directory listing to a text file, it then does a dir listing on any subdirectories and finally it does a dir listing of files in those directories. We then output the VARIABLES returned to a text file to create a unique filename based on the directory listings. The issue I'm having is that I want to subtitute a variable for the top directory name RATHER than using the directory name itself.

Any ideas would be MUCH appreciated.


Example filename required - 130042008filename.tif from the variables - echo %var%%%b%%c

Current Filename returned - Directory name A30042008filename.tif from the variables echo %%a%%b%%c

del c:\filenames.txt
dir /b E:\ > c:\dir.txt
for /f "tokens=*" %%a in (
'type c:\dir.txt'
) do (
echo %%a
if %%a == Directory name A (
set var=1
echo %var%
dir /b "e:\%%a\Images\*" > c:\dates.txt
for /f "tokens=*" %%b in (
'type c:\dates.txt'
) do (
echo %%b
for /f "tokens=*" %%c in (
'dir /b "e:\%%a\Images\%%b\*"'
) do (
echo %var%
echo %%c
echo %var%%%b%%c >> c:\files2.txt ))

if %%a == Directory name B (
set var=2
echo %var%
dir /b "e:\%%a\Images\*" > c:\dates.txt
for /f "tokens=*" %%b in (
'type c:\dates.txt'
) do (
echo %%b
for /f "tokens=*" %%c in (
'dir /b "e:\%%a\Images\%%b\*"'
) do (
echo %var%
echo %%c
echo %var%%%b%%c >> c:\files2.txt ))

)
)You could try parsing the path using the backslash as a DELIMITER. This would break down the path into component parts which you can glue back together using just the drive and the top level directory.

Good luck.

5063.

Solve : Artificial Intelligence Project?

Answer»

I built my basic AI but I am thinking up new THINGS to add to it. Like for example:

-If you were to type in "google" and then a new question would ask what you WANT to look up and then it would look that up and OPEN it in a new window. Can I make it do this?

I'll add to this post LATER.

5064.

Solve : Rename folders??

Answer»

is it possible to make a batch files that just remove a piece of the name?
eg. "CD blabla" then i want to remove "CD " including the space.
some time its "GAME CD blabla" then i want to remove it with the two spaces " CD "Quote

is it possible to make a batch files that just remove a piece of the name?
eg. "CD blabla" then i want to remove "CD " including the space.
some time its "Game CD blabla" then i want to remove it with the two spaces " CD "

This little snippet will remove the space on the right. You can modify it to remove the space on the left.

Code: [Select]@echo on
setlocal enabledelayedexpansion
for /F "tokens=* delims=" %%x in ('dir /a:d /b') do (
SET input="%%x"
set input=!input:cd =!
ren "%%x" !input!
)


Hope this helps. Quote from: Sidewinder on June 11, 2008, 03:12:20 AM
Quote
is it possible to make a batch files that just remove a piece of the name?
eg. "CD blabla" then i want to remove "CD " including the space.
some time its "Game CD blabla" then i want to remove it with the two spaces " CD "

This little snippet will remove the space on the right. You can modify it to remove the space on the left.

Code: [Select]@echo on
setlocal enabledelayedexpansion
for /f "tokens=* delims=" %%x in ('dir /a:d /b') do (
set input="%%x"
set input=!input:cd =!
ren "%%x" !input!
)


Hope this helps.



THANK You! it realy helped!
+karma
5065.

Solve : Copy command not working?

Answer»

Everytime i put in the command to copy a folder it says its completed but i check the directory and still nothing. This is the script that im trying atm:
Code: [SELECT]SET COPYCMD=/Y
ROBOCOPY "C:\test" C:\test2 /E /V /L
pause
Before i was using XCOPY but still had no luck Help please if you can.Try using.
Code: [Select]xcopy "C:\test" C:\test2 /v /y /e
pauseIt works fine for me.ty it worked Ok another PROBLEM has arose, i dont know if its because im building this on vista but the simplest scripts are giving errors. My start command doesnt work now

Code: [Select]START %CURRDIR%\..\Backup.reg
When i do it like that it says it cannot find the file but when it has the "" it opens a cmd window and i dnt want that.Quote from: youngbucks on May 10, 2008, 05:26:30 PM

Code: [Select]START %CURRDIR%\..\Backup.regWhen i do it like that it says it cannot find the file but when it has the "" it opens a cmd window and i dnt want that.

is %currdir% set to some value?
no, im trying to let it start the registry entry from inside its current directory. Its SUPPOSED to launch it from the folder E1 which would be in whatever directory the user copies it to.Please explain more fully.

What is the purpose of the variable %currdir%? does it actually appear in the batch file? Why are you using it? What (and where) is the folder E1?

Quote
%CURRDIR%\..\Backup.reg

Does this line actually appear in your batch? Just like that?
Im not 100% sure what your asking for but ill try by best to explain. Im creating a cmd based installer to fix a problem with a printer for a few people and there is a registry key entry that they are missing which i have taken off my computer and put into the folder E1 and named it Backup.reg so if you extracted everything i gave you it would be Wherever you copied it to\Fix\E1\Backup.reg. Im trying to make it so that it will launch the registry entry from the folder during the installation process so im trying to use the START command which leads me to the problem i now have with getting it to work.

Here is my full script so far, if theres a problem in it stopping it from launching let me know.
Quote
@echo off
color 04
title Fallen Soilders Release: Fix For Printer V.02
Echo .:,,,,,,,,,,,,, .,,,,,,,.
Echo ;s #
Echo ;; @
Echo ; : H [emailprotected]@
Echo ; : B [emailprotected]@
Echo ; : # [emailprotected]@
Echo ; : @ [emailprotected]@
Echo ; : @ [emailprotected]@
Echo ; : @ @
Echo ; : @ .:,,,;r
Echo ; : @H2SiiSXX
Echo ; ##: @
Echo ;r , ,,. ..,;@
Echo ;r S95SS5; [emailprotected]@
Echo ;; @ [emailprotected]@
Echo ;. @ [emailprotected]@
Echo ; # [emailprotected]@
Echo ;: @ [emailprotected]@
Echo ;r :@r

Echo Fallen Soilders Release: Fix For Printer V.02
echo.
:BEGIN
echo 1. INSTALL
echo 2. Uninstall
echo 3. Exit
:B2
set /p choice=What do you want to do?
if "%choice%"=="1" goto Install
if "%choice%"=="2" goto Uninstall
if "%choice%"=="3" goto End
if "%choice%"==" " goto False

:False
Echo That response does not Corespond!
goto :B2

: Install
:I1
IF EXIST "%0\..\E1.cab" (echo All Files Found. Press Enter To Continue...) ELSE goto CheckF
IF EXIST "%0\..\E1" goto :I2 ELSE goto :I1
Pause
Echo Running Extraction Process
TASKKILL /F /IM explorer.exe
EXPAND -r -F:* "%0\..\E1.cab" %TEMP%
Move %TEMP%\E1 "%CURRDIR%"
:I2
Pause
START %CURRDIR%\Backup.reg
SET COPYCMD=/Y
xcopy "%0\..\E1\system32" C:\test2 /v /y /e /i /c
START C:\Windows\explorer
goto :BEGIN

:CheckF
Echo File Checking has failed!
Pause
goto :BEGIN

:Uninstall
Echo Currently Uninstalling All Files...
DEL /s /q "%0\..\E1"
RD /s /q "%0\..\E1"
RD /s /q "C:\test2"
Pause
goto :BEGIN

Nevermind i FIXED it, for some reason the command could not reach the file, probably because its a registry entry but i changed it to:

Code: [Select]REGEDIT %CURRDIR%\..\Backup.regCode: [Select]%CURRDIR%
What I am trying to find out is, why are you using this variable? It isn't a standard Windows thing. It exists on Linux/Unix systems though. What value is it supposed to have? Who told you to use it?

Is this a batch file you copied from somewhere? Because if you wrote it yourself you would know what I am asking?

Also, what are you expecting %0\..\ to be doing here?

Code: [Select]IF EXIST "%0\..\E1.cab"
I can see a few other things that need fixing, but if you could answer my questions above for now?





I just started to learn cmd programming and im putting this together from basic things i remember so thats why im not 100% on what your asking. The script you see was written by me from scratch and with the help of this website http://www.ss64.com/index.html . As for "%0\..\" i placed it there under the influence that when cmd looks for the file it will search all directories (acting as something like a wildcard) until it finds the file. Im trying by best to explain because im new to this, and since you found some problems if you dont mind could you please point them out so i dont make the same mistake again.

Edit* Also if this not too much, is there a way for this batch file to create a report and send it to my computer from someone elses?Well, these are the points that spring out at me, after you have fixed these it might be nearer to working

@echo off
color 04

REM Corrected spelling of 'soldiers'

title Fallen Soldiers Release: Fix For Printer V.02
Echo .:,,,,,,,,,,,,, .,,,,,,,.
Echo ;s #
Echo ;; @
Echo ; : H [emailprotected]@
Echo ; : B [emailprotected]@
Echo ; : # [emailprotected]@
Echo ; : @ [emailprotected]@
Echo ; : @ [emailprotected]@
Echo ; : @ @
Echo ; : @ .:,,,;r
Echo ; : @H2SiiSXX
Echo ; ##: @
Echo ;r , ,,. ..,;@
Echo ;r S95SS5; [emailprotected]@
Echo ;; @ [emailprotected]@
Echo ;. @ [emailprotected]@
Echo ; # [emailprotected]@
Echo ;: @ [emailprotected]@
Echo ;r :@r

Echo Fallen Soldiers Release: Fix For Printer V.02
echo.
:BEGIN
echo 1. Install
echo 2. Uninstall
echo 3. Exit
:B2
set /p choice=What do you want to do?
if "%choice%"=="1" goto Install
if "%choice%"=="2" goto Uninstall

REM Where is the :end label??? (I can't find it in your code)

if "%choice%"=="3" goto End

REM You don't need this, because if choice was not 1,2 or 3 you are going to wind up here anyway
REM Also, you are testing for %choice% being a single space, which is a waste of time.

if "%choice%"==" " goto False

:False

REM that was not how you spell 'correspond' and it should not have a capital C

Echo That response does not correspond with a valid choice!
goto :B2

: Install
:I1

REM %0 is a special variable that means "the file name of this batch file"
REM 2 dots .. means "the directory above this one"

REM You need to specify properly where E1.cab is going to be


IF EXIST "%0\..\E1.cab" (echo All Files Found. Press Enter To Continue...) ELSE goto CheckF
IF EXIST "%0\..\E1" goto :I2 ELSE goto :I1
Pause
Echo Running Extraction Process
TASKKILL /F /IM explorer.exe

REM see above

EXPAND -r -F:* "%0\..\E1.cab" %TEMP%

REM %temp% should really be "%temp%"
REM Change "%CURRDIR%" to "%CD%" wherever it occurs

Move %TEMP%\E1 "%CURRDIR%"
:I2
Pause

START %CURRDIR%\Backup.reg
SET COPYCMD=/Y
xcopy "%0\..\E1\system32" C:\test2 /v /y /e /i /c
START C:\Windows\explorer
goto :BEGIN

:CheckF
Echo File Checking has failed!
Pause
goto :BEGIN

:Uninstall
Echo Currently Uninstalling All Files...

REM not sure why this is being done
DEL /s /q "%0\..\E1"
RD /s /q "%0\..\E1"

RD /s /q "C:\test2"
Pause
goto :BEGIN
Ok i made the changes and the uninstallation part is to let the batch file delete all the files it has extracted and placed on the computer. RD and DEL are there because when i run it on this computer it says "access is denied" even when it has been elevated to run as admin but i removed DEL and left RD now which removes everything including the folder. Is there a way for cmd to create a report and send it to my computer from the users?
5066.

Solve : HELP!!!!!!!!!?

Answer»

Quote from: rhoads on April 29, 2008, 08:17:42 AM

last nite i got a call back from a friend of a friend lol, who i tried to contact to help out with this and he told me that i didnt need to use a for loop to do this.........that i could accomplish the same thing by using the set command.....

I'd appreciate it if you post your friend of a friend's solution on here.
no i just spoke to him on the phone....he lives in diff state and sort of explained what i had to do and that i was trying to FIGURE out the for command and he just told me that set command could just be used.......i ALMOST CRIED lol, j/k....but seriously i thought i had to use for and that is why i have been trying to figure this out for so long.Well, I am very surprised that your friend's friend thinks there is an easy way to get three items out of %1 just using SET, and I believe he is probably wrong. Without proof of his method then it is just something a guy told you on the phone. On the other hand, my batch file actually works.

i dont KNOW, he has a bachelors in computer science....i dont know him that well but he sounded confident, lol........he said i could use set after i told him i could only use %1 and that i can only use 2 EVars (Fname and Lname) in the batch file.....im not sure lolHey, if your friend is right, we might all learn something (as much as I try to avoid that.. )LOL yes but UNFORTUNATELY like i said he is out of state and i will probably never know....i worked on this for a couple hours last nite to no avail....then again i am a newbie.....i set fname=%1 but then to get lname and dept to work i dont knowQuote from: rhoads on April 30, 2008, 06:38:14 AM
i set fname=%1 but then to get lname and dept to work i dont know

You said you were allowed only 2 "evars" (whatever they are, I presume you meant variables) and to get Fname, Lname and Dept you will need 3. Are you sure you have posted the assignment exactly as you were given it?
I am sure, i rechecked my original post. I am thinking that obviously set is not the only command i need, i might not need for but just set i dont think will do it.....im losthave you got your assignment in writing? How do you know what it is you are supposed to be doing? Is it a work thing? A school thing?
5067.

Solve : How can i use AND or OR in IF condition??

Answer»

hi ...

I tried Giving two CONDITIONS which are connected by OR operation in IF CONDITION .It didnt allow me to give

or
|
||

what way i should give.,.??

to opearte like if ((a==b) or (c==d)

advance thanks
prasanna
You have to kludge it

CODE: [Select]If "%a%"=="%b%" goto label1
If "%c%"=="%d%" goto label1
goto LABEL2

:label1
REM you arrive here if (a==b or c==d) is TRUE

REM code
REM code
REM code

goto NEXT

:label2
REM you arrive here if (a==b or c==d) is FALSE

REM code
REM code
REM code

:next

5068.

Solve : Help with .bat and IF / ELSE commands?

Answer»

Hey all

I'm trying to test a variable and if its correct open up another batch file, if its false go to another part of the original .bat file. Below is how Ive got my commands :

IF %VARIABLE% == 1 (
CALL TEST.BAT
)ELSE(
GOTO TEST2
)

But it generates this output without running the 2nd .bat file. PROMPT outputs "ELSE( was UNEXPECTED at this time". Ive tried changing the format but I cant get it to work.

Would this be the right way of doing it, or is there a better way.

Thanks, Alextry;

if /i "%variable%" EQU "1" (start test.bat) else goto test2


notice I added "/i" this will MAKE the if statement compare them as integers. I've also added the " " around the values we're comparing and I stuck it on one line cos I reakon it's easier to read.

I haven't tested it, but I hope it helps. Quote from: blastman on May 09, 2008, 08:30:06 AM

notice I added "/i" this will make the if statement compare them as integers.

No it won't; using if with the /i switch makes the comparison case-insensitive, or makes it ignore case if you prefer. Since numerical digits don't have "upper" or "lower" case, it will have no effect whatsoever.

Quote
I've also added the " " around the values we're comparing

Good practice

Quote
and I stuck it on one line cos I reakon it's easier to read.

Ditto

This is an alternative

Code: [Select]if "%variable%"=="1" (start test.bat) else goto test2
Quote from: Dias de verano on May 09, 2008, 10:50:00 AM
Quote from: blastman on May 09, 2008, 08:30:06 AM
notice I added "/i" this will make the if statement compare them as integers.

No it won't; using if with the /i switch makes the comparison case-insensitive, or makes it ignore case if you prefer. Since numerical digits don't have "upper" or "lower" case, it will have no effect whatsoever.


I may have miss understood the explaintion for the help option.

"and the /I switch, if SPECIFIED, says to do case insensitive string compares. The /I switch can also be used on the string1==string2 form of IF."

and the bit that confused me...

"These comparisons are generic, in that if both string1 and string2 are both comprised of all numeric digits, then the stings are converted to numbers and a numeric comparison is performed"

I guess I thought that last section was part of the explation of the /I switch.

oh well.

as long as it works eh???

Quote from: blastman on May 09, 2008, 01:41:19 PM
the bit that confused me...

"These comparisons are generic, in that if both string1 and string2 are both comprised of all numeric digits, then the stings are converted to numbers and a numeric comparison is performed"

That means decimal (or lesser base) integers (the only numbers that don't contain punctuation or letters) are compared as numbers, everything else as strings. (Numeric comparisons are made as if all
the numbers were base ten, so comparing an octal and a decimal number would often give wrong results.)
Thanks for the reply guys and it works
5069.

Solve : folder in the desktop?

Answer»

how to copy a file when my FOLDER is in the desktop?for example,i will create a folder in DOS cmd,then it will appear in the desktop,and i want to copy a file in my new create folder,what should i do?LIKE just about everything else the Desktop is contained in a folder. If you want to copy a file to your new desktop folder using Dos or the Command PROMPT you should use the Copy command e.g.

Copy_file.ext_"c:\Documents_and_Settings\All_Users\Desktop\New_Folder\"

or

Copy_file.ext_"c:\Documents_and_Settings\Administrator\Desktop\New_Folder\"

The above is ok in Windows 2k, you didn't MENTION which operating system you are using. (Replace the _ with spaces)

Of course in Explorer you can simply Copy/Paste the file.

Good luck

5070.

Solve : Batch command for renaming and moving file to other directory with suffix.?

Answer»

hi,
I need renaming and moving file to other directory with SUFFIX of date and time.
this is what i TRIED
for /f "TOKENS=1-5 delims=:" OR "tokens=1-5 delims=/ " %%d in ("%time%") %%d in ("%date%") do rename "E:\LogUpdate\CtRddmMavenRDR.meta" "CtRddmMavenRDR"%%e-%%f-%%g-%%d-%%e.meta
but not workingI have never seen that "tokens=" OR "tokens=" thing before. Where did you GET that? Also that weird way you are trying to run two loops at the same time, did you invent that yourself?



hi,
i have never USED batch command before but i found these two loops working fine individually
but my need is to get both date and time as suffix to file name.

pls help me out
thanks in advance

5071.

Solve : Delete a virus using .bat file. help!?

Answer»

Hi

I have a virus in my computer, and i was creating a .bat file than delete it. But now it is changing his folder, but it don't change his name. So I need to do a scan to find the FOLDERS and next delete them.

Can I to do a SEARCH and delete the results? How I do this?

Thx!UM go to start and press search and look for the file nameWelcome to the CH forums.

You should be using a recognised virus removal tool to CLEAN your system. The virus, which you do not name, may be resident in more than one location.

Post in the "Computer Viruses and Spyware" forum and/or wait for one of the CH AUTHORISED malware removal specialists to respond.

Please read this..

Good luck

5072.

Solve : Folder creation and numbering issue.?

Answer»

Hey all.

I've been scratching my head over this for some time now;

Code: [Select]@echo off
set /p name="Skriv elev navn(e): "
echo 1
md %name%
echo 2
echo %name%>>folderlog.txt
echo 3
echo %name%>%name%\%name%.txt
echo 4
pause
This is the code I've got so far, obviously the echo's are for debugging.

This is the aim of this script;

To create as many folders as required, in this case student names - e.g.: John, Jake, Peter etc.
I need it to create the folder, a .txt file within the newly created folder containing the number the folder was during creation - and the name of the folder.
As such: MAIN DIR\John\John.txt - containing string: , .
I hope this is clear enough.
I have yet to figure out the numbering issue, and it's a real head-scratcher. However, I have successfully managed to get it to create the .txt file with "John" in it.
However, when I try to make more than one folder - the script breaks only creating the folders, and no .txt files. This happens at the .txt file creation string.
That's basically where I'm stuck. I've worked on it for hours today, with no luck.

Also, I've been attempting to make a batch file that will delete all *folders* including their contents in a directory. So far my attempts have been unsuccessful.

I really hope this great site - and it's members can provide me with help for a solution to this.

Thanks in advance!

-Frobergtry this for numbering

@echo off
:labl1
set /p name="Skriv elev navn(e): "
echo 1
for /f %%i in ('dir /a ^|find /c "<DIR>"') do set /a d=%%i
md %name%
echo 2
echo %name%>>folderlog.txt
echo 3
echo %d%,%name%>"%name%\%name%.txt"
echo 4
set re=
set /p re=to insert an other student press r
if "%re%" EQU "r" goto labl1
pause


i hope its helpfulIt is indeed.
Only, it creates the names one at a time.. I'd really prefer to just type in a long string of names... but that's not possible I take it?
Been playing around with it a bit, any chance of getting it to start counting with number 1 instead of number 2?

I can't see that particular oddity being set in the script..at first i forgot to till u that the u have to remove the /a from the dir command in the for LOOP thats due to it will give u 2 aditional directoryes that are . and .. for that u have to remove the /a unless u got som headin folders u want to cont

and about the names u can put them into a file line by line an do this

setlocal ENABLEDELAYEDEXPANSION
for /f "delims=" %%i in (names.txt) do (
set name=%%i
echo 1
for /f %%t in ('dir ^|find /c ""') do set /a d=%%t
md "!name!"
echo 2
echo !name!>>folderlog.txt
echo 3
echo !d!,!name!>"!name!\!name!.txt"
echo 4
)
pause
endlocal
Nah, it has to be direct user input.

I was wondering if you could look at SOMETHING else, perhabs.

I'm trying to make a batch to delete all the directories, and the contents - but leave the files in root intact.

Here's what I've got so far;
Code: [Select]@echo off
dir /b /ad %1 > dirlist.txt
for /f %%i in (dirlist.txt) do rd /s /q %1\%%i
Basically creating a directory list, and have it delete the folders listed. However, it says "File not found" in the cmd prompt. Any ideas?


I really appreciate your help man.Quote

To create as many folders as required, in this case student names - e.g.: John, Jake, Peter etc.
I need it to create the folder, a .txt file within the newly created folder containing the number the folder was during creation - and the name of the folder.
As such: MAIN DIR\John\John.txt - containing string: <number>, <John>.

Code: [Select]@echo off
setlocal enabledelayedexpansion
set count=0
set /p name=Skriv elev navn(e):
for %%v in (%name%) do (
call set /a count=%%count%%+1
md %%v
echo ^<!count!^> ^<%%v^> >> %%v\%%v.txt
)

Enter all the names, each separated by a space, at the prompt. (ie. John Jake Peter)

Quote
@echo off
dir /b /ad %1 > dirlist.txt
for /f %%i in (dirlist.txt) do rd /s /q %1\%%i

Code: [Select]@echo off
for /f "tokens=* delims=" %%i in ('dir /b /a:d %1') do (
rd "%1\%%i" /s /q
)

You might want to add a prompt for the directory name, rather than passing it along the command line.

Good luck. Excellent. I've got it working now.

So, the other query. Any way I can get a batch file to delete all folders in, for EXAMPLE, C:\data\project\blah - and leave the other files in that directory intact?

All the methods I've tried, have either deleted the whole folder, or just deleted my files and left the directories alone.

I would only need to keep two batch files in the root, everything else should go.

The "Make folder" batch and the "delete all dirs" batch file.

Thanks a bunch guys!Quote
So, the other query. Any way I can get a batch file to delete all folders in, for example, C:\data\project\blah - and leave the other files in that directory intact?

This was asked and answered in the previous post:

Code: [Select]@echo off
for /f "tokens=* delims=" %%i in ('dir /b /a:d %1') do (
rd "%1\%%i" /s /q
)

As mentioned previously, you may want to prompt for the directory name instead of passing it along the command line.


Prompt for directory name?

It should delete all folders in that directory, including their contents - without removing files in the root directory.. The two batch files, and whatever .txt files may be present. Quote
@echo off
dir /b /ad %1 > dirlist.txt
for /f %%i in (dirlist.txt) do rd /s /q %1\%%i

In your original code you referenced the %1 variable which in most cases is defined as an argument on the command line.

Quote
Prompt for directory name?
Yes, just like you did in the other batch file:
Quote
set /p name="Skriv elev navn(e): "

If batch file is to run against the current directory, remove the reference to %1
Code: [Select]@echo off
for /f "tokens=* delims=" %%i in ('dir /b /a:d') do (
rd "%1\%%i" /s /q
)

Oh my GOD! I love you! YOU ARE MY NEW BEST FRIEND!

That piece of code works FLAWLESSLY..

I mean, WOW!
5073.

Solve : Hacking and Dos?

Answer»

Friends can u please suggest me some forums/websites regarding hacking and dos We aren't your "friends" here if you are a hacker. You won't get any help here, the only thing I think that needs to be said is.... goodbye!
If you don't know enough about finding info on hacking/Dos you will never make the grade as a hacker.

Here is a definition I really like:
Quote

The ........File contains a bunch of definitions of the term ‘hacker’, most having to do with technical adeptness and a delight in solving problems and overcoming limits. If you want to know how to become a hacker, though, only two are really relevant.

There is a community, a shared culture, of expert programmers and networking wizards that traces its history back through decades to the FIRST time-sharing minicomputers and the earliest ARPAnet experiments. The members of this culture originated the term ‘hacker’. Hackers built the Internet. Hackers made the Unix operating system what it is TODAY. Hackers run Usenet. Hackers make the World Wide Web work. If you are part of this culture, if you have contributed to it and other people in it know who you are and call you a hacker, you're a hacker.

The hacker mind-set is not confined to this software-hacker culture. There are people who apply the hacker attitude to other things, like electronics or music — actually, you can find it at the highest levels of any science or art. Software hackers recognize these kindred spirits elsewhere and may call them ‘hackers’ too — and some claim that the hacker nature is really independent of the particular medium the hacker works in. But in the rest of this document we will focus on the skills and attitudes of software hackers, and the traditions of the shared culture that originated the term ‘hacker’.

There is another group of people who loudly call themselves hackers, but aren't. These are people (mainly adolescent males) who get a kick out of breaking into computers and phreaking the phone system. Real hackers call these people ‘crackers’ and want nothing to do with them. Real hackers mostly think crackers are lazy, irresponsible, and not very bright, and object that being able to break security doesn't make you a hacker any more than being able to hotwire CARS makes you an automotive engineer. Unfortunately, MANY journalists and writers have been fooled into using the word ‘hacker’ to describe crackers; this irritates real hackers no end.

The basic difference is this: hackers build things, crackers break them.

So if you want to become a hacker or a cracker first study programming techniques in depth.

Good luckCouldn't of said that better *tears forming in eyes*Back in the 80s, we used to say that a hacker's computer was one with a built in ashtraythat PARAGRAPH moved me Quote
Back in the 80s, we used to say that a hacker's computer was one with a built in ashtray

It's probably not politically correct, but I have this vision of a PC smoking a Marlboro. Back In my Day Windows 1.0 was a MAD skittled Operating Systemn and It still is no one wants To Do All FLIPPITYJIBBITYJABBERYBUZZ! Crap of the Screen making It all Blocky and 3d Thats Dumb Microsofts used to be awesome...Quote from: Carbon Dudeoxide on April 02, 2008, 11:44:02 PM
Couldn't of said that better *tears forming in eyes*

I would cry... if i could.

I sir, am a man!Quote from: NOT ADMIN :P on April 30, 2008, 08:31:46 PM
Quote from: Carbon Dudeoxide on April 02, 2008, 11:44:02 PM
Couldn't of said that better *tears forming in eyes*

I would cry... if i could.

I sir, am a man!

I'm not so I'm flooding with tears.

P.S. Congratulations for being a man NOT ADMIN
5074.

Solve : MSDOS batch file - del wildcards?

Answer»

At our SCHOOL we want to be able to delete all the contents of the My Music, My Pictures and My Videos folders on the computers with a batch file. I know there's

DEL "C:/Documents and Settings/username/My Documents/My Pictures/*.*" /Q

But the problem is there's dozens of computers and they each have dozens of different users on WINDOWS XP.

Is there a wildcard that I can USE with DEL or RMDIR in the path at 'username' so it will select all the folders, then go on to delete each "/My Documents/My Pictures/*.*" in each of the different users folders? WITHOUT having to specify each different actual username.

Cheers in advance.This might work:

Code: [Select]del "%userprofile%/My Documents/My Pictures/*.*" /Q

Good luck.

5075.

Solve : How can I boot with floppy and get external usb cd to load xp?

Answer»

Hello
I have a dell laptop with a floppy but no cd and a formatted hdd. I need to load xp from external usb cd drive. I can get as far a getting usb to work and external cd drive is recognised but gives cdr103 not high sierra.
The laptop is back a bit so doesnt boot from usb and is also usb 1.1
Any ideas please
number7What is the exact model of the laptop?

Chances are if the BIOS doesn't support booting from a USB device, there's nothing you can do.

I take it the internal CD drive is not working....?lattitude c510 and it aint got a cd only a floppy. I have LOADED xp on to it as a slave driver on ANOTHER pc then removed it at reboot then put it back to dell. Works fine except C drive says its d: and it is a messy installation. Id like a nice clean installation.
Like dos boot the usb, achieved, then the external cd, achieved, but wont read disks says error cdr103 not high sierra.
Then put on bart or similar then xpQuote from: number7 on June 09, 2008, 08:59:45 AM

external cd drive is recognised but gives cdr103 not high sierra.

That is an MSCDEX message. CDR103 : Disc in drive is not High Sierra.

All CD-ROM discs on a DOS or Windows-based system need to be in High Sierra or ISO 9660 format.

The message could therefore mean that the disk is:

* an audio disc.

* a disc configured for an Apple Macintosh.

* a damaged or bad disk.

Try another disk and see if it is readable. This may help...

http://www.bootdisk.com/usb.htm

cd should be ok as its my xp disk, all give the same.
Site looks good spoiler, thanks.
Just going to try a few, I may be sometime.Spoiler is right in that you need to load drivers on your floppy to recognise the CDRom drive. Reason: Older computer bios's were not USB ready.
First choice: Look for information that came with your USB drive, or from their website for instructions to create a bootable floppy with the cdrom drivers.
Second choice: Use information from Spoiler's site to create a bootable floppy with drivers for your USB CDRom drive. That should get you to the point of recognizing the disk.

But, ... I doubt that you will be able to use the CD in the USB drive to load XP normally.
The reason you will probably have trouble is this: During setup, Windows need to reboot one or more times. When you reboot, it will be without the drivers on the floppy, thus no cdrom will be present. (Bad News! )

You will need to get the XP setup files on the HD and setup from there.

Here is the way I would go:

1. Boot with floppy & CDRom drivers.
2. Copy I386 folder from CDRom to your hard drive.
Command line:
Code: [Select]xcopy /s /e /v D:\I386\*.* C:\I386\ (Assumes that cdrom is drive D: & that you have xcopy.exe on your floppy.)
3. Remove CDRom from drive. You won't need it again.
4. Run winnt.exe
Command line:
Code: [Select]C:\I386\WINNT.EXE /S:C:I386 /T:C:TEMPDRV5. Setup will proceed normally!

The /S switch specifies the source location of the setup files.
The /T switch specifies the location for the temp files during setup.
If you want a complete list of the switches for winnt.exe that will explain the command line above, type C:\I386\WINNT.EXE /?

Edited: Note: I added the switches /s /e /v to the xcopy command. (I forgot the first time.)
It will take 20 minutes or so to copy the I386 folder & sub folder to the HD, but you will save most of that time during setup, which will go much faster than it does from the CDRom.
Most interesting IImeyer2000, havent heard of winnt.exe before. It will probably be easier if I copy i386 directory from the cd to the dells hdd, but on another pc with a cd drive then return it and do as you recomend.Quote from: number7 on June 10, 2008, 04:18:48 AM
Most interesting IImeyer2000, havent heard of winnt.exe before. It will probably be easier if I copy i386 directory from the cd to the dells hdd, but on another pc with a cd drive then return it and do as you recomend.
That will work even better. Windows will copy the folder & sub-folder at least twice as fast.
Don't feel bad about not KNOWING about winnt.exe. I suspect that a large majority are in the same boat. The only time you really need to know about this is when installing on an older computer.

Note this quote:
Quote
A Win98 boot disk ... can be used to install these OS's. (Windows 2000 and XP)
I found that quote on this site:
Clean Install Windows XP

I just ran across this, which I forgot to mention, on the same site:
Quote
smartdrv.exe must be added and loaded manually before running WINNT.EXE
If I remember correctly, You will get an error telling you to load smartdrv first if you try to run winnt without it.

When you are done with the installation, you can delete the I386 folder if you need the space, but, if you don't, just leave it there. (It's like having the CD in the drive permanently)

Edit: I just ran across another site that explains winnt.exe & lists a lot more switches than I was familiar with. I don't think you will need anything more than I what I posted before, (I have used the command line as posted a number of times, and it works very well as is.) but if you want to be informed, here it is:
Installation of Windows XP
PS: Divide my name by 2. Thanks.That seems to work fine. Setup started and said couldnt find smartdrv on the computer did I want to exit or continue.
I did load smartdrv in the config.sys of the boot floppy.
Its still loading so thats brilliant, thanks Im realy impressed after all these years.
5076.

Solve : C Drive space?

Answer»

Hi,

I am using windows XP.

I need to create a batch file to check the c:drive space and display the result as available space free space and utilized space.

CHKDSK command does not help me to do so.

Can you tell me the command that will help me to do so...??

Thanks vbscript
Code: [Select]Set objFSO = CreateObject("Scripting.FileSystemObject")
Set colDrives = objFSO.Drives
For Each objDrive in colDrives
If objDrive.DriveLetter = "C" Then
Wscript.Echo "Available space: " & objDrive.AvailableSpace & " bytes"
Wscript.Echo "Free space: " & objDrive.FreeSpace & " bytes"
Wscript.Echo "Total size: " & objDrive.TotalSize
End If
Next
save as script.vbs and on command line

c:\test> cscript /nologo script.vbshey....no i do not want a vb code...i have absolutely no idea with visual basic...i was looking for a bat file with batch commands...is that possible..?In this case the VBScript is the better solution, concise, straightforward, and uses named data.

Quote

CHKDSK command does not help me to do so

It should. All the information you need is produced by chkdsk.

Code: [Select]@echo off
for /f "tokens=1-2" %%i in ('chkdsk c: ^| find /i "total disk space"') do (echo Total Space: %%i %%j)
for /f "tokens=1-2" %%i in ('chkdsk c: ^| find /i "kb available on disk"') do (echo Free Space: %%i %%j)

Be careful what you wish for. This batch solution eats up some clock time.



hey thanks sidewinder..

Ok so u suggest VB RIGHT..but i have no prior knowledge of VB.

I wanted to write a script that will connect to the sever os and check the c drive space on the server machine...will VB work there?If the server's C: drive is mapped to your system, the VBScript solution that was posted should work fine after changing the drive letter.

If not, the FileSystemObject is available only for local drives. Instead you'd need to use the Windows Management Interface (WMI).

Oh god these terms are Greek to me... you don't speak greek, doesn't mean you can't speak greek. Quote from: Sidewinder on April 30, 2008, 08:34:24 AM
Code: [Select]@echo off
for /f "tokens=1-2" %%i in ('chkdsk c: ^| find /i "total disk space"') do (echo Total Space: %%i %%j)
for /f "tokens=1-2" %%i in ('chkdsk c: ^| find /i "kb available on disk"') do (echo Free Space: %%i %%j)

Be careful what you wish for. This batch solution eats up some clock time.

Less time if you make chkdsk run once, REDIRECTING its output to a file, and do all the fancy FIND stuff on the file, a LOT more time if there are any errors on the disk that need fixing. PS He asked for used space as well

df1.bat...

Code: [Select]@echo off
REM show available space free space and utilized space.
REM informative message to user
echo Running chkdsk c: (please wait)
REM Redirect output to file
REM Avoids running chkdsk 3 times
chkdsk c: > chkdsk.txt
echo Completed chkdsk.
echo Displaying desired output
echo 1. Total disk space:
REM use FIND to show desired lines of text
type chkdsk.txt | find "KB total disk space"
echo 2. Available space:
type chkdsk.txt | find "available on disk" | find /v "allocation"
echo 3. Used disk space:
type chkdsk.txt | find "files" | find "KB"
Code: [Select]D:\>df1
Running chkdsk c: (please wait)
Completed chkdsk.
Displaying desired output
1. Total disk space:
26724095 KB total disk space.
2. Available space:
11980504 KB available on disk.
3. Used disk space:
14527556 KB in 106148 files.




I'm posting this for all our Greek members:

Code: [Select]On Error Resume Next

Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
Const GroupDigits = -1

strComputer ="servername" 'Change to server name
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_LogicalDisk Where DeviceID = 'C:'", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)

For Each objItem In colItems
WScript.Echo "Drive: " & objItem.DeviceID
WScript.Echo "Size: " & FormatNumber(objItem.Size,0,,,GroupDigits)
WScript.Echo "Used: " & FormatNumber(objItem.Size - objItem.FreeSpace,0,,,GroupDigits)
WScript.echo "Free: " & FormatNumber(objItem.FreeSpace,0,,,GroupDigits)
Next

Remarkably, it's a trade off. Either batch code that looks like hieroglyphics from King Tut's tomb or VBScript that looks like Greek.
Thank you everybody for your valuable inputs..I am soon going to learn to speak greek..yes and you are right
" If i dont speak greek does not mean i can't!!"


Sidewinder the code you provided me with is checking space on server side using WMI???

CheersQuote
Sidewinder the code you provided me with is checking space on server side using WMI???

Yes, you'll need to replace servername in this line:

strComputer ="servername" 'Change to server name

To get the data from the local machine, replace servername with a dot (.) otherwise you can use the name of any computer on your network. KEEP the quotes.

Most of the code in a WMI script is BOILERPLATE. The challenge is to find the class that contains the data you need.

Good luck. Thank you so much.........just one question is it possible to create this script using Batch files?Quote from: sd on May 01, 2008, 11:11:46 AM
Thank you so much.........just one question is it possible to create this script using Batch files?

ghostdog74 doesn't "do" batch files. Even if that's what you asked for. Do try to keep up!
Quote from: sd on May 01, 2008, 11:11:46 AM
Thank you so much.........just one question is it possible to create this script using Batch files?

Batch code is not designed for remote execution although there are third party programs like psexec in the PS-Tools toolkit that may help. On a network, it may be worth your time to investigate what VBScript or any of the other Windows script languages offer in the way of remote communications.

In answer to your question, you could use a batch file to launch the VBScript.

Good luck.

PS. VBScript and JScript come free as part of Windows. Most of the others are free but need to be downloaded.
5077.

Solve : How to read properties from a property file using batch file vice versa??

Answer»

Hello all

Can any ONE help me out on the following TOPICS?

1.How to READ properties values from a properties file using a batch file

and

2.How to write values to properties file from a batch file


Help would be greatly appreciated

ThanksBy properties file do you mean something like an .ini file?

You can use the for command to read any file and use ECHO to write to a file. If you actually want to run the statements in the property file, you may have to get creative with the set command.

Perhaps you can show us some of the data in this property file and EXPLAIN more fully the results you hope to achieve.

5078.

Solve : anyone help?

Answer»

i am trying to write a batch to delete the temp folder contents from path
C:\Documents and Settings\alan\Local Settings\Temp

and having no luck
i can delete files from anything before Documents and Settings but no SOON as Documents and Settings is put in as part of the file path i get the system cannot find the path specified, the path does exist as i have navigated there on the pc.

the same following script works on other drive with letter changed or anywhere on c drive but not the Documents and Settings path.

@echo off
DEL C:\Documents and Settings\alan\Local

Settings\Temp\*.*
pause

sorry if this is a stupid post lolThe path has SPACES and must be ENCLOSED in quotes. Your CODE
Code: [Select]del C:\Documents and Settings\alan\Local Settings\Temp\*.*
Should be changed to:
Code: [Select]del "C:\Documents and Settings\alan\Local Settings\Temp\*.*"
Or, why not use the environment variable for the temp folder with:
Code: [Select]del "%Temp%\*.*"

But that will delete only the files. From the path you show, it appears that you are running XP. If that is the case RD will delete all the files and folders except the ones in use at the time.
Code: [Select]rd /S /Q "%TEMP%\."

Notice that I did not use \*.*
Instead I used only the . to represent the current directory.
RD must have a directory name and *.* is not a valid directory name, while . is.

PS. Nothing stupid in asking!

5079.

Solve : only execute permission for a file?

Answer»

is there any way to give only EXECUTE permission(no read permission& no WRITE permission) to afile using DOS COMMAND prompt
You NEED Read Permission in order to Execute...otherwise it cant be executed or even seen!

Read-Only will allow execution without editing!

5080.

Solve : Shortening.?

Answer»

Is their anyway to reduce the size of this code?
Code: [Select]if EXIST data\level40.SAS (
set level=40
) else (
if EXIST data\level39.SAS (
set level=39
) else (
if EXIST data\level38.SAS (
set level=38
) else (
if EXIST data\level37.SAS (
set level=37
) else (
if EXIST data\level36.SAS (
set level=36
) else (
if EXIST data\level35.SAS (
set level=35
) else (
if EXIST data\level34.SAS (
set level=34
) else (
if EXIST data\level33.SAS (
set level=33
) else (
if EXIST data\level32.SAS (
set level=32
) else (
if EXIST data\level31.SAS (
set level=31
) else (
if EXIST data\level30.SAS (
set level=30
) else (
if EXIST data\level29.SAS (
set level=29
) else (
if EXIST data\level28.SAS (
set level=28
) else (
if EXIST data\level27.SAS (
set level=27
) else (
if EXIST data\level26.SAS (
set level=26
) else (
if EXIST data\level25.SAS (
set level=25
) else (
if EXIST data\level24.SAS (
set level=24
) else (
if EXIST data\level23.SAS (
set level=23
) else (
if EXIST data\level22.SAS (
set level=22
) else (
if EXIST data\level21.SAS (
set level=21
) else (
if EXIST data\level20.SAS (
set level=20
) else (
if EXIST data\level19.SAS (
set level=19
) else (
if EXIST data\level18.SAS (
set level=18
) else (
if EXIST data\level17.SAS (
set level=17
) else (
if EXIST data\level16.SAS (
set level=15
) else (
if EXIST data\level14.SAS (
set level=14
) else (
if EXIST data\level13.SAS (
set level=13
) else (
if EXIST data\level12.SAS (
set level=12
) else (
if EXIST data\level11.SAS (
set level=11
) else (
if EXIST data\level10.SAS (
set level=10
) else (
if EXIST data\level9.SAS (
set level=9
) else (
if EXIST data\levell8.SAS (
set level=8
) else (
if EXIST data\levell7.SAS (
set level=7
) else (
if EXIST data\level6.SAS (
set level=6
) else (
if EXIST data\leve5l.SAS (
set level=5
) else (
if EXIST data\level4.SAS (
set level=4
) else (
if EXIST data\level3.SAS (
set level=3
) else (
if EXIST data\level2.SAS (
set level=2
) else (
if EXIST data\level1.SAS (
set level=1
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
)
Code: [Select]for /L %%N in (40,-1,1) do if exist data\level%%N.sas set level=%%N
Like your code, it will set the level to the same as the lowest numbered level(NUMBER).sas in the folder \data.
Quote from: Dias DE verano on JUNE 07, 2008, 08:03:55 AM

Code: [Select]for /L %%N in (40,-1,1) do if exist data\level%%N.sas set level=%%N
Like your code, it will set the level to the same as the lowest numbered level(number).sas in the folder \data.

my code sets to the highest level.
i swapped it around a few hours ago because it was reading the highest value last so if level2 was there it would read that last and set it to level2.


i tried your code and it needs to be swapped around so it reads the lowest last

not sure how, but mine works fine, just your shortened VERSION says level2 if level 2 and level 40 are there.
when it should says level 40.Sorry, you are right. I was too hasty.

This is what you need

Code: [Select]for /L %%N in (1,1,40) do if exist data\level%%N.sas set level=%%N
This starts at 1 and works up to 40, setting the level to the last (highest) numbered file found.Quote from: Dias de verano on June 07, 2008, 08:19:08 AM
Sorry, you are right. I was too hasty.

This is what you need

Code: [Select]for /L %%N in (1,1,40) do if exist data\level%%N.sas set level=%%N
This starts at 1 and works up to 40, setting the level to the last (highest) numbered file found.

Thanks very much, even i am confused about the order now
thanks again
I read the title and thought this was about Crisco...Quote from: patio on June 07, 2008, 10:43:10 AM
I read the title and thought this was about Crisco...
Pardon?
In English, "shortening" also means any fat or oil used in baking like BUTTER or lard. Crisco is a US brand of cooking fat.

Quote from: Dias de verano on June 07, 2008, 11:46:33 AM
In English, "shortening" also means any fat or oil used in baking like butter or lard. Crisco is a US brand of cooking fat.


I'm English, and i did not know that, so thank you.
5081.

Solve : Batch file opening one autorun.exe after another??

Answer»

Here is the file I am using.

[autorun]
open=Autorun\Autorun.exe
wait open=Autorun.exe
icon=Start.icoAutorun files contain directives used by Windows when media is INSERTED or CHANGED in a CD or DVD drive. They have a .inf extension and contain no executable code. BATCH files contain code that can be interpreted by the command shell.

While autorun files can LAUNCH a batch file, batch files cannot launch an autorun file.

What are you trying to do?



Note: wait is not a VALID keyword in an autorun file.

5082.

Solve : Ansi characters in Wordpad?

Answer»

I would like to make a menu in a dos window. To do this I need to ENTER Ansi characters such as Alt-201 into an editor to save as a file. Then use the Type file.txt to display this file in the dos window.

The problem is that when I type characters like Alt-201 into wordpad I just get accented characters and not the Ansi character I need.

How do I enter Ansi characters into Wordpad?
I need Wordpad because I need a courier font so that I can line up characters in different lines. The dos window uses uniform character widths.
Thanks
FrankClick Start> Programs> Accessories> System Tools> "Character Map"

You can find and select various extended characters in there that can create borders. You can them copy them from there, to Notepad.

ALT + 201 is this symbol: ╔

You can't save notepad files with symbols like this...

This is very puzzling. I have 2 machines and decided to try this on the second machine also.

On the first machine in wordpad when I key in Alt-201 I get I get an E with an accent on top. But I can save it and doing a Type file.txt in the dos window shows the correct character (the ╔).

On the second machine in wordpad when I key in Alt-201 I get the ╔ character, but cannot save it and get error message shown in previous post.

Knowing that the fist machine output gives me the correct result in the dos window. I will leave it at that.

Thanks a lot
FrankIn Notepad,
Goto:
Save As:
File Types: Your choices are:
ANSI
Unicode
Unicode big endian
UTF-8

I THINK the answer to the discrepancy MAY be found there.


Another thought, Try changing the font in edit.com. (It's found in the properties, not in the program.)

First make a new shortcut to Edit.
Right-Click on the Desktop - New Shortcut - Target - edit.com
then,
Right-Click on the Shortcut - Properties - Font Tab - ... see if you can get the display you want.

You can also get to a font tab by:
Right-Click on the title bar in Edit - Properties - Font Tab - ....

Let us know how it works for you.
On the machine that works (sort of), the save as choice is Ansi, the display shows E (with an accent, I think this MIGHT be the unicode equiv) but saves correctly the character Alt-201 as ╔. On this machine I can LAUNCH edit.com and shows the correct characters I want and saves them correctly as well.
I think I will use edit.com for creating these sort of files.
Frank

5083.

Solve : Creation of GUID?

Answer»

How do I create a new GUID from .bat file? THANKS in advance.Do you mean Globally Unique Identifier?

THIS page isn't about a .bat file, but it MAY give you some ideas.Some versions of Exchange and Visual STUDIO INCLUDE a generator utility (GuidGen.exe), so you may already have it installed. Even the WINDOWS Script Component Wizard can generate a GUID or you can download a generator program from here.

Good luck.

5084.

Solve : Positioning the cursor in a batch file?

Answer»

I have read everything and tried every combination, I know you can do it because I've done it in the past! How do you execute (echo) the cursor position escape sequences? ANYONE??What is your OS? Back in the DOS days, you could load the ansi.sys driver and various escape clauses could be used for printer controls, cursor controls and colors in the shell.

This should still WORK on Win9x machines provided ansi.sys is loaded in the config.sys file. On NT machines, ansi.sys would need to be loaded in the config.nt file and would only be EFFECTIVE in the MS-DOS prompt (command.com) and not the cmd.exe environment.

Good LUCK.

5085.

Solve : String manipulation in a batch file?

Answer»

How do I manipulate a string from within a batch file?

I need to know if a file_name entered in %1 has a dash (-) on it to change the course of processing with an @ifi cant understand ur last STATMENT
put u can manibulat the srting see this examble

set a=hi there ?
echo %a:~0,1%
echo %a:~-1%
echo %a:~0,-2%

and for mor info see the set command

and if u want to REPLACE characters u can use

set a=hi there ?
set b=%a: =,%
echo %b%.bat_man, I don't THINK that is what fermat73 asked.

Quote

I need to know if a file_name entered in %1 has a dash (-) on it to change the course of processing

Code: [Select]@echo off
echo "%1" | find "-">nul && goto yes
goto no

:yes
echo filename contains one or more DASHES

goto NEXT

:no
echo filename does not contain any dashes

:next

Well done, SummerDays.
I want to thank you both cuz I learned a lot today.
What .bat_man said, tho it didn't really solve my problem, helped quite a lot, but you got to the point.

Quote from: fermat73 on June 08, 2008, 02:17:58 PM
Well done, SummerDays.

You are the first person who said they understand my screen name! It's a song by Amaral.
i didn't understand ur question correctly and thats bad for me
put i am happy that u had something useful from my responce
and what a good meaning Dias de verano
5086.

Solve : error in batch file1?

Answer»

If I put the following statement in the RUN of VISTA it works property. However, if I copy the data from the RUN window and put it into a batch file created in WordPad I get the errors shown and can't understand why.

The RUN COMMAND line is:
C:\Program Files\Yahoo & Google Historical QUOTES Downloader\ydownloaderpr.exe -a -x C:\finance\mutual fund investments\get prices\data.txt"" -d ""C:\finance\mutual fund investments\get prices -t 5/8/2008 -e 5/8/2008

When attempting to run as a batch file I get the following errors:

'C:\Program' is not recognized as an internal or external command,
'Google' is not recognized as an internal or external command, operable program or batch file.

What obvious thing am I Missing?I finally discovered the PROBLEM. I have SPACES in the path. I enclosed both paths in "" and it works just fine.

5087.

Solve : Using batch script to check if a service is running?

Answer»

Finally, I found a forum for DOS. I hope you guys can help me. I've never taken any shot at batch script, so I hope you can help me with this simple task.

Basically, as the subject suggests, what I'm trying to do is check if a service is running or not. And then it will show me the STATUS and give me the appropriate options. If it is running, stop it and vice versa.

I figured out the dos command, which is following

Code: [Select]sc query serviceName | find /I "state"
It outputs a line SAYING whether the service is running or not. Now, I'm trying to use this command in a batch script. How do I store the output in a variable, examine the variable and if the service is running/not, then show the appropriate option.

I started with the following, but it doesn't seem to work.
Code: [Select]@echo off
set test= sc query serviceName | find /I "state"
echo %test%
pause
Could you please advise. If there's a better way, please let me know. Your help is much APPRECIATED. Thanks

in DOS, most of the time , you would have to use a for loop. Set up the for loop to get the variable
see for /? for more info.Are we really talking about DOS here, or is it Win2k/XP/Vista command prompt? (I suspect the latter because of the mention of "services".) Come on folks, get it right.

If the latter you can use the && (success) and || (failure) test operators

In a statement with &&, the command on the left of the operator is carried out, and if it was successful, the command on the right is executed. (E.g. with FIND, success=the text specified was found.)

In a statement with || the opposite is the CASE, the command on the right is executed if the ONE on the left fails.

Some examples...

I send the FIND output to nul to avoid screen clutter.

Code: [Select]C:\>sc query winmgmt | find /I "running">nul && echo winmgmt is running
winmgmt is running

C:\>sc query nosuchname | find /I "running">nul || echo nosuchname is NOT running
nosuchname is NOT running

Code: [Select]set servicename=winmgmt
set message=NO
sc query %servicename% | find /I "running">nul && set message=YES

Also, since the key word RUNNING is always in upper case you could save 3 characters by ditching the /i switch & specifyiing the string in all caps.





Hey Dias,

Thanks for the corrections. You are right. I was talking about command prompt. Thanks for the examples as well. I'll go from here and see how far I can get. Thanks again.

5088.

Solve : Fixing Enter Goes To Random Thing.?

Answer»

Okay, i have this menu:
Code: [Select]cls
echo.
echo Current Available Regiments:
echo.
echo Rank Name
echo -------------------------------
echo 1 The Dogs
echo -------------------------------
echo 2 British
echo -------------------------------
echo 3 Revolution
echo -------------------------------
echo 4 SWAT
echo -------------------------------
echo 5 Americans
echo -------------------------------
echo. 6 Smiths Unit (Default)
echo -------------------------------
echo.
echo.
echo Type The Rank Of The Regiment You Wish To Join.
echo.
set /p choice= [Regiment Rank]:
if %choice%==1 goto TheDogs
if %choice%==2 goto British
if %choice%==3 goto Revolution
if %choice%==4 goto SWAT
if %choice%==5 goto Americans
if %choice%==6 goto noregiment

When i don't enter anything and just press enter it goes to a random option, how can i fix this please?
(sorry about all the questions i just need to fix a few bugs in my game)Code: [Select]:1
cls
echo.
echo Current Available Regiments:
echo.
echo Rank Name
echo -------------------------------
echo 1 The Dogs
echo -------------------------------
echo 2 British
echo -------------------------------
echo 3 Revolution
echo -------------------------------
echo 4 SWAT
echo -------------------------------
echo 5 Americans
echo -------------------------------
echo. 6 Smiths Unit (Default)
echo -------------------------------
echo.
echo.
echo Type The Rank Of The Regiment You Wish To Join.
echo.
set /p choice= [Regiment Rank]:
if %choice%==1 goto TheDogs
if %choice%==2 goto British
if %choice%==3 goto Revolution
if %choice%==4 goto SWAT
if %choice%==5 goto Americans
if %choice%==6 goto noregiment
cls
echo.
echo. You did not choose anyone
echo.
pause > nul
goto :1Starting to look nice...Post it here when you're done, Jacob After the last possible choice IF test, have a catch-all IF test which directs execution back to the menu possibly via an error message like this...

Code: [Select]:Menu
cls
echo.
echo Current Available Regiments:
echo.
echo Rank Name
echo -------------------------------
echo 1 The Dogs
echo -------------------------------
echo 2 British
echo -------------------------------
echo 3 Revolution
echo -------------------------------
echo 4 SWAT
echo -------------------------------
echo 5 Americans
echo -------------------------------
echo. 6 Smiths Unit (Default)
echo -------------------------------
echo.
echo.
echo Type The Rank Of The Regiment You Wish To Join.
echo.
set /p choice= [Regiment Rank]:
if %choice%==1 goto TheDogs
if %choice%==2 goto British
if %choice%==3 goto Revolution
if %choice%==4 goto SWAT
if %choice%==5 goto Americans
if %choice%==6 goto noregiment
echo.
echo Input not recognised
echo Press a KEY to try again
pause>nul
goto Menu

Wierd:
if i type anything that isn't 1, 2, 3, 4, 5 or 6 such as lol or hehe it works.
if i THEN type nothing and press enter it works.
BUT if i go straight there and enter nothing and press enter it goes random.

very weird...Quote from: Jacob on June 07, 2008, 09:17:10 AM

Strangely the pause doesn't work and it goes to somewhere random...


and i will post the game here when i am done.
i have about 1700 lines of code.

and i have only done around 1.5 missions.

Which version, mine or Carbon's? or both? That code works on my system.
Wierd:
if i type anything that isn't 1, 2, 3, 4, 5 or 6 such as lol or hehe it works.
(AFTER THE ABOVE) if i THEN type nothing and press enter it works.
BUT if i go straight there and enter nothing and press enter it goes random.

very weird...Did you just COPY your previous post? Quote from: Carbon Dudeoxide on June 07, 2008, 09:27:55 AM
Did you just copy your previous post?
he quoted me, so he might not of seen that i changed the old post.
so i posted again just to be sure.
btw,
www.sassurvival.co.nr
I have a few suggestions:
1. Add this code at the beginning of the original code you posted.
(This will allow you to return to the menu if an error is encountered.)
Code: [Select]@echo off
:Start
2. Add choice #7 Exit

3. Add this code before the set /p command in the original code you posted.
(This will remove (or delete) the environment variable choice, if it exists.)
Code: [Select]set choice=
4. You should test to see whether or not an entry was made, even if it was wrong.
If no entry was made, you should set the variable "choice" at this time
so that you can display the proper error to the operator.
Add this code at the end of the original code you posted.
The first line is true if you fail to enter anything at the set /p command
Code: [Select]if '%choice%'=='' set choice=No Selection!
echo.
echo MENU ERROR&echo.&echo.&echo.
echo You must make a VALID selection:&echo.
echo "%choice%" is not valid!&echo.&echo.&echo.
echo Valid selections are: 1 2 3 4 5 6 or 7.&echo.&echo.
echo Type The Rank Of The Regiment You Wish To Join.
echo Press Enter to continue.&echo.&echo.
echo Press any key to return to the menu.&pause >nul
cls&goto Start
5. Add this code at the end of the original code you posted.

Code: [Select]:End
exit
6. Add single quotation marks around the variables in the "if - goto" statements.
I do not know the technical reason for this, but it is shown this way in the examples in
the help on this site. They surely had a good reason for using the single quotes in the
example. I do know this. When I try to remove them from a working test file, it starts
to behave badly. I suggest that you use the quotes as shown.
Note the single quotes in the example from the help page below:
Code: [Select]if '%choice%'=='1' goto hello Microsoft DOS set command

Dias, (If you are not too mad at me from another recent post), could you explain the reason for the eratic behavior without the use of the single quotes.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Finally, here is your code modified as I suggested, & working good!
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Code: [Select]@echo off
:Start
cls&echo.
echo Current Available Regiments:
echo.
echo Rank Name
echo -------------------------------
echo 1 The Dogs
echo -------------------------------
echo 2 British
echo -------------------------------
echo 3 Revolution
echo -------------------------------
echo 4 SWAT
echo -------------------------------
echo 5 Americans
echo -------------------------------
echo. 6 Smiths Unit (Default)
echo -------------------------------
echo 7. Exit
echo -------------------------------&echo.
echo Type The Rank Of The Regiment You Wish To Join.
echo (Valid selections are: 1 2 3 4 5 6 or 7 - Press Enter to continue.)&echo.
set choice=
set /p choice= [Regiment Rank]:
cls

if '%choice%'=='1' goto TheDogs
if '%choice%'=='2' goto British
if '%choice%'=='3' goto Revolution
if '%choice%'=='4' goto SWAT
if '%choice%'=='5' goto Americans
if '%choice%'=='6' goto SmithsUnit
if '%choice%'=='7' goto End

:: The following line tests if no entry has been made.
if '%choice%'=='' set choice=No Selection!
echo.
echo MENU ERROR&echo.&echo.&echo.
echo You must make a valid selection:&echo.
echo "%choice%" is not valid!&echo.&echo.&echo.
echo Valid selections are: 1 2 3 4 5 6 or 7.&echo.&echo.
echo Type The Rank Of The Regiment You Wish To Join.
echo Press Enter to continue.&echo.&echo.
echo Press any key to return to the menu.&pause >nul
cls&goto Start

:TheDogs
echo.&echo TheDogs&echo.
pause>nul&goto end
:British
echo.&echo British&echo.
pause>nul&goto end
:Revolution
echo.&echo Revolution&echo.
pause>nul&goto end
:SWAT
echo.&echo SWAT&echo.
pause>nul&goto end
:Americans
echo.&echo Americans&echo.
pause>nul&goto end
:SmithsUnit
echo.&echo SmithsUnit&echo.
pause>nul&goto end
:End
exit
Quote from: llmeyer1000 on June 08, 2008, 01:49:29 AM
I have a few suggestions:
1. Add this code at the beginning of the original code you posted.
(This will allow you to return to the menu if an error is encountered.)
Code: [Select]@echo off
:Start

Good. Already suggested. See posts above

Quote
2. Add choice #7 Exit

Good.

Quote
3. Add this code before the set /p command in the original code you posted.
(This will remove (or delete) the environment variable choice, if it exists.)
Code: [Select]set choice=

Good.

Quote
4. You should test to see whether or not an entry was made, even if it was wrong.
If no entry was made, you should set the variable "choice" at this time
so that you can display the proper error to the operator.


Very good.

Quote
5. Add this code at the end of the original code you posted.

Code: [Select]:End
exit

Good.

Quote
6. Add single quotation marks around the variables in the "if - goto" statements.
I do not know the technical reason for this

It is so you can accurately define what you are testing for.

cmd.exe "expands" variables to their value at runtime.

Pressing Enter at the set /p prompt results in an empty string, (i.e. "nothing"), and the only way to test for it is to use delimiter characters.

if %choice% is empty, then...

if %choice%==1 goto label

expands to

if ==1 goto label (causes an error)

whereas, using quotes or other delimiters, it expands to

if ""=="1" goto label (does not cause an error)

You can use single quotes, double quotes (which is what I am used to), in fact any delimiting characters you like, except the usual suspects like <>^&. They must be the same both sides though.

Double quotes have a special meaning in connection with filenames, so sometimes people prefer to avoid them, and in fact many people prefer to use what I call "SPIDER brackets" but I think in the US they are called "braces" - these characters { }.

See here. If quotes are used, note that single on one side and double on the other side will not work as expected, (i.e. the test will give the "not the same" result), and mixing them before/after the variable doesn't work at all, and actually throws an error message

Code: [Select]C:\>set test=egg

C:\>if "%test%"=="egg" (echo yes) else (echo no)
yes

C:\>if '%test%'=='egg' (echo yes) else (echo no)
yes

C:\>if '%test%'=="egg" (echo yes) else (echo no)
no

C:\>if q%test%q==qeggq (echo yes) else (echo no)
yes

C:\>if a%test%b==aeggb (echo yes) else (echo no)
yes

C:\>if {%test%}=={egg} (echo yes) else (echo no)
yes

C:\>if "%test%'=="egg' (echo yes) else (echo no)
(echo was unexpected at this time.

Quote
Dias, (If you are not too mad at me from another recent post), could you explain the reason for the eratic behavior without the use of the single quotes.

I hope you are not too mad at me about the nanosecond thing!! I hope the above explains it.
i will add this at a later date, thanksQuote from: Dias de verano on June 08, 2008, 02:51:50 AM
Quote from: llmeyer1000 on June 08, 2008, 01:49:29 AM
Quote
2. Add choice #7 Exit

Good.
How about the option to exit when you type 'exit.

if %choice%==exit goto :endQuote from: Carbon Dudeoxide on June 08, 2008, 06:05:06 AM
if %choice%==exit goto :end

did you read all of my post?

if {%choice%}=={exit} goto :endUhh......It was too LONG

Sorry man.
5089.

Solve : Making New Users Via .bat?

Answer» HEY There

I'm just wondering how do I Make users with a batch file also how to change PASSWORDS =]

thank you =)
5090.

Solve : Dos Sort - ?Advanced¿?

Answer»

*JAW drops*

That is AWESOME, who WOULD have thought that I could do something like that with dos, you are wonderful for giving me that code. Thank you thank you thank you.

You mean it works for you now? That is correct. Thank you very much for your help.

5091.

Solve : Error Log?

Answer»

Hi Everybody,

I am new to the forum and to DOS Command world. I have to run a batch file that will create around 60 folders and then sub folders into them. The issue is that I want an activity or error log that will give me an output after running the batch file as how many folders were created and mark the errors in creating folders or missouts. This is an auditing output I require to track my output as sometimes there are errors and a couple of folders dont get created.

Kindly help me ...........try this code it will print the output of ur PAT file into an TXT file
from the CMD prompt

batfile.bat &GT;> log.txt

put if there was (echo off) command the log.txt will only contain the errors and the echo's ur bat file have
unless u provide u code so we can add SOMTHING to make ur bat file count the objects it CREATES

5092.

Solve : move file to email...?

Answer»

New here. Not too savvy with this area, but I was wondering if any ONE MIGHT know a SCRIPT to GET a file off of a floppy (raw text) and move it to an email FOLDER... eg

thisfile.nru

move it off the floppy to my inbox. Thank you very much if anyone can help.

Tim

5093.

Solve : Opening a link?

Answer»

Can you open a LINK through a batch file? i'm assuming it would be something like this:

Code: [SELECT]start C:\Documents and Settings\CE User\Start\Programs\Internet Explorer"Link Here"
ThanksQuote from: Clipper34 on May 01, 2008, 05:46:09 PM

Code: [Select]start C:\Documents and Settings\CE User\Start\Programs\Internet Explorer"Link Here"

You're nearly there...

Code: [Select]start "" "C:\Program Files\Internet Explorer\IEXPLORE.EXE" http://www.google.com
1. After the START you NEED a title string which can be blank

2. The path to IEXPLORE.EXE needs quote marks if it contains spaces

3. You have to actually include the name of IEXPLORE.EXE explicitly

4. Put a space before the url

Thank you very much for your HELP Dias
5094.

Solve : how to combine multiple files??

Answer»

i have multiple .flv files and i want to combine all these file to make a SINGLE .flv file
how is it possible?


regards
sanYou can convert the files to a .wmv/.avi file and then put them together in Windows Movie MAKER.
Not sure about .flv files though...Quote from: CARBON Dudeoxide on May 14, 2008, 04:30:49 AM

You can convert the files to a .wmv/.avi file and then put them together in Windows Movie Maker.
Not sure about .flv files though...

and how to convert to .wmv/.avi using DOS commonds??
i am using windows xp sp2this is not a simple matter of using "commonds". You need software. Google for an flv to avi converter and learn to use it.
I use this one:
http://www.nbxsoft.com/files/flvconverter.exe

You can only use it once or twice before it locks itself and you can't use it anymore.
5095.

Solve : Converting all the lines of a text file into a variable.?

Answer»

I have created a text FILE by interrogating an ORACLE database using sql.

This then gives me uptodate information. I need to pass all the lines from this file to a string for another programs to use.

I can read all the lines using
for /f %%i in (FILENAME) do set str=%%i but this only sets the variable (str) to the last line of the file as expected I suppose. How can I set the variable so that all the lines of the file appear in SERIES see below;
My file LOOKS like /[emailprotected]
/[emailprotected]
/[emailprotected]

and I want the variable to be equal to /[emailprotected]/[emailprotected]/aldi
The final @ symbol must be omitted also and help how to do this would also be appreciated.joinup.bat

Code: [Select]@echo off

REM this is crucial
setlocal enabledelayedexpansion

REM generate test file
echo /[emailprotected]>supermkts.txt
echo /[emailprotected]>>supermkts.txt
echo /[emailprotected]>>supermkts.txt
echo /[emailprotected]>>supermkts.txt
echo /[emailprotected]>>supermkts.txt
echo /[emailprotected]>>supermkts.txt
echo /[emailprotected]>>supermkts.txt

REM count lines in file
set /a lastline=0
for /f %%S in (supermkts.txt) do set /a lastline=!lastline!+1

REM main loop

REM set line counter to zero
set line=0

REM set output variable to blank
set variable=
REM read each line in input file
for /f "delims=" %%S in (supermkts.txt) do (

REM copy line into string
set string=%%S

REM add one to line counter
set /a line=!line!+1

REM if this is the last line remove the @
if !line! EQU %lastline% set string=!string:@=!

REM append the string to output variable
set variable=!variable!!string!

)


REM here is your output variable
echo %variable%
Code: [Select]D:\>joinup.bat
/[emailprotected]/[emailprotected]/[emailprotected]/[emailprotected]/[emailprotected]/[emailprotected]/monoprix
Alternatives,
1) vbscript

Code: [Select]Set objFSO=CreateObject("Scripting.FileSystemObject")
strMyFile = "c:\test\file.txt"
Set objFS = objFSO.OpenTextFile(strMyFile)
Do Until objFS.AtEndOfLine
s=Trim(objFS.ReadLine) & s
Loop
If Right(s,1) = "@" Then
WScript.Echo Mid(s,1,Len(s)-1)
End If
save as script.vbs and on command line
Code: [Select]C:\test>cscript /nologo script.vbs
/[emailprotected]/[emailprotected]/asda

2) if you can download gawk from here and install.
Code: [Select]{ s=$0 s }
END {
gsub(/ +|@$/,"",s)
print s
}
save as script.awk and on command line
Code: [Select]C:\test>gawk -f script.awk file.txt
/[emailprotected]/[emailprotected]/asda

5096.

Solve : Disable cursor?

Answer»

XP Home SP.2

In a batch script I would like to echo a message onscreen and have nothing else showing. PAUSE > Nul leaves a blinking cursor onscreen, is there any way of disabling (and re-enabling) the cursor from within a batch script?

ThanksProbably not. There is a driver (ansi.sys) loadable thru your machine config file that can control many cursor functions, but hiding is not one of them. In addition, ansi.sys works only in the context of the MS-DOS prompt (command.exe).

You might try Google.



Just curious but why are you playing Where's Waldo with the cursor?Quote from: Sidewinder

Just curious but why are you playing Where's Waldo with the cursor?

It's just an appearance thing, I have brilliant blue background with BRIGHT white lettering and this darned cursor blinking, a real distraction.

I've already looked at ANSI.SYS and a few others without success.

Thanks for responding. I was playing around with something similar a while back. I never got it TOTALLY worked out but maybe you can tweak it in. The following opens the JPG in "Windows Picture and Fax Viewer" while the batch file waits in the background.(Picture with no cursor) The batch file waits until you close the viewer with the "X", and then continues.
Code: [Select]START "" /wait /max "Test.jpg"
If you get it working in full screen, PLEASE let me know. Thanks! Thanks llmeyer1000 - this leaves the batch script running but what I want is to have the message in the script displayed without the cursor. Even running something minimized doesn't seem to work.

If the cursor is a window I could run it Hidden in CMDOW but I don't know what name it would be...

Thanks again.
5097.

Solve : Download file??

Answer»

Does anyone know how to download a file from the INTERNET to you pc with batch under winxp? E.G. If you have a tekstfile and you have the link, let the textfile appear on the desktop. As far as I know there is no standard function for that in the command line, but googling for it didn't help me either. Perhaps someone of you guys can help me?There is a well known command line program called wget.
Quote from: Dias de verano on MAY 02, 2008, 09:50:40 AM

There is a well known command line program called wget.


But that ain't for WINDOWS, is it. From the install notes from wget:
Quote
To build Wget, your system must support a Unix-like command-line
development environment, including the text-processing utilities (sh,
grep, awk, sed, etc.) and a functional C compiler. On some GNU/Linux
systems, this means that you will need to install packages such as
`gcc', `glibc-devel' (or `libc6-dev') and `make'. Most systems come
with these packages preinstalled, but it doesn't hurt to check. If
Blackberry, there is a tradition among some Linux users to compile software from source code. You have quoted from the compile instructions for wget. Wget is a C program that can be compiled for various platforms, such as Linux, Mac OS X, Solaris, OpenVMS (!!!) and 32 bit Windows. Unix-like development tools are necessary to compile it from source code, but why do that? Most people get their win32 software of all kinds ready compiled. Wget compiled for Win32 is extremely available.

e.g. here

http://users.ugent.be/~bpuype/wget/


Quote from: Dias de verano on May 02, 2008, 10:09:44 AM
Blackberry, there is a tradition among some Linux users to compile software from source code. You have quoted from the compile instructions for wget. Wget is a C program that can be compiled for various platforms, such as Linux, Mac OS X, Solaris, OpenVMS (!!!) and 32 bit Windows. Unix-like development tools are necessary to compile it from source code, but why do that? Most people get their win32 software of all kinds ready compiled. Wget compiled for Win32 is extremely available.

e.g. here

http://users.ugent.be/~bpuype/wget/





My bad. Thanks for the link Like it says on that page, get a version later than 1.8.2, I have been using 1.9.1 for some while now, and I have no complaints. I hope you find it useful. I do.



5098.

Solve : how to change color prmanently??

Answer»
I have tried using color command to change the text color of dos shell but when i close the session it resets to default white color.
would anyone suggest how to change text color parmanently?

thanks in advanceUsing the gui, click on the little dos box in the top left corner and change the default values.

If you WANT to AUTOMATE this, dump a copy of the registry before and after, a DIFFERENCE will tell you which keys need changing, you could export those explicitly and LOAD them up on multiple machines

Graham
ok...after opening windows registry where to navigate??
i dont know the setting for dos in windows registry

regards
sanRight click the the top left of the Command prompt window and select defaults.dude!! i have done that already
now i want to know how this setting make chages in window registry as gpl said.
but i dont know where to navigate after opening registry editor?

i am using windows xp sp2please someone help me out
i am using windows xp sp2

regards
sanok to change the color permantely, open command prompt, right click on the title bar, and select properties, then hit the colors tab on the properties window and there are your color settings.Maybe what is not clear from the above is that changing the colours ("colors" for N. Americans) by setting them in the Properties dialog of the command windows, does in fact change the registry. Provided you select "Save properties for future windows with this name" on exit.


so im right???Quote from: macdad- on May 13, 2008, 02:21:18 PM
so im right???

You're right that to change the colours permanently, you can access the command window properties.

I would add that before clicking OK, you have to select the radio button for "Save properties for future windows with same title", if you want the settings to persist and be saved in the registry.



The above is the easy way. Below is another way to achieve exactly the same thing.

The value DefaultColor controls the foreground and background colours used in command prompt windows. It has a default value of 0, for standard white text on a black background.

You can replace this value with a two-digit hexadecimal number, in which the first digit selects a background colour and the second a foreground colour. The hexadecimal codes are:

Hexadecimal value Colour

0 Black
1 Blue
2 Green
3 Aqua
4 Red
5 Purple
6 Yellow
7 White
8 Grey ("gray" to Americans)
9 Light Blue
A Light Green
B Light Aqua
C Light Red
D Light Purple
E Light Yellow
F Bright White

A value of F0, for example, would give black text on a white background, and 1E would yield yellow text on a blue background.

The change should take effect the next time you open a console window.

Registry Settings:

User Key: [HKEY_CURRENT_USER\Software\Microsoft\Command Processor]
Value Name: DefaultColor
Data Type: REG_DWORD (DWORD Value)
Value Data: (0 = default)

ok, i wuz kinda nervous that san would try to grab my neck. (not really an lol)Quote from: Dias de verano on May 13, 2008, 03:25:32 PM


The change should take effect the next time you open a console window.

Registry Settings:

User Key: [HKEY_CURRENT_USER\Software\Microsoft\Command Processor]
Value Name: DefaultColor
Data Type: REG_DWORD (DWORD Value)
Value Data: (0 = default)



i have changed color parmanently as u stated using windows gui but your claim, that this change will be shown in system registry, has not been verified rather its still having default valueslook san, if it works...it works there is no need for extra work, the registry key that changes may be hidden from user view, so just accept it as it is.
5099.

Solve : how to check a text file if it is empty or not by using batch command??

Answer»

hello
i would like to check a text file if it contains any text or rows. how to make it? i would like to make it by batch command.

thanksA file with no rows or text has no size. you can use dir and search for "0 bytes" using findstr in combination with for LOOP... or you can use vbscript
Code: [Select]Set objFS = CreateObject("Scripting.FileSystemObject")
strFile = "c:\test\test.txt"
If objFS.GetFile(strFile).Size = 0 Then
WScript.Echo "Zero Size "
END If
save the above as script.vbs and on command line :
Code: [Select]c:\test> cscript /nologo script.vbs
thanks very much!u can also use this in BAT file
for /f "delims=" %%i in ('dir /b "path\*.txt"' ) do if %%~zi EQU 0 echo %%i have zero size

5100.

Solve : removing reg keys?

Answer»

hey guys,

I've got several machines with SYMANTEC antivirus install which i need to remove. Sadly I don't have the install msi so I can't use the easy add/remove programs bit.

I've found a manual way of removing the software but it involves loads of keys to be removed from the REGISTRY.

is there a way to remove them from a batch file??


link to symantec uninstall instructions if your intrested.....

http://service1.symantec.com/support/ent-security.nsf/854fa02b4f5013678825731a007d06af/5db8e519e16d42f2882573290005aa1d?OpenDocument

any ideas would be greatly appreciated!!!!

EDIT;

I'm using 'reg delete' to remove the keys, but I'm stuck on...

Quote

Search all subkeys below HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall. Delete any associated subkeys that reference: "Symantec Endpoint Protection".

how can I achieve this?If you know the specific keys you want to delete:

Quote
To delete a specific registry key from the registry:
Win 2000, XP - You can create .reg file and specify in it MINUS sign before the key name to delete. Example:
del_key.reg
Code: [Select][-HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System]

After you get your *.reg file set up, you can start the reg file from a batch file, or simply run the reg file.

You do know that you only need to edit the keys in the branches:
[HKEY_CURRENT_USER] & [HKEY_LOCAL_MACHINE]
The rest are mirrors and will be updated as well.

The easiest way (that I know of) to create the reg file is to search for the keys, then export the keys to a file (or files.) and then edit the file (or files). You can combine the data from several different exports into one reg file, for easier handling.
RegSeeker: http://www.snapfiles.com/get/regseeker.htmlvbscript. Not tested. (always do backups of registry before meddling with it)
Code: [Select]
'Step 1: Stop Symantec Services.
strComputer = "."
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery("Select * from Win32_Service")
For Each objService in colListOfServices
If objService.Caption = "Symantec Endpoint Protection" Or _
objService.Caption = "Symantec Event Manager" Or _
objService.Caption = "Symantec Network Access Control" Or _
objService.Caption = "Symantec Settings Manager" Or _
objService.Caption = "Windows Installer" Or _
Then
WScript.Echo objService.Caption
objService.StopService()
objService.StartMode="Disabled"
End If
Next


'Step 2 : End task ccApp.exe

Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process Where Name = 'ccApp.exe'")
For Each objProcess in colProcessList
objProcess.Terminate()
Next


' Step 3 point 4-7,9,14-15: Delete registry keys
' Not including those optional ones
Const HKEY_LOCAL_MACHINE = &H80000002
Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & _
strComputer & "\root\default:StdRegProv")

On Error Resume Next
Set objFSO = CreateObject("Scripting.FileSystemObject")
strRegKeysFile = "regkeystest.txt"
Set objFile = objFSO.OpenTextFile(strRegKeysFile)
key = "HKEY_LOCAL_MACHINE\"
Do Until objFile.AtEndOfLine
strKeyPath = Replace(objFile.ReadLine,key,"")
WScript.Echo "Deleting " & strKeyPath
oReg.DeleteKey HKEY_LOCAL_MACHINE, strKeyPath
Loop

' Step 3 - point 8
strKeyPath = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
DeleteSubkeys HKEY_LOCAL_MACHINE, strKeyPath


Sub DeleteSubkeys(HKEY_LOCAL_MACHINE, strKeyPath)
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubkeys
If IsArray(arrSubkeys) Then
For Each strSubkey In arrSubkeys
If InStr("Symantec Endpoint Protection",strSubkey) > 0 Then
WScript.Echo HKEY_LOCAL_MACHINE, strKeyPath & "\" & strSubkey
'oReg.DeleteKey HKEY_LOCAL_MACHINE, strKeyPath 'Uncomment to use
End If
DeleteSubkeys HKEY_LOCAL_MACHINE, strKeyPath & "\" & strSubkey
Next
End If

End Sub

'Steps 3: point 10-13 not done as I don't have testing environment for that.

'Step 4: restart computer.
WScript.Echo "Wanna restart computer ? (y|n)" 'probably want to use InputBox instead
Set StdIn = WScript.StdIn
strChoice = StdIn.Read(1)
If strChoice = "Y" Or strChoice = "y" then
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate,(Shutdown)}!\\" & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
For Each objOperatingSystem in colOperatingSystems
objOperatingSystem.Reboot()
Next
End If

'Step 5: Do it manually

'Step 6: Do point 5 and 6 yourself.

strFolder = "c:\Documents and Settings\All Users\Application Data\Symantec\"
strFolder1 = "C:\Documents and Settings\All Users\Start Menu\Programs"
strFolder2 = "C:\Program Files\Symantec and delete the Symantec Endpoint Protection"
strF1 = strFolder & "SavSubEng"
strF2 = strFolder & "SPBBC"
strF3 = strFolder & "SyKnAppS"
strF4 = strFolder & "Symantec AntiVirus Corporate Edition"
strF5 = strFolder & "SRTSP"
DeleteFolder strF1
DeleteFolder strF2
DeleteFolder strF3
DeleteFolder strF4
DeleteFolder strF5

Sub DeleteFolder(strPath)
For Each objFile In objFSO.GetFolder(strPath).Files
objFile.Delete
Next
For Each objFolder In objFSO.GetFolder(strPath).SubFolders
If objFolder.Name <> "SrtETmp" Then
DeleteFolder(strPath)
End If
Next
objFSO.DeleteFolder(strPath)
End Sub



[recovering space - attachment deleted by admin]Cheers for all the replys guy's.

I managed to get script written by the pervious owners IT dept that removed it for me. Sadly, the PC's have celeron processer's so it takes about 2 hours!! but it gets the job done.


Cheers again for your helpIs the working script too LONG to post? I'd like to see it after all. It's in servarl parts and is very long, I'll slap it on rapid share if you like.

Sadly I don't have it here (at home) and it'll have to wait till tuesday when I'm back in the office.