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.

8251.

Solve : Redirecting only a few lines to a file?

Answer»

Hello,

I am trying to use the "cmd" prompt in Windows XP. I am trying to find out if I can redirect only the first few lines of the output APPEARING on my screen to a file?

e.g. ipconfig >> test.txt CAUSES several lines to be written to the file "test.txt".

I am looking for selecting, say the 1st 3 lines to be written to the "test.txt" file or of a way to skip the first few, and then write the next 3 lines

Any ideas, thoughts will be appreciated! Thanks.In this specific case, something like this will work:

Code: [Select]ipconfig | find ". " > test.txt

Unfortunately this is not generic code and applies only in this situation by coding the output DATA instead of the METHOD. Either Powershell or any of the Windows SCRIPTING languages would be more helpful here.

Thanks, Sidewinder for that tip! That works for me, for now!

8252.

Solve : Renaming and reading PDF files?

Answer»

Hi

i want to make a program that has the following requirements:

- there are some pdf-files in directory: C:\Test\temp
- the names of the pdf-files are 20071119-0001.pdf, 20071119-0002.pdf, 20071119-0003.pdf, etc
- the 3rd LINE of the first pdf-file is "contractnr: 000001", of the second pdf-file "contractnr: 000002", the 3rd "contractnr: 000003", etc
- the pdf-files have to be moved to the directory C:\Test\contract\000001\000001.pdf

This is the code I have, my problem is how to read the pdf-file

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim FSO
Dim srcFolder, dstFolder
Dim i
Dim contractnr
Dim pdfBase
Dim myFiles

Set FSO = CreateObject("Scripting.FileSystemObject")

srcFolder="c:\test\temp" 'Server source folder location
dstFolder="c:\test\contract" 'Destination Folder as desired

i=0 'array counter
For Each myFiles In FSO.GetFolder(srcFolder).Files
'MsgBox srcFolder & FSO.GetExtensionName(myFiles)
If FSO.GetExtensionName(myFiles) = "pdf" Then
pdfBase = FSO.GetBaseName(myFiles)
'open pdf file and determine contractnr in 3rd line of pdf-file

'I haven't got a clue whether this is possible?
contractnr = "00000" & i+1

'Copy the file to the new directory: dstFolder="c:\test\contract"
'MsgBox "i: " & i & "srcFolder:" & srcFolder & "\" & pdfBase & ".pdf" & " , dstFolder: " & dstFolder & "\" & contractnr & ".pdf"
src = srcFolder & "\" & pdfBase & ".pdf"
dest = dstFolder & "\" & contractnr & "\" & contractnr & ".pdf"
MsgBox src
MsgBox dest
FSO.CreateFolder dstFolder & "\" & contractnr
FSO.MoveFile src, dest

i=i+1

End If
Next
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''






Hope anybody can help!

Thanks!
Stronky
PDF like most text files only allow sequential access. You could program two reads and then a third to pick up the contractnr: 000001 data in the third line. You can also use the .skipline method (twice) to skip the first two lines and then use the .readline method to get the data in the third line.

Another WAY would be to use .readall method to dump the entire contents of the file into a data name. Using the instr function you could find the start of contractnr: in the data name. Knowing that contractnr: is 12 bytes (including the trailing space) and the contracter number is 6 bytes, you could use the mid function to pluck the contracter number out of the data field.

We don't have enough information on this PDF file. Is contractnr: only found in the third line? Is it in every file?

Quote

the names of the pdf-files are 20071119-0001.pdf, 20071119-0002.pdf, 20071119-0003.pdf, etc
- the 3rd line of the first pdf-file is "contractnr: 000001", of the second pdf-file "contractnr: 000002", the 3rd "contractnr: 000003", etc

There seems to be a pattern here where the file name of each PDF file ends with contracter number minus two leading zeroes. Perhaps this pattern information could be useful in WRITING your script.

Thanks for your response. I tried to do exactly as you told me, but it does not work yet.

First I tried a normal read, but the variable text gives only garbage:

Dim text, readfile, contents
set readfile = FSO.OpenTextFile(src, 1, False) '1=ForReading
text=readfile.Read (38)



Then I tried 2 SkipLine and a ReadLine, but again, garbage:

Dim readfile, contents
set readfile = FSO.OpenTextFile(src, 1, False) '1=ForReading
contents = readfile.SkipLine
contents = readfile.SkipLine
contents = readfile.ReadLine
MsgBox "contents:" & contents


Also the .readall method gives garbage:


Dim readfile, contents
set readfile = FSO.OpenTextFile(src, 1, False) '1=ForReading
contents = readfile.ReadAll
readfile.close

'determine contractnr in 3rd line of pdf-file
dim pos
pos=InStr(contents,"contractnummer: ",1)


The value of contents is: "%PDF-1.4
%äüöß
2 0 obj
<</Length 3 0 R/Filter/FlateDecode>>
stream
xœ}PËjÃ0¼ë+ö°º«ÇZ!pÒøÐ[@ÐCé-mo…ø’ß?´²›%Íìcf?šà¬N€€åå¯-Gz€ùÞ7ðÛjå›Ô6+Ï:@ï?î!áe""0ùû#""%ŠhRg""Ztè+åEè8¦ÎÆVܦ¢í„s!ŸùMí³:ükHN›fh€ÌjXG? ­»\…Æ}#,¾|“Aä?BÄAxñøw7ý¼{}Ú¯«ˆâ½_ºòžÊæ?IÒ?Ëð$”PÚÜÓ³9°æ‡³©?ý|{«?ü|²d—”#¹´&$ŸjÇ=™¯±pÌÁtÆ
endstream
endobj

3 0 obj
238
endobj

5 0 obj
<</Length 6 0 R/Filter/FlateDecode/Length1 26468>>
stream
xœí|y\TGºhU?Óûvš¥7ú@Cƒ4‚Š(‘FÀ%ÜБZieínD'Nâ³™ÌdŸ‰f™ì‰-Mrãd½Y?É2'‰&1Û̽ó2ÉÍ""ý¾ªs01sçÞ÷þx¿ßKªÎWU_U}õmõU5õ?
""ùÚºü½+Λµ!ô*B8¡mCD¼éíüc"

like I said, garbage

It doesn't make a difference whether the code says:
set readfile = FSO.OpenTextFile(src, 1, False,0)
set readfile = FSO.OpenTextFile(src, 1, False,-2)
set readfile = FSO.OpenTextFile(src, 1, False,-1)

(the last number, 0, -1 or -2 , indicates the format of the file.


The code does read textfiles, so I think it has to do with the pdf files, but I don't know how to fix it (=how to read the content of a pdf-file in vbscript).

To answer your question, yes, the contractnr: is only in the 3rd line. (And the pdf-files I'm currently working with, the ones with "contractnr: 000001", "contractnr: 000002", etc, are just test files. In reality there are different contracts scanned as pdf and there is no pattern in their contractnumbers, so that's why I want to read the pdf-files: to read the unique contractnumber, and to give the pdf-file the name of that contractnumber.

Hope you have any more suggestions on how to read the contractnumber of a pdf-file
(by the way, it is also possible to scan the files as jpg or TIF-files instead of pdf-files, but I think it is impossible to read a contractnumber from a jpg or tif-file).


BEST,
Leonard

I should have removed my post as soon as I realized that PDF files are not your normal text files (duh! ). In fact they are proprietary Adobe files.

You will need to find (use Google) an ActiveX component (either a DLL or OCX module) which can handle PDF files, specifically reading them. I found many for creating PDF but they are quite pricey ($$$).

Good luck.
another way is to convert pdf files to text for reading
you can download tools from 3rd party such as xpdf and others. after converting,you can read them using your script. If you have experience is other scripting languages such as Perl/Python,there may be modules for reading PDF files, you can try them also.








8253.

Solve : Cmd, batch file, cant use Ftp, why??

Answer»

i'm making a BATCH file, and i use @FTP in it, but after that no CODE will work anymore, why?What operating system are you using? WinXP or.... ?

Can you post the text of your batch file here? if you mean it wont work after that in a batch file.. its because U need to CREATE a second script

echo myusername&GT;>script.txt
echo mypassword>>script.txt
echo operation1>>script.txt
echo operation2>>script.txt
echo quit>>script.txt
ftp -s:script.txt ftp.yourftp.com

8254.

Solve : i cannot open command prompt at all...?

Answer»

i`m having problem to open command prompt. is there is new virus or anything that can disabled this program( command prompt ) too?are they those WHOSE make this virus really genius, why they so genius?please HELP me....theirs a way to DISABLE command prompt maybe this is what happend.. to find out

go to run and open regedit and find this key HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System

look for a value called DisableCMD if the value is set to 1 or 2 this is the problem,
set it to 0 that is default , 1 is disabled , 2 is disabled except for BATCH.

8255.

Solve : NET USE COMMAND?

Answer»

need help abt NET USE COMMAND..........pls....C:\>net use /?
The syntax of this command is:


NET USE
[devicename | *] [\\computername\sharename[\VOLUME] [password | *]]
[/USER:[domainname\]username]
[/USER:[dotted domain name\]username]
[/USER:[[emailprotected] domain name]
[/SMARTCARD]
[/SAVECRED]
[[/DELETE] | [/PERSISTENT:{YES | NO}]]

NET USE {devicename | *} [password | *] /HOME

NET USE [/PERSISTENT:{YES | NO}]hi..thanks
can u give me an e.g
how net use command work pls..

actually i wnt to upload data from another location bt in sme network


get the ip addressA simple example would be

c:\>NET USE X: \\$REMOTE_SERVER_NAME\$SHARE

Where X is a random unused drive letter between A & Z, REMOTE_SERVER_NAME is the name of the remote computer you want to mount from and SHARE is the name of the file directory or DEVICE you want to mount. Now if you select X; from a command prompt you will be taken directly to the folder \\$REMOTE_SERVER_NAME\$SHARE

incorporate that into a script that will easily allow you to transfer files from your machine to a remote machine and back again.

D.

8256.

Solve : Escape codes in batch files?

Answer»

Hello,

I'm calling wget in a batch file to download from an FTP site which requires a password with characters that need to be encoded for the command to work. If I type the command directly into DOS, it works fine, but if I put it in a batch file and run it, what DOS echos is the password with the escape codes PARTIALLY eliminated.

Here's the command:
wget -N ftp://cr-3476:j%40o9v!6%[emailprotected]/*.*

So I'm using %40 for @ and %26 for &

The intended password being"[emailprotected]!6&"

When echoed in DOS, the password comes out as "j0o9v!66"

So it eliminates the %4 from the %40 and the %2 from the %26 leaving just 0 and 6 in their places.

How can I endode this so it's SENT to the FTP as the intended "[emailprotected]!6&"?

why not just USE internal ftp command instead of wget..

try wgets website for help , or wait for someone else You can also try using the carat ( ^ ) as an escape character to keep the next character from being interpreted by DOSThanks for your suggestions!

I do need to use wget so that I can pull all newer files from the site, but the documentation for wget doesn't SEEM to say anything about using batch files or even escape codes.

Tried the ^. Just one before the escape character code didn't seem to have any effect. DOS eliminate the first two characters in the code as it normally does. Having 1 before each of the three escape characters like %40 had strange results. It caused DOS to eliminate several other characters in the password.Try doubling-up the % symbols

Code: [Select]wget -N ftp://cr-3476:j%%40o9v!6%%[emailprotected]/*.*That did it!

Thank you!

8257.

Solve : need help with this code...?

Answer»

I'm making a message encrypter and i need it to allow me to enter the message i want encrypted and have it spit out the encrypted form of the message. Is this possible? and if so what command can i use?

I am using windows XP home with service pack 2. Quote

I'm making a message encrypter

Do you mean you are writing a program, if so which language are you using? If not, which encryption program will you be using?

I understand that the XP EFS is available only in the Pro version.

Lots of free encryption programs and info on the WWW - Google for 'message encryption' (without the quotes').

As for the command to use - the supported commands at the XP Command Prompt are here.

its just a simple batch file that i am creating... no need for internet downloads its just for me and a friend this is what i have so far... and btw i went to the link to it didn't help...

Code: [SELECT]@ECHO OFF

REM This program is used to convert the "thermalvison" encryption.
:PASSWORD
SET /P CHOICE= Please enter password...

IF '%CHOICE%'=='AB10069' CLS
GOTO CHOICE1
IF '%CHOICE%'=='666' CLS
GOTO FAKE
ECHO "%CHOICE%" IS AN INVALID PASSWORD.
GOTO PASSWORD


:CHOICE1

SET /P CHOICE= To ENCRYPT type "e". To decrypt type "d".

IF '%CHOICE%'=='e' GOTO ENCRYPT
IF '%CHOICE%'=='d' GOTO DECRYPT
IF '%CHOICE%'=='secret' GOTO SECRET
ECHO "%CHOICE%" is not a choice.


:ENCRYPT
CLS
SET /P CHOICE= Please enter the message you wish to encrypt.

IF '%CHOICE%'=='A' ECHO T
IF '%CHOICE%'=='B' ECHO H
IF '%CHOICE%'=='C' ECHO E
PAUSE
exit
please help this forum is still open.
8258.

Solve : help help help {no fixed disks present}?

Answer»

due to virus problems i used fdisk to format C and now when i use a start up disk i get [drive c does not contain a valid fat or fat 32 partition] and says to use fdisk to create a partition but when i try to enter fdisk i get i get [no FIXED disks present] HELP ! Here is Microsoft on the subject.

Suggest you start off by ENSURING that cables are correctly plugged up. Go to your hdd MANUFACTURER's SITE and download the hdd diagnostics.

Good luck

8259.

Solve : Deleting multiple unknown subdirectories ??

Answer»

Hi,

I'm looking for something to delete multiple subdirectories (along with files in them) of which the names i will for the sake of this pretend to not know.

E.G. i WANT to delete directories "A, B & C" in the directory "Alpha", so not the whole directory "Alpha"

Thanks for any replies in advance.cd\alpha
rmdir /q/s a & rmdir /q/s b & rmdir /q/s cAnd i quote:
"I'm looking for something to delete multiple subdirectories (along with files in them) of which the names i will for the sake of this pretend to not know."

So, that means.. that i do not know those directories are called A, B & CSo how do you know that you want to delete them ??

Is it all subdirectories under Alpha ?I know because it are multiple Cache directories made by a game with never the same name.

and as for that i can only say: Yes.Thats easy then, USE a for loop to identify all directories and delete them

:: ensure we are in the correct dir
Cd \alpha

For /D %a in (*.*) Do RmDir "%a"


NOTE : if you run it from a batch file, the loop command needs to look like this (note the doubled % symbols):
For /D %%a in (*.*) Do RmDir "%%a"

GrahamNice, thank you.

Though 1 small problem.
how do i implement /Q in this in a way it actually works ?
because im sure you know it will otherwise say: Directory not emptyTry this

For /D %a in (*.*) Do RmDir /S/Q "%a"
GrahamQuote from: NiTeCr4Lr on November 20, 2007, 05:57:32 AM

And i quote:
"I'm looking for something to delete multiple subdirectories (along with files in them) of which the names i will for the sake of this pretend to not know."

So, that means.. that i do not know those directories are called A, B & C

my badNp Diablo461

Quote from: GPL on November 20, 2007, 09:45:11 AM
Try this

For /D %a in (*.*) Do RmDir /S/Q "%a"
Graham

Thanks again gpl : )
8260.

Solve : TRACERT?

Answer»

Ok, I've known about tracert for a while, but I have no IDEA what it actually does (or at least, no informed idea: I can guess some use). Anyways, can someone explain to me exactly what it does and how to use it?


Also, are there any other similar commands?trace route as it implies

it traces the network route from the host to a destination. (the host being the computer/device your are running the COMMAND from)

ie trace route to a server SOMEWHERE (someserver.com) will show your the route that it takes.

the internet, kinda like a LARGE railway system. Are made train stations(routers) some stations only go one way where as others span to different locations.

Your home router goes from your lan to your isp. But your isp spans to many locations. So in this case your train station (router) is at the end of line, and your isp is an Interchange that carries traffic to many destination, yours being one.

lets SAY your station is A and to get to station B you need to go through station E and F
so if you do a trace route on station B form station A
you will get the route it takes to get there ie
A
E
F
B

Another command similar in windows is Code: [Select]pathping

8261.

Solve : How to caputre txt from a .exe based on buffer size?

Answer»

Good-day,

We are trying to capture data flow (text) from a .exe program. Is the information is ALLOT -> RUNS all the TIME, we are trying to see if we can capture data until the buffer size is full. Then SAVE this as a .zip or something and start again.

Is this possible?

THANKS for any help

8262.

Solve : How to find Process/service??

Answer»

Hello

I remember there being a command in XP to list/FIND the services that are associated to a process or a process associated with a service.
I'm 100% sure that there is such a thing and remember using it once.
It may not be a BUILD in command...

I've been searching for ages now and haven't been ABLE to find it.

I remember using it on svhost.exe once as multiple instances of it run different things.


Any help would be awsome
Thanks services.msc and hit Enter...from a command prompt.not the gui...NEVERMIND i've found it

For anyone thats INTERESTED its:
Code: [Select]tasklist /svc
useful for clearing up unwanted stuff

8263.

Solve : Batch File functionality?

Answer»

What I need in a sense is to have a batch file open notepad and save it in a directory? Is it possible to have this task repeated daily?open notepad and save it in a directory? how do you mean..

start notepad.exe will open notepad.. what is it you want to save though?I want the batch file to just save a txt doc into a directory... nothing on the txt at all... just like if you were to open notepad and just save an untitled to MyDocs... It's a really out there QUESTION with no real purpose behind it. I just want to know if it can be done and how. Thank you for your immediate response.no problem and yea if you TYPE 00>mytext.txt it will create a txt file called mytext
the 00 part can be anything, and is only their to complete the syntax.. the result will be it saying "00" is not recognized as an internal or external command, operable program or batch file but in the directory it was typed you will find a file called mytext.txt , if you wanted to add information to this document.. say from typing DIR as an example , use two > INSTEAD of one , or it will just re-create the text file.. so dir >>myfile.txtThanks a lot!! You have been a real help!echo. > myfile.txt will create a file with a CR/LF in it and nothing else, so basically an empty file is created. if you wanted it in a subdirectory you could do something like

echo. > c:\temp\tmp\myfile.txt

a single > will create a new file overwriting anything in the old file if it previously existed.
a DOUBLE >> will append the new text to the end of the file if it exists.

D.

8264.

Solve : Litestep?

Answer»

so heres the problem
litestep is a shell like explorer just that it looks better with the cool themes.

is there a WAY to make a batch file or anything that will start before the boot screen which will ALLOW me to choose which shell to use

C:\LiteStep\utilities\SetShell.exe "explorer.exe"

C:\LiteStep\utilities\SetShell.exe "C:\LiteStep\litestep.exe"

those two are the COMMANDS to switch from shell to shell

thx in adv.helloo....
anyone

8265.

Solve : C:\> Documents and Settings?

Answer»

When I FIRST OPEN DOS, I'm prompted with [C:\> Documents and Settings\Ehucker>] and it won't LET me go to [C:\>] by itself, can someone hel me? I want to get to [C:\>].all you gota do is TYPE cd\

8266.

Solve : Locked files?

Answer»

Is there a way to see what files are locked and by whom?I not sure if Windows or DOS keeps TRACK of locked files. A very inelegant solution would be to get a LIST of the files and then attempt to open each for reading. If successful, you'd KNOW the file was unlocked and if unsuccessful, you'd know the file was locked.

VBScript would be one solution, but if the list of files was large, the script would run at glacial speed and the OVERHEAD on the I/O subsystem would be horrendous.

8267.

Solve : IF EXIST & COPY to archive before XCOPY /s/d/y stomps on backup target location?

Answer»

Help NEEDED for archival of files in batch

Trying to figure out how to use the IF EXIST Command with XCOPY instruction to avoid overwriting existing ARCHIVE with latest file.

Using:

XCOPY c:\data\*.* Z:\backup /s/d/y

It stomps ontop of older files so I always have the latest altered files backed up which works as I wanted it to until now.

What I would LIKE to do now is to check before copying the files over to see if they exist, and if they do pass them into a folder NAMED BEFORE at Z:\backup\BEFORE ....before copying the latest date/time stamped file of that same name to Z:\backup

Been trying to get the syntax correct but no luck with my batch. I am guessing that I would have to add a condition to be tested before allowing the XCOPY to operate, to test if the file exists of a similar name between Z:\Backup and C:\Data, and if so copy the files that are matching in name to Z:\backup\BEFORE ... before the XCOPY actually runs the routine to drop the latest data to Z:\Backup

Or Maybe there is a better method of combining the XCOPY string with IF EXIST to make this more clean

Any suggestions???

Thanks,

DaveHad a hard time deciphering your request, but if I understood it correctly, maybe this code will be helpful:

Code: [SELECT]for /f "tokens=1* delims=" %%i in ('dir /b c:\data\*.*') do (
if exist "z:\backup\%%i" copy "z:\backup\%%i" z:\backup\before
)
xcopy c:\data\*.* z:\backup /s/d/y

Good luck.

Thanks once again Sidewinder!!!

That did the trick!

Dave

8268.

Solve : cd.. then c..how to open MSDOS using cd prompt?

Answer» HI! How to open MSDOS using CD prompt.I typed cd.. and then c.. but it is invalid directory.

Thank you!PLEASE rephrase your question. What is it you WANT to ACCOMPLISH?
8269.

Solve : accessing windows root directory from dos?

Answer»

I need to replace a corrupt .dll file in the windows root dir of XP I get an access DENIED message when attempting to CD to that directory. Is there a way around this?Shouldn't be any dll's in the root directory...
Access denied means you are not logged on as the Admin.I'm not logged in at all I'm in the HDD from a boot FLOPPY, trying to FIX a windows start-up error (Windows could not start because the following file is missing or corrupt: \system32\hal.dll. Please re-install a COPY of the above file.) I don't have access to an XP CD but I do have another computer right next to the one with the problem running XP. so I copied the DLL file from the working system and would like to replace the one thats corrupt with it. Thanks for what EVER help you can give!!DLoad the recovery fileset from MS...7 files i believe to make floppies.
From there you can run the Recovery Console to fix the error.
At the DLoad site they show a complete listing of the RC file commands.Quote from: Kick1369 on November 22, 2007, 11:53:53 AM

I need to replace a corrupt .dll file in the windows root dir of XP I get an access denied message when attempting to CD to that directory. Is there a way around this?
8270.

Solve : how to install net send service?

Answer»

I want to USE net start COMMAND but I don't know how to install . Please I assume you're on Win XP...
If so you don't need to install anything.
Go to your start menu and SELECT Run
type services.msc and HIT enter
Find the entry called Messenger
Double click it
Under startup type select Automatic (to have the service startup with Windows) or MANUAL (if you want to start it manually).
Now press the start button and the service should be running.
Thanks a lot
I got it ->

8271.

Solve : DOS Kill All Command??

Answer»

If I do a NETSTAT command and see a connection that is established and I want to KILL it, what command do I USE. Also is there any good DOS tutorial anywhere on the web?

Thanks,
Norenester Netstat does not arbitrarily disconnect established connections. If you want them removed, you have to completely disconnect from the internet or other SERVER and wait for them to time out.

Established connection - a CURRENTLY active connection
Listening - connection not currently actively - listening for activety on the port
Time_wait - not active- not listening- will time out and drop after n time unless new activity is detected on the port.

You need not worry with these unless connection to an undesirable server or router is detected, which is unlikely.

If you are using a local proxy (which I am) what you see is not necesarily what you get.

8272.

Solve : Can any one help me make a restarter bat file with w timer for 5 minutes?

Answer»

I want to make a bat file to open a program, and then in 5minutes it CLOSES and then it RESTART right FATER it closes, but 5 minutes later it crashs again


echo off

Start: /myexe.exe

timer: 2600

taskKill: /myexe.exe

loop:


I REALLY dont know how to write it. but that kinda waht i want it to do.Besides not understanding why anyone would want to do this, I couldn't figure out the timer: 2600.

Code: [Select]@echo off
:loop
start "" \myexe.exe
ping 127.0.0.1 -n 300 > nul

for /f "tokens=1 skip=3" %%f in ('tasklist') do (
if /i %%f equ myexe.exe taskkill /im %%f /f
)
goto loop

If you do check BACK for this solution, let us know what possible use this has. Thanks. well i like to play fear the game and i can play with only 10 players online at once but we figered out if we turn the logonserver off, while the 10 are in we can have 10 more join,.

so i thought about just making a bat file to would kill the logonserver ever 5 minutes or so and restart so unlimited players could join. and i didn that to turn it off my slef.

Very clever.

8273.

Solve : where can I get sources of command language?

Answer»

I don't which use COMMAND LANGUAGE. for example, to OPEN add and remove program box, i don't know how to open in cmd. Can someone GIVE sources that explain FACTIONS of commands in system32.
ThanksStart Here...

8274.

Solve : How to get the file size?

Answer»

Hi all:

Please help me to get the code which helps us to get the file size for all the files present under the specified directory. For the files whose size is 0 bytes should be written (file name) to another file.

Thanks in advance.

Suvir SudFeel free to make any changes NECESSARY. The snippet SHOWS one way to solve your request.

Code: [Select]@echo off
for /f "tokens=* delims=" %%d in ('dir /s /b C:\*.*') do (
if %%~zd==0 echo %%d >> ZeroByteFile.txt
)



Edit: In this case REDIRECTION requires double symbols.

8275.

Solve : set num1 = %num1% + 1?

Answer»

yeah this is SOMETHING I've been thinking about, I might not find a GOOD use for it but I like to try this KINDA stuff out in case I get any ideas...

so I'm making text documents and naming them sequentially...
this program can be exited and when restarted would pick up basically where it left off because it checks if the files are there. even if some are missing here and there it would STILL remake them...

heres the code im trying to use:
Code: [Select]set NUM1=1
:start
if exist %num1%.txt set num1 = %num1% + 1
echo hello>%num1%.txt
goto startIf you're using XP - at the COMMAND Prompt enter SET/? and have a look at the SET/A switch.

Arithmetic gets tricky when using environment variables:

Code: [Select]set num1=1
:start
if exist %num1%.txt call set /a num1=%%num1%%+1
echo hello>%num1%.txt
goto start



thanx, works great

8276.

Solve : DIR verbose in WinXP as in Win98??

Answer»

Back in good old Windows 98 SE (MS-DOS 7.1) I used to backup file lists with the command:
dir/v/oe/s > filelist19991231.txt
that generated a NICE LIST with the columns:
DOS filename, Size, Disk space, Last modified, Last accessed, Attribute, Long filename
and then a summary at the end.

Now I’m missing this feature from Windows XP. Though command dir has the /n SWITCH for “new long list format with filenames on the right” that is less detailed.
Does anyone know a command line solution? Or is there a simple downloadable exe for this purpose?A to Z

The whole ball o' wax...Quote from: mn1995 on November 14, 2007, 12:50:25 PM

... Or is there a simple downloadable exe for this purpose?

Maybe.
At least it is free, so you can check it out to see if it does everything you need.
There is a for-pay version, but I've never even looked into whatever advantages it claims.

See:
http://www.no-nonsense-software.com/freeware/
Look for PrintFolder

It is great. I use it on Win98SE.
I've been told by a reliable source that it works fine on WinXP systems too.

Since it is free and simple to use, your best BET is to simply grab a copy, install it, and play around with it to see if you like it.
For me, it is one of the standard things I want to have handy on any computer I mess with for very long.

Let us know if it fulfills your need.

Of course when I had found out this change in Windows XP I searched the available switches for command dir both in its help and on various sites. Well, Microsoft's Command-line reference A-Z has nothing new to dir/?.

I have found a few useful utils at Slovak Antivirus Center most of them single exe files not requiring installation but none of those seemed to be the right one.

Quote from: WillyW on November 14, 2007, 04:37:51 PM
Look for PrintFolder
Let us know if it fulfills your need.
With the advanced options I could create a list containing all the required columns. Because of the different file sizes in space aligned plain text mode the column width is not the same for each subdirectory so the format output has to be set to delimited list to make it ready to be imported in Excel.
Yes, it fulfills my needs. Quote from: mn1995 on November 24, 2007, 01:49:24 PM

Quote from: WillyW on November 14, 2007, 04:37:51 PM
Look for PrintFolder
Let us know if it fulfills your need.
With the advanced options I could create a list containing all the required columns. Because of the different file sizes in space aligned plain text mode the column width is not the same for each subdirectory so the format output has to be set to delimited list to make it ready to be imported in Excel.
Yes, it fulfills my needs.

Excellent!
Thanks for POSTING back the good news.

8277.

Solve : Error in your file CONFIG.SYS in Line 1...A beginners question?

Answer»

What does it mean? is it the reason why my computer is not STARTING? I got a problem about my computer and I see that written when I start my pc...can someone tell me why my PC isn't starting? before my PC WENT down the graphics of my PC was odd...I never seen it like that before...it was somehow a little bit reddish.Can't tell YET...
Post a COMPLETE COPY of your config.sys...What Windows version?
Starting with Windows 98, config.sys, and autoexec.bat files are not even required.

8278.

Solve : How to use a batch file to enter a username and password on webpage?

Answer»

Hello!! OK, I'm a newbie and haven't delt with dos in years. So FAR I've got a batch file started that will open IE and goto the username box. But what I haven't FIGURED out how to do is:

(1) input the username
(2) goto "password"
(3) input password
(4) Press the "Enter" Button

This is what I have so far:

start /max "C:\Program Files\Internet Explorer\iexplore.exe" http://www.hotmail.com
goto "User name"


So you're trying to make a batch file that will log you into a website by typing the keys for you?
As far as I know, that's IMPOSSIBLE with a batch file.there is a solution to this...
mozilla FIREFOX
-the most SECURE browser
-user friendly
-cool ad-ons
-personalised themes
Well, with Firefox you can have the login information saved and all you have to do is press 'log in', even if the page doesn't have a 'remember me' option.

8279.

Solve : PLEASE HELP trying make .bat to delete temporary internet files at every startup?

Answer»

i have made a batch file to run at start up... this batch file cleans internet tracks, by deleting history and want it to delete temporary internet files as well. My delima is that the temporary internet file folder is a read only file shown in the properties, in the explorer. when checking the attributes from a comand prompt, it is shown as a hidden,system file. I have tried to change attributes on the folder, as well as the files from a command prompt, using the (attrib +a -r -s -h c:\tempor~1 /s) command. The hard drive rattles no error messages or other messages for that matter. when i went to look in the windows explorer the read only is still checked. Can anyone help me edit the attributes of this folder.. I know there is programs to help do this, but i'm not interested in another program... I only want to know if it is possible to change the attributes on this folder and keep them changed when REBOOTING... Maybe i should be in programming,,, but i know nothing about programing, so if there is programming involved , i'll have to be spoon fed the instructions,,, if u know what i mean....THANKS...WEW delete the contents of the folder instead , c:\tempor~1\*.*
You can do it through Internet Explorer SETTING itself:
http://samanathon.com/delete-internet-explorer-7s-temporary-internet-files-automatically-when-it-closes/thanks for the replys,,, I have tried to delete the files as u suggested, also tried to remove the directory... both of which GIVES the same error message file not found,,, which i figure it's because of the hidden-system attributes... Sorry i didn't mention that i am running IE 6.0,,, because 7 wouldn't let music match jukebox or windows media player play after installation... Also as i mentioned I would like to know how to change the attributes to folders like these.. I think it will come in handy for other files and folders down the road...so as i wrote in my original post is it possible to change the attributes for this folder and files....I thought maybe editing the registry ,, but have had little experience with that.. I couldn't FIND the folder there. Thanks again ... WEWIf you apply setting from my link, temp files will be deleted when you EXIT Internet Explorer.Sorry i missed the link, I read it and thought it meant for IE 7.0. I did have the setting to dump temp i-net files on exit. But Still would like to know if it is possible to edit the attributes on files such as these, as i said it would come in handy for other files as well... Thanks at least i don't have to worry about manually deleting them. WEWQuote

I have tried to change attributes on the folder, as well as the files from a command prompt, using the (attrib +a -r -s -h c:\tempor~1 /s) command

attrib /?
Displays or changes file attributes.

ATTRIB [+R | -R] [+A | -A ] [+S | -S] [+H | -H] [drive:][path][filename]
[/S [/D]]

+ Sets an attribute.
- Clears an attribute.
R Read-only file attribute.
A Archive file attribute.
S System file attribute.
H Hidden file attribute.
[drive:][path][filename]
Specifies a file or files for attrib to process.
/S Processes matching files in the current folder
and all subfolders.
/D Processes folders as well.

Try using the /D to set attributes on a folder.

Note: when deleting files, it may not be wise to delete the folder the files were in.

Ok I must be missing something... I have reset the attributes. i can recheck from a command prompt. The attrib are reset to archive, when i close the cmd prompt. then i go into win-explorer it still says read only on the properties. when i restart the pc the attrib is set back to system at the command prompt... some one please help...and thought i might also add, after setting the ie 6.0 to dump files when browser is closed, i still SEE files in it that are 4 days old. This is why I want to have the power to delete these files with a batch file...I guess i'm back to manually deleting them to be sure....I also tried what sidewinder suggested....no help after reboot they are reset back to the system attrib.
8280.

Solve : Web Address Redirect?

Answer»

I am not a computer expert and I thought someone here could help me. My old evil roommate got into my DOS screen and redirected several websites I frequently visited to Google. When I returned home my DOS screen was open with a bunch of STUFF I did not understand but I did SEE the website addresses that were affected. For example when I put "www.myspace.com" in the address bar the Google website is on the screen. The address in the address bar does not change.

I am never able to access myspace unless I enter "home.myspace.com". However for the various others she changed, I am not able to do the same thing and have no access to these sites from my computer.

Please someone tell me how to fix this. I would really appreciate it.

This is a long shot, but check your HOSTS file. Normally the HOSTS file is used to redirect dodgy web site names back to the LOCAL computer; in effect not allowing the user to view the site. Perhaps your "evil roommate" redirected www.myspace.com to Google's IP address (72.14.205.147).

On an XP machine the HOSTS file has no extension and can be found in the C:\WINDOWS\system32\drivers\etc directory.

Like I SAID, it's a longshot, but hey, you never know.

8281.

Solve : Finding DOS commands entering area foe xp windows?

Answer»

How do you reach the DOS commands section/page on xp windows.?Welcome to the CH forums.

Am not quite sure what you WANT to get to but if you are LOOKING for the XP Command Prompt window then CLICK on

Start
Run
Type CMD in the dialog BOX and hit OK

The available commands are listed here and here.

Post back for more info if required..

8282.

Solve : Backup with a batch file: How to mirror destination with source ??

Answer»

I'm running Windows XP and I've just wrote a batch file for backing up my stuff on an external hard-drive. I use the XCOPY command with the following switches: /D/E/I/H/K/Y.

It works fine except that I don't end up with a mirror image of the original source structure, because everything that I deleted since the last backup is obviously not deleted by the xcopy command ...

The easy solution would be to delete everything first, and then use xcopy ... but then, I loose the benefit of the nice /D switch because every file would be recopied each time and that takes quite a while ...

Is there a DOS command or some clever code that I could run after xcopy that would quickly compare both structures (source and backup) and remove all files and folders that are in excess in the backup structure, so that source and backup are identical ?

A batch file beginner :oP

I don't think there is any way to do it with a batch file. You get into some real complicated issues here. Sophisticated backup systems OFTEN handle this issue by CREATING a catalogue of all the files, with date and time stamps, that are on the source disk at backup time. Then if there is a restore, the system REFERS to that catalogue and restores only what is listed in it, rather than everything it finds on the target disk.
Mmmmmhh ... and I guess that any elaborate code I would write in order to compare source and DESTINATION would run just as slow as deleting and then copying everything ...

Ok, so I'll first delete everything with: rmdir /S/Q ... and also remove /D of xcopy since it would be obsolete ...

This "compare and clean excess" behavior would be a nice switch to add to xcopy ...

Thanks for answering me !

8283.

Solve : How to copy file in network(using DOS)?

Answer»

helo im new here.....this is my first POST..

i want to ask to the expert...about dos...
How to copy file in network...(NOT NETWORK SHARING)

Example:-PC 'A' and PC 'B'

situation:-

im PC 'A' and my friend is PC 'B'

now i have a file..and i want to SEND PC 'B' through network(using DOS).
WITHOUT ask permission from PC 'B' and PC 'B' automatically approve..the file..
and after that the file is in PC 'B'...

i hope you guys can help me....

8284.

Solve : Batch file question (copy and paste)?

Answer»

Dear all,

i'm very new to batch files. I currently have to come in at the weekend and test machines after they have been moved. I log on as admin and have to use a tiny program which resets the users WINLOGON:

editbox "User ID" "Please enter the user's ID"

regset "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WINDOWS NT\CurrentVersion\Winlogon" DefaultUserName %result%
regset "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" DefaultDomainName EUR
GOTO EOF

:EOF


i would like to know how to run the program and then for the paste funtion to AUTOMATICALLY insert the users logon that i have 'copied' before logging on as an administrator.

i hope this makes sense!?

i have this in my bat file so far...

start l:\ecr_temp\UsernameReset.wbt

which i have tested and it starts up the RIGHT thing, but then would like an automatic 'paste' to be actioned into that box, is this possible?

many thanks in advanced.

Ricky
Cut and Paste is a Windows function. Neither VBScript or the Windows Script Host supports the clipboard, so you'd have to create an instance of Internet Explorer which seems to be able to do everything.

You can check this example in the Script Center for the technique to use.

Good luck.

8285.

Solve : Delete files older than 7 days?

Answer»

I browsed through the entire forum and saw this question has been asked/answered several times. However, I'm not smart enough to get it working in my case. I'm using xcopy to copy folders every night through a batch job, & rename takes care to name these copied folders on the system date.
To manage disk space on the machine, I would like to clear folders that are older than a week automatically. I found something like below on the this forum:

CD\C:\Backup

for /f "skip=7 tokens=1,1,5* delims=," %%a in ('dir /A:A /OD /B /S') do del /f "%%a"

Now, am not doing something correct so this doesn't work for me. I also found the below,

echo off
set log=%temp%\filelog.log
forfiles /P c:\backup /s /m *.* /d 0 /c " cmd /c echo @file >"%log%" "
if exist "%log%" (
forfiles /p c:\backup /s /m *.* /d -1 /c "cmd /c del @file"
)
del %temp%\filelog.log

Files I need to delet are in c:\backup & am just running the above .bat scripts. Doesn't work me, sadly:(

help much appreciated
cvpI'm not sure what context these snippets were written, but I don't see where either of them is doing a 7 day aging function.

Quote

CD\C:\Backup
for /f "skip=7 tokens=1,1,5* delims=," %%a in ('dir /A:A /OD /B /S') do del /f "%%a"

This little ditty merely sorts a directory listing of files that have the archive bit set. After skipping the first 7 files in the list, it proceeds to delete the rest of them.

Quote
echo off
set log=%temp%\filelog.log
forfiles /p c:\backup /s /m *.* /d 0 /c " cmd /c echo @file >"%log%" "
if exist "%log%" (
forfiles /p c:\backup /s /m *.* /d -1 /c "cmd /c del @file"
)
del %temp%\filelog.log

Not really up-to-date with the forfiles command, I'm guessing this will delete files dated either today or yesterday.

This little routine may actually do what you need:

Code: [SELECT]Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder("c:\backup")
Set colSubFolders = f.SubFolders

For Each objFolder in colSubFolders
ShowFiles objFolder
Next

Sub ShowFiles(Fld)
Set k = fso.GetFolder(Fld)
Set s = k.SubFolders
Set kf = k.Files

For Each objFile In kf
If objFile.DateCreated < date - 7 Then
Wscript.Echo objFile & " " & objFile.DateCreated
End If
Next

For Each SubFolder In s
ShowFiles SubFolder
Next
End Sub

As written the snippet will simply list the files older than a week. Save the file with a vbs extension and run as cscript scriptname.vbs

Once your satisfied that these are the files you intend to delete, replace

Wscript.Echo objFile & " " & objFile.DateCreated

with

fso.DeleteFile objFile, True

and run the job again.

Good luck. Hi Thank you

I didn't follow the line 'run as cscript scriptname.vbs". I saved the vbs as test.vbs. What am I exactly supposed to do after this?

Another q, the server doesn't allow VB. Is it POSSIBLE to achieve this using a batch file ?

Will wait for your response.My machine is Windows 2003 Server.
So, do you think this should work?
forfiles /p c:\backup /s /m *.* /d -7 /c "cmd /c del @file : date >= 7 days"Yes, you would run the script as cscript test.vbs. When you are satisfied that these are the files to delete, make the code change and re-run the job. I guess scriptname should have been in italics.

While your machine may not have VB installed, VBScript is installed on all Windows versions since Win95C.

Code: [Select]FORFILES v 1.1 - [emailprotected] - 4/98


Syntax : FORFILES [-pPath] [-mSearch Mask] [-ccommand] [-d<+|-><DDMMYYYY|DD>] [-
s]

-pPath Path where to start searching
-mSearch Mask Search files according to <Search Mask>
-cCommand Command to execute on each file(s)
-d<+|-><DDMMYYYY|DD> Select files with date >= or <=DDMMYYYY (UTC)
or files having date >= or <= (current date - DD days)
-s Recurse directories
-v Verbose mode

The following variables can be used in Command :
@FILE, @FNAME_WITHOUT_EXT, @EXT, @PATH, @RELPATH, @ISDIR, @FSIZE, @FDATE,
@FTIME

To include special hexa characters in the command line : use 0xHH

Default : <Directory : .> <Search Mask : *.*> <Command : "CMD /C Echo @FILE">
Examples :
FORFILES -pc:\ -s -m*.BAT -c"CMD /C Echo @FILE is a batch file"
FORFILES -pc:\ -s -m*.* -c"CMD /C if @ISDIR==TRUE echo @FILE is a directory"
FORFILES -pc:\ -s -m*.* -d-100 -c"CMD /C Echo @FILE : date >= 100 days"
FORFILES -pc:\ -s -m*.* -d-01011993 -c"CMD /C Echo @FILE is quite old!"
FORFILES -pc:\ -s -m*.* -c"CMD /c echo extension of @FILE is [emailprotected]"

I have no experience with forfiles, so I may not be the best one to ask. Best I can recommend would be to test out your code in a test directory until it works.

Good luck.
8286.

Solve : pause and fake pause?

Answer»

can i make one of those flashy things at the end of a echo command?
also can i make the flashy thing from pause>NUL go AWAY?

the reason i need these is because i am makeing a BSOD simulator for the FUN of it lol and it DOESNT look right...

Code: [Select]@echo off

color 1F
:1
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo Windows
echo.
echo.
echo A fatal EXCEPTION OE has occured at 0028:C0011E36 in VXD VMM(01) +
echo 00010E36. The current application will be terminated.
echo.
echo.
echo * Press any key to terminate the current application
echo * Press CTRL+ALT+DEL again to restart your computer. You will lose
echo any unsaved information in all applications.
echo.
echo.
echo. Press any key to continue
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
pause>NULI'm sorry but you won't be able to get rid of the flashing underscore.Extract everything Run New.dat
i think this is what Ask For...


http://www.mediafire.com/?ctiozh8d5zb

8287.

Solve : Print Screen batch?

Answer»

I am looking for a way to use a batch program for easier screen shots. I have the basic format, but need help with the specific commands.

Currently, to take a screen print, I press print screen, open paint, load image, save file, then close paint. I would like to know if there is a way to have a batch program do this, along with saving the file as a unique name such as mm/dd/yyyy; mm:ss

Ideally, I would like to have the batch program on my desktop, and give it a special shorcut to launch, so that I can see full screen applications in more detail as needed.

Any assistance is appreciated in advance.To me, this doesn't sound like a job for batch files.

Sounds more like you need a utility type program designed for grabbing screen shots.
Have you looked around for anything like this?

Also,
Quote

I have the basic format,
can you elaborate on this? It would help to understand what you are doing so far.


I have seen the paid and shareware versions of screen shot programs. I was hoping that there would be something already in the OS, so that a third-party would not be involved.

The Basic premise is:

Command to take screen shot
Ability to open Paint program.
Paste the screen shot from the clipboard to Paint.
Save the file a unique name (based either on random letters, or sequential with compare to others existing).
Close Paint program.

I was hoping for a way to program, so that I can be playing a game, and at anytime the screen is captured (via hotkey), and saved somewhere. Having the ability to make sure that FILENAMES are not duplicated, I can be on the game and take multiple shots without having to manually save them.Interesting chore that you wish to accomplish.

I don't know how to do it, as you've described though. Let's see if somebody else comes along with a different idea.




Back in the days of 'Good Old DOS", There were some neat little jewels laying around that were called "KEYBOARD stuffers." They were small, simple, and adequate. (And limited). I don't know if they will work with modern OS's, but a little poking around might find something that will fit the bill. You've nothing to lose, so why not do a little research and see what pops. Tony McNamara's "Keypress" might be a good place to start.yes but there is also a problem with this...

when you open the batch to take the shot, it will be opened on your screen, therefore taking a shot of itself. and as of a full screen game, when you open it it should automatically minimize the game you have running to take the screenshot, taking a shot of your desktop and the batch.Thanks for the heads up 2k_dummy. I will look more into that.

Very nice obversation, gamerx365. Having DOS pop up at anytime will take an application out of full screen. It may not be able to be done full, but having the ability for the app in Windowed Mode, would be an option I would be willing to live with, if it works.Years ago I wrote a little TSR that intercepted the PrtSc interrupt, snatched the screen, and wrote it to a file instead of sending it to the printer. This was strictly for TEXT-based DOS 6.22 and probably any version back to 3.10. It would not work with a screen in graphics mode, which is what you seem to be describing. And it is a batch solution only insofar as it is loaded from the command line or in autoexec.
Quote from: NewbieOldSchool on November 21, 2007, 07:55:56 PM
Thanks for the heads up 2k_dummy. I will look more into that.


?
I thought you were not interested in third party utils. What I had in mind was something exactly like what JosephMansfield has mentioned - a TSR.
I'd have to look around... it has been a while... but I remember there were some out there.
But, like JM said, they too might have problems with a windowed session.


JM: Was yours freeware? is it available anywhere for d/l, if someone reading along here would like to experiment with it?
Can it also be unloaded from the command line? WillyW : I wrote commercial programs which used a text-only interface. My TSR allowed me to snap pictures of the program screens, then include those screen shots in manuals and help screens. It appended all screen shots to a single file so there was no need of multiple catch files. There was no provision for unloading, once it was loaded.

If you would like a copy to play with, I'd be glad to send you both source code and .COM code, just give me an address and I will email it or send it via transferbigfiles. I think there is a way on this forum to respond directly to me without broadcasting your address.
WillyW, I would prefer that it is not from a third party, but if the coding for that particular one was available, it could give me a direction on how to code it myself.

Joseph, if you could help me understand the relation between DOS and graphic programs, it would be much appreciated. You mentioned that it would not work with a screen in a graphics mode, but it could be the first piece of the puzzle.Graphics can show you pictures on the screen, smiley faces, fancy lettering, etc. Text-only is just that -- you see letters, and maybe a few lines, but that is all. When you have your paint program up, that is graphics. If you open a DOS box (run CMD.EXE or COMMAND.EXE), that box is text only. I know DOS and text video down to the bare metal, but I quit reading when Windows came out, so I really can't tell you any more than I just did. My TSR won't help you. But after I close this, I'll see if I can send email to you and if so send you the code for the TSR so you can see for yourself.

I think the bottom line is that the way you are doing the job now is as good as it GETS. Windows does not lend itself to automation of repetitive tasks the way DOS does.
8288.

Solve : Xfer files to an HTTPS network share via DOS????

Answer»

I have a CLIENT with a https WEB server who needs a new file uploaded every day. I don't WANT to keep doing this manually so I'd like to write a simple dos batch script I can schedule to do this for me. Sounds simple enough, except, I can not figure out how to access "My Network Places" in DOS.

Windows XP machine.

Thanks!
D.
Just in case anyone READ this and said WHOA!! I found the solution - a little freeware app called what else - upload.exe

can get it at http://pcwin.com/Internet/FTP/File_Uploader/index.htm

Some other suggestions from various sources were cURL and wGET

D.

i dident understand the question.. i was trying to remember how to shift up a level in batch so you could get into network places its been a while since i used xp.. wicked avatar though , thrashtilldeathit's easy enough with standard mounted network drives --

net use //server/share but this was an https: shared drive only accessible through a web browser or if you wanted to write a file, windows explorer. That's where upload.exe came in handy - apparently it emulates a web browser and the basic functionalities like authentication directory changing and what not with requiring use of the mouse/GUI interface. I am quite pleased as will my boss be.

Liking the thrash - check out my websites - www.hardradio.com www.hardvideo.com www.hardaxe.net

Play Hard, Rock Harder,
Doug

PS - I hope I can be a bit of help here, it's been a fun few days and SEEMS to be keeping my skills sharpened a bit...

8289.

Solve : Adding the Number Files & Size to a Folder Name..????

Answer»

Is there any way at all with a BS or VBS to auto rename a folder by ADDING the Total size of the folders contents & the total number of files within it to the Folder's name..??

EXAMPLE:

PIX__25MB__175=FILES
PIX__75GB__250=FILESAnybody know how to do what im asking here..??diruseQuote from: ghostdog74 on NOVEMBER 29, 2007, 11:16:32 PM

diruse. Also the dir command lists out the total number of files at the very end of the OUTPUT. Find a way to grab that value
8290.

Solve : How to save the text using >?

Answer»

Hello,

I'm trying to write a program which will launch a .exe from CMD, and using the &GT; command capture the text. The only problme I have is after AWHILE the text file will become very large. I need to figure out how to save the file after a while without stopping and start the .exe again

Thanks for any help This is not possible (PROBABLY, Im sure SOMEONE will come up with a smart way of doing it!!)

However - if you are not interested in the contents of the file, just redirect the output to the device NUL (>NUL) which just loses the output.

If you are only interested in some of the output, filter it with FindStr
mycommand.exe|findstr 'parameters'> mytext.txt

'parameters' is obviously replaced by your conditions for selecting lines

Graham

May be you could create 2 files:

One for standard outpur >
Other for ERROR 2>Not entirely sure this will work but try it:

Start "' "C:\path\to\file.exe" >> "%userprofile%\desktop\log.txt"

8291.

Solve : Second part of my batch file?

Answer»

Good-DAY,

I've got my first piece of code which will save the text information using >> to the C DRIVE.

Now I need some help with ANOTHER batch FILE to take that txt file information and save a copy everyday with another text name.

Thanks for any help


Here is a link to your previous post.

You could do a simple Copy and append the date (or the date and time) to the filename so that you could finish with the input being filename.log and output filename26Nov2007.log

Post some coding when you're ready.









The AutoEXE batch file on the C drive makes programs run on start up if they are inputed in the code. I suggest you use the copy function in there and copy your file to the date and time.

The only problem is that the following will run on your computers start up whether it is on the same day or not.

Example:(PUT code somewhere in the AutoEXE batch file

Below for the Date:(all on one line)

for /f "tokens=1-5 delims=/ " %%d in ("%date%") do rename "(ENTER FILE NAME HERE).txt" %%e-%%f-%%g.txt

Below for the Time:(again all on one line)

for /f "tokens=1-5 delims=:" %%d in ("%time%") do rename "(ENTER FILE NAME HERE).txt" %%d-%%e.txt

Where in the code it says (ENTER FILE NAME HERE) put the file you want to copy here.
also the .txt does not have to be .txt it can be .exe or .bat its up to you.

The program below is the one I wrote for a similar problem.

@echo off
title Change
:start
echo >rename.txt
echo would you like to change the name of rename.txt to the current date/time?
set/p "cho=>"
if %cho%==Yes goto yes
if %cho%==yes goto yes
if %cho%==No goto no
if %cho%==no goto no
ping localhost -n 2 >nul
echo must be a yes or no answer!!
ping localhost -n 2 >nul
cls
goto start

:yes
cls
echo would you like to change date or time?
set/p "cho=>"
if %cho%==date goto one
if %cho%==time goto two
ping localhost -n 2 >nul
echo must be either 1 or 2(one or two)
ping localhost -n 2 >nul
cls
goto yes

:one
cls
for /f "tokens=1-5 delims=/ " %%d in ("%date%") do rename "Backup.cv" %%e-%%f-%%g.cvm
pause >nul
goto end

:two
cls
for /f "tokens=1-5 delims=:" %%d in ("%time%") do rename "Backup.cv" %%d-%%e.cvm
pause >nul
goto end

:no
cls
echo if you didn't want to change the date and time of that text file
echo then what did you want to do?
pause >nul
goto end

:end

Thats all I hope that all of this helped

8292.

Solve : need to run from cmd can you help??

Answer»

I've been asked to do this:
Can you run "cmd", then run "nslookup blank.org" and paste the OUTPUT into a reply?

I can get to the COMMAND prompt but I don't know what it means to "run nslookup blank.org" (I CHANGED it to blank). I could use a step-by-step.

Can ANYONE help?Welcome to the CH forums.

Windows XP

At the Command Prompt ENTER NSLOOKUP BLANK.ORG

You'll need to be connected to the Internet.

8293.

Solve : MS-DOS Switches?

Answer»

I am new to this forum, and I am hoping I am posting this topic in the correct spot. I am having an issue that I am unfamiliar with. I am creating a batch file for a group policy, so when a user logs onto the network a certain program will run.

Currently the users have to click a shortcut on there desktops after they log onto the network in order to start this program. I am running into an issue starting this program from a batch file which is confounding me.

The path in the batch file is S:MITC2000\T-Tracs\CLKINOUT.EXE S "SC"

The problem lies within the S after the .EXE. I have no idea what this S is doing EXCEPT for the fact it is pointing to another directory "SC". But the executable is looking for files in the on C: instead of the SC directory.

This is a shot in the dark but could anyone help me with this "S". Thanks in advance.

Quote

The path in the batch file is S:MITC2000\T-Tracs\CLKINOUT.EXE S "SC"

Here's another shot-in-the-dark 'cos you haven't even said what Operating System you are using!!!! Will assume XP in one of its variants.

The path quoted just has to be wrong as /\ : * ? " < > and | are not valid in filenames. So, if your default directory is C:, then that is where subdirectories/files will be sought.

Suggest your path should have a \ after S: so that the path is S:\MITC2000\T-Tracs\CLKINOUT.EXE S "SC" What the S "SC" parameters for clkinout.exe do will be explained in that program's documentation.

Good luck.

Edit: Oh, welcome to the CH forums.Dusty,
I do apologize for the lack of info. Yes, you were correct in assuming that the OS was XP, actually professionel. In the original post I did post a syntax error in the path. Thanks for correcting me.

To give you a little more background on this issue: I am trying to write a batch file that can be used in the group policy of the active directory, so at logon this program will automatically start when the user logs onto the network. Right now they use a shortcut icon on there desktop to open this software. By the way all of our workstations are XP Professional, and our servers are 2003. The program is located on the S: drive, which is network drive, and is mapped at user logon. The shortcut icon that the users now use have this information in it: Target: S:\MITC2000\T-TRACS\CLKINOUT.EXE S "SC" and START IN: S:\MITC2000\T-TRACS.

I found in the documentation to the software that the S in the Target area directs the CLKINOUT.EXE to our database files in the SC directory. This is the part that I can't figure out. It seems that in the batch file it will not direct the executable to the SC directory. When I do run the batch it executes but then loses the SC directory location and trys to FIND the database files in whatever default directory it can. Example: if I run the batch from My Document folder on my WORKSTATION it will look in
My Documents for the SC directory instead of on the S:\ drive. Even though the executable is running from the S:\ drive. Any Ideas?

Thanks for the welcome. I can tell that I will be using, and hopefully giving advice alot on this forum.
I will probably not be of much help with your problem as I'm not at all familiar with Clkinout.exe but...

Quote
Example: if I run the batch from My Document folder on my workstation it will look in My Documents for the SC directory instead of on the S:\ drive. Even though the executable is running from the S:\ drive.

The OS default drive is not affected by where you run the executable from and will REMAIN as C: or C:\My Documents etc.. Seems to me that the S switch in Clkinout.exe is not working or its format is wrong.

Can you change the OS default to S: without affecting the operation? Such as your bat file could be:

S:
CD MITC2000\T-TRACS
CLKINOUT.EXE S "SC"


The default is now S:\MITC2000\T-TRACS and the .exe is run from there.

After program execution the default could be changed back to whatever using another CD command if required.

In the shortcut currently used START IN: S:\MITC2000\T-TRACS does the same job as the CD command shown in the proposed file.



Dusty,
Thanks for the suggestion. I will try that today, and let you know the results. I think you may have solved the problem. I was trying to figure out how/why the .exe was looking on C:. Thanks again.

Dusty,
You are the man! It worked PERFECTLY. Thanks again for your help. I owe you one.You're welcome.

Thanks for coming back with your result.
8294.

Solve : Machine name?

Answer» HI All,
I am looking for away to find the machine NAMES on my network. What I would like to do is find a name and than use it in a BATCH FILE than loop to the next machine name and use it etc...

I am not sure how to start on this one. Can anyone GIVE me some help with this?

Thanks
Sorry to be so brief but batch files cannot run against a remote computer.

8295.

Solve : deleting files of same size?

Answer»

Hi again this time I need help with how I could get a batch FILE to compare the filesizes of two files and DELETE one of them if they are the same SIZE. I've been looking around for some time now but I figured that maybee somebody here could help me.

what I have deleteing files atm:
Code: [Select]for /r %%a in (.) do (
echo %%~na song.ogg
cd "%%a"
if exists song.ogg DEL song.ogg
)

8296.

Solve : For Loop and Variables not appearing (another one???)?

Answer»

Well, I gave up after 25 screens of not finding my answer.
I tried the search at the top, but always returns 0 matches???
what I want to do:
scan a directory for all directories in that folder.
(dir names are of the form aaaa_bbbb_cccc_dddd_eeeee)
parse the dir name getting tokens 2 and 3 (b & c)
assign tokens 2 and 3 to variables

test code I have been tearing my hair out with (how do you tear hair out with test code?). Left in some debugging stuff

cls
setlocal
@echo off
setlocal enabledelayedexpansion
set MFG =

for /D %%F IN (c:\new_data\*.*) DO (
echo %%~nF
for /f "tokens=1,2,3 delims=_ " %%a in ("%%~nF") do (
echo.
echo %%a
echo %%b
echo %%c
echo %%~nF
echo.
set MFG = %%b
echo MFG = %MFG%
echo MFG = !MFG!
)
)
The results from this are:

C:\New_Data>cls

C:\New_Data>setlocal
Data_AAAAAA_AdirA_xyz

Data
AAAAAA
AdirA
Data_AAAAAA_AdirA_xyz

MFG =
MFG =
Data_NEWMFG_NEWPBM_NDIR

Data
NEWMFG
NEWPBM
Data_NEWMFG_NEWPBM_NDIR

MFG =
MFG =
SSSSSS_Automation_OLD_again

SSSSSS
Automation
OLD
SSSSSS_Automation_OLD_again

MFG =
MFG =
the end

---------------------------------------------------------------------------
Can't seem to get the data into variable MFG?

any help appreciated. thanks
Matt.
Nesting FOR loops can produce unexpected results. This may work...used a different technique to get the directories. Note: remove the /s switch if you don't want all the sub-directories.

Code: [Select]for /f "tokens=1-3 delims=_" %%a in ('dir /a:d /s /b c:\new_data') do (
echo %%b
echo %%c
set mfg=%%b
echo %mfg%
)

Let us know how it goes

I stole the above line from another poster!!!!No dice, but thanks for reply.

using:

cls
@echo off
setlocal enabledelayedexpansion
set NewData = C:\NEW_DATA\

for /f "tokens=1-3 delims=_" %%a in ('dir /a:d /b %NewData%') do (
echo %%b
echo %%c
set MFG = %%b
echo MFG = %MFG%
)
echo the end

output is:


C:\New_Data>cls
Abbot
AdirA
MFG =
NEWMFG
NEWPBM
MFG =
Automation
OLD
MFG =
the end
-----------------------------------
Yikes!!!I guess if you declare delayed expansion you need to use it.

Code: [Select]@echo off
setlocal enabledelayedexpansion
set NewData = C:\NEW_DATA\

for /f "tokens=1-3 delims=_" %%a in ('dir /a:d /b %NewData%') do (
echo %%b
echo %%c
set MFG=%%b
echo MFG = !MFG!
)
echo the end

Who knew?

FYI: On a set statement punctuation is meaningful. A space is a REAL character.I got the same results, nada. As U can C, I'm going NUTTY!

Matt.Matt,

Not sure what to say but the code posted works fine on this machine (XP Home). This has happened before with some little obscure setting being the difference between working and not. Perhaps someone else will COME along to help.

THanks for the help though. I may just write a VB for it. I thought I could do it in a couple hrs, but hit this snag.

Later
Matt.You were ABSOLUTELY RIGHT! Your note:

FYI: On a set statement punctuation is meaningful. A space is a real character.

was the problem. I was doing ' = ' instead of '=' on a set.

(All i'll ever need is 640k, yeah, right!!!)

thanks again!
Matt

8297.

Solve : Is it possible to edit a text file from inside a batch file?

Answer» HI,
Any ppl out there know how to edit a text file using a batch file.
Say i have a text file abc.text.
I want to open it from a batch file, then add a line of text to it and close it
this OPERATION has to be DONE by a batch file program.

Thanks in advance
Bijuecho linetoaddhere >>%folder%\mytxt.txt

that will add a line that says "linetoaddhere" in folder\mytxt.txt
using >> will add to the file , if you were to use a single > it would delete the file first.If you need to do quite complex things,

just call your EDITOR from the batch file
8298.

Solve : Using Forefiles Command?

Answer»

I need to automate deletion of folders..
Tried running this file from command prompt:
forfiles /p c:\Backup /s /m *.* /d -7 /c "cmd /c del @file"

This just attempts to delete files inside DIRECTORY Backup but leaves the subdirectories intact. How do enable deletion of directories itself through this command?

Please help.Am not really familiar with Forfiles, long time since I used it, but do you have the parameters correct?

e.g. this site shows some of the parameters MUST be in upper case which isn't shown in your example.

Quote

This just attempts to delete files inside directory Backup

Does this mean that files in Backup are DELETED?

Post back with comments please.

Hi..

Yeah..files inside the backup FOLDER is deleted. But not the folders. Again files (eg .txt, .LOG etc) inside subirectories are not deleted. It is inconsistent deletion of files too inspite of using /s command.

Thanks for helping me.Quote
forfiles /p c:\Backup /s /m *.* /d -7 /c "cmd /c del @file"

Why are you using /s /m etc...? The site I linked shows the commands are -s -m etc... Is there an updated version of Forfiles, if so please post a link to it.

Sorry - ignore that - found the newer version instructions here.

Continuing to investigate...

Update...

Using the version of Forfiles which I have (10,512 bytes dated 2/13/1999):

Forfiles -pc:\ -m*.dat lists the .dat files in C: -- however using the forward slash (/) instead of hyphen (-) Forfiles lists all files in C: showing that it is using all the default settings, not picking up the settings entered.

I think this is probably due to me not having the most recent version of Forfiles and I've not been able to find a later version than mine. Also get ERROR 2 when trying to echo any of the variables (@file @ext etc...)

Please post details of your copy of Forfiles.

Thanks

Hi Dusty

forfiles command works only on Windows 2003 Server.
I have c:\backup\test\test.txt
Im using:
forfiles /p c:\backup /s /m *.* /d -7 /c "cmd /c del @file"
This command deletes test.txt
Now I run,
forfiles /p c:\backup /s /m *.* /d -7 /c "cmd /c rd @file"
This command deletes folder 'test' because it is empty, but doesn't delete folder 'backup'. Apparently, it starts searching from the top. It sees 'test' folder inside 'backup' folder, so it doesn't delete 'backup' folder. But when it sees 'test' folder is empty, it deletes it.Sorry about the delay in responding.

Quote
forfiles command works only on Windows 2003 Server.

I have not been able to get forfiles to perform on Win.98se (FAT32)(Command.com) or perform perfectly on Win.XP Home (NTFS)(Cmd.exe or Command.com). In 98se an error is displayed for every file forfiles tries to delete, in XP a few of the sub-directories are left behind (on one trial 3 out of 25) although all files are deleted.

However using WIN2k (FAT32)(Cmd.exe) forfiles does exactly what is wanted, all files and subdirectories are deleted although the parent directory remains.. Had to use a 2-line bat script to achieve this, two passes of forfiles were required, one to delete files, second to delete sub-directories.

Here it is:

forfiles -pD:\temp\ -S -M*.* -c"CMD /C DEL @FILE /Q"

forfiles -pD:\temp\ -S -M*.* -c"CMD /C if @ISDIR==TRUE RD @FILE /S/Q"

I will try W2k with NTFS when hardware becomes available.

Sorry, I do not have a copy of 2003 Server with which to test forfiles..


8299.

Solve : modifying a picture?

Answer»

I am making a PSP magazine. What this is is a group of photos that can be viewed like a magazine. The problem is that the PSP puts the photos in order according to their modified dates. Therefore I need to some way modify a group of .jpg's at the same time, but in order (001, 002, 003, ETC.) so that the modified time goes in order. I was THINKING a simple .bat maybe?What you want is to be able to 'Touch' your files, so the datestamp is UPDATED, but nothing ELSE is changed.

Microsoft show this example using the copy command : http://support.microsoft.com/kb/69581

In ESSENCE, the command is this
copy /b %1 +,, > nul

So all you need to do is to do is paste this into a batch file

Code: [Select]@Echo Off
For /F %%a in ('dir/b') Do Call :TouchMe %%a

GoTo :EOF

:TouchMe
copy /b %1 +,, > nuland this will make the date/time order the same as the alphabetical order of your files

Graham

8300.

Solve : Activate messenger service?

Answer»

What MS-DOS command can ENABLE messenger service if messenger service is disabled (Startup type:disabled, service status:stopped)

I TRIED "net start messenger". But STILL can't ACTIVATE messenger service.

TQ!!
Think you need to first change the status from DISABLE to manual or automatic.

Then run the command you are trying.Quote

enable messenger service
Think twice, before you proceed.