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.

5351.

Solve : No Feedback??

Answer»

No feedback?

ASSUME the ID of the Original POSTER and make your ANSWERS appear
to be right on TARGET.

5352.

Solve : variables in FOR command?

Answer»

When using the for command in a batch,

e.g.

Code: [Select]
for /r %%g in (*.*) do ( ..........



Is there a WAY to make %%g relative rather than an absolute?

I need to use the variable %%g later but just with the filenames, not the absolute path including C:\dir1\dir2 etc.

[This is actually for a GPG decryption; it wants me to specify the output FILE for each decryption, not merely the directory; clearly it won't work if the output file points to a file that already exists!]


Many thanks for your help, possibly in stating the obvious
Look at the help for FOR

you can do this
for /r %%g in (*.*) do MyCommand.Exe %%~nxg
which will extract only the name

where you were PROBABLY doing
for /r %%g in (*.*) do MyCommand.Exe %%g

which will GIVE you the full path
Quote from: gpl on January 05, 2010, 05:56:27 AM

Look at the help for FOR

you can do this
for /r %%g in (*.*) do MyCommand.Exe %%~nxg
which will extract only the name

Excellent answer. Technically, ~n gets the name, ~x gets the extension (which includes the dot).

In the filename "Datalist.txt", Datalist is the name, and .txt is the extension.
Hi

Thanks very much for your quick reply.

I now have this:

for /r %%g in (*.*) do (
echo %pass%|gpg --batch -q --passphrase-fd 0 -o "D:\gpgD\%%~pnxg" --decrypt "%%g"
)


I want to recreate the file structure (using %%~pnxg) but in an existing directory D:\gpgD

This seems to work except for the fact it tries to write to the directory with double forward slashes
e.g. D:\\gpgD\\dir1\\file.gpg

Argh!

Thank you for your patience Quote from: impaled on January 05, 2010, 08:25:22 AM

This seems to work except for the fact it tries to write to the directory with double forward slashes
e.g. D:\\gpgD\\dir1\\file.gpg


... and this is a problem?
Sorry, you're right. \\ doesn't matter
Misdiagnosed the problem --- GPG won't output to a directory that doesn't yet exist (it won't create them itself, for some reason.)

I have solved it like this: output them in the current dir without the .gpg extensions, then robocopy out EXCLUDING .gpg extensions....

for /r %%g in (*.*) do (
echo %pass%|gpg --batch -q --passphrase-fd 0 -o "D:\gpgD\%%~dpng" --decrypt "%%g"
)

Thanks all for your help.Quote
"D:\gpgD\%%~dpng"

That's going to give you a very strange looking path...
More mistakes, on a roll today.

-o "%%~dpng"

Thanks!
5353.

Solve : How to get the control panel in the right click menu of the desktop...?

Answer»

I want to get the control panel in the right click menu of the DESKTOP and does not KNOW the same and hence wants the help with the same....You can create a shortcut to Control Panel (its called control.exe) but i'm not sure about the Right-Click Context menu.Quote from: Shersingh12 on November 17, 2008, 10:27:14 AM

I want to get the control panel in the right click menu of the desktop and does not know the same and hence wants the help with the same....
Quote from: Shersingh12 on JANUARY 05, 2010, 02:55:30 PM

Carbon requested a re-explanation of your post, not a repeat of it. No he didn't. I'm FAIRLY certain CD understood the question but wasn't sure how to answer it.
See if this helps: http://www.tech-recipes.com/rx/1176/how-to-add-menu-items-under-right-click-or-context-menu/
5354.

Solve : Log into website??

Answer»

Hello fellow nerds

I just had a request to create an "ICON" on a DESKTOP for multiple PCs that multiple users will need to access. It will be a shortcut to a website. I have no problems creating an EXE that is a shortcut to a site. The problem is the user wants me to create a script that will automatically log into the website when it opens...I am totally lost with this. I believe you can not create a BAT file that passes credentials, but you can create a VBS that will. Can anyone assist me in fulfilling this request?

Thank you!

HoFLSorry to double post. This is more of an update / FYI type post.

I FOUND a script that works perfectly! Check it out. All you need to do is view the source code of the page you are trying to log into, then get the string name for the user name, PASSWORD and login button. You will also need the "value" of the button. Let me know if you guys need any help!

Code: [Select]WScript.Quit Main

Function Main
Set IE = WScript.CreateObject("InternetExplorer.Application", "IE_")
IE.Visible = True
IE.Navigate "http://www.chiltonpro.com/home.aspx"
Wait IE
With IE.Document
.getElementByID("Mkt_lnav1_mkt_login1_txtUsername").value = "ITS A SECRET"
.getElementByID("Mkt_lnav1$mkt_login1$txtPassword").value = "ITS A SECRET"
.getElementByID("Mkt_lnav1$mkt_login1$btnLogin").click
End With
End Function

Sub Wait(IE)
Do
WScript.Sleep 500
Loop While IE.ReadyState < 4 And IE.Busy
Do
WScript.Sleep 500
Loop While IE.ReadyState < 4 And IE.Busy
End Sub

Sub IE_OnQuit
On Error Resume Next
WScript.StdErr.WriteLine "IE closed before script finished."
WScript.Quit
End Sub

5355.

Solve : super HEX Problem?

Answer»

Is ther any way 2 find a file's SIZE and Its OFFSET in Archive Through command line
or Is there any softwareIf you mean a standard zip archive, you can use unzip with the -Zv switch

for example, here archive is test2.zip, files in it are zipinfo.txt and ziplimit.txt

Code: [Select]S:\Test\GZip\unzip\dl>unzip -Zv test2.zip
Archive: test2.zip 37809 bytes 2 files

End-of-central-directory record:
-------------------------------

Actual offset of end-of-central-dir record: 37787 (0000939Bh)
Expected offset of end-of-central-dir record: 37787 (0000939Bh)
(based on the length of the central directory and its expected offset)

This zipfile constitutes the sole disk of a single-part archive; its
central directory CONTAINS 2 entries. The central directory is 115
(00000073h) bytes long, and its (expected) offset in bytes from the
beginning of the zipfile is 37672 (00009328h).

There is no zipfile comment.

Central directory entry #1:
---------------------------

zipinfo.txt

offset of local header from start of archive: 0 (00000000h) bytes
file system or OPERATING system of origin: MS-DOS, OS/2 or NT FAT
version of encoding software: 2.0
minimum file system compatibility required: MS-DOS, OS/2 or NT FAT
minimum software version required to extract: 1.0
compression method: none (stored)
file security status: not encrypted
extended local header: no
file last modified on (DOS date/time): 2010 Jan 7 16:45:06
32-bit CRC value (hex): e94b62b5
compressed size: 25829 bytes
uncompressed size: 25829 bytes
length of filename: 11 characters
length of extra field: 0 bytes
length of file comment: 0 characters
disk number on which file begins: disk 1
apparent file type: binary
non-MSDOS external file attributes: 000000 hex
MS-DOS file attributes (20 hex): arc

There is no file comment.

Central directory entry #2:
---------------------------

ziplimit.txt

offset of local header from start of archive: 25870 (0000650Eh) bytes
file system or operating system of origin: MS-DOS, OS/2 or NT FAT
version of encoding software: 2.0
minimum file system compatibility required: MS-DOS, OS/2 or NT FAT
minimum software version required to extract: 1.0
compression method: none (stored)
file security status: not encrypted
extended local header: no
file last modified on (DOS date/time): 2010 Jan 7 16:45:06
32-bit CRC value (hex): 9cb65fcc
compressed size: 11760 bytes
uncompressed size: 11760 bytes
length of filename: 12 characters
length of extra field: 0 bytes
length of file comment: 0 characters
disk number on which file begins: disk 1
apparent file type: binary
non-MSDOS external file attributes: 000000 hex
MS-DOS file attributes (20 hex): arc

There is no file comment.


Get unzip from

ftp://ftp.info-zip.org/pub/infozip/win32/unz552xn.exe

self extracting archive.D ans Worked Salmon
but do u hav a software or is ther any way 2 find size of file in hex

FOR ex if there is a file of 1 MB den how to find size of file in hex
Does that mean you don't want to know any more?
info-zip.bat

Code: [Select]@echo off
setlocal enabledelayedexpansion
set archname=%1
Echo Archive: %archname%
for /f "skip=1 tokens=1-8* delims= " %%A in ('unzip -Z "%archname%" ^| find /v "uncompressed"' ) do (
set filename=%%I
set filesize=%%D
for /f "delims==" %%L in ( 'unzip -Zv "%archname%" "%%I"') do (
for /f "tokens=1-11 delims=() " %%M in ('echo %%L ^| find "offset of local header"') do (
set hexoffset=%%V
set hexoffset=!hexoffset:h=!
set /a decoffset=0x!hexoffset!
echo File !filename! size !filesize! offset !hexoffset! hex !decoffset! dec

)
)

)


Code: [Select]S:\Test\GZip\unzip\dl>info-zip.bat test2.zip
Archive: test2.zip
File zipinfo.txt size 25829 offset 00000000 hex 0 dec
File ziplimit.txt size 11760 offset 0000650E hex 25870 dec
File Copy of unzipsfx.txt size 15578 offset 00009328 hex 37672 dec
No its not working

i m tryin 2 inject files in 1 data file
[Remember ma Topic on INJECT.exe]

I ve got the right command line with right example

go through this example

its command line options are

inject.exe filewhichuwantinject.ext [COMMAND LINE]

filewhichuwantinject.ext_offsetinhex_si zeinhex.ext[files shld b named as follows ]

the file in attachmnts "SchemaMetafile_DVD1.csc" is just renamed RAR file
Use the example and find out this softwares power

IT REQUIRES PERFECT SIZE IN HEX HENCE I need A software 2 show Filesize and offset in hex

[Saving space, attachment deleted by admin]Code I posted only works with zip archives. Not rar.

You'd better find a cdda injecting forum somewhere.




5356.

Solve : wav injector = reopened?

Answer»

i m tryin 2 inject files in 1 data file
[REMEMBER ma Topic on INJECT.exe]

I ve got the right command line with right example

go through this example

its command line OPTIONS are

inject.exe filewhichuwantinject.ext [COMMAND LINE]

filewhichuwantinject.ext_offsetinhex_si zeinhex.ext[files shld b NAMED as follows ]

the file in attachmnts "SchemaMetafile_DVD1.csc" is just renamed rar file
Use the example and find out this softwares power

IT REQUIRES PERFECT SIZE IN HEX hence I need A software 2 show Filesize and offset in hex

[Saving space, attachment deleted by admin]Quote from: the_mad_joker on January 08, 2010, 06:47:07 AM

i m tryin 2 inject files in 1 data file
[Remember ma Topic on INJECT.exe]

I ve got the right command line with right example

go through this example

its command line options are

inject.exe filewhichuwantinject.ext [COMMAND LINE]

filewhichuwantinject.ext_offsetinhex_si zeinhex.ext[files shld b named as follows ]

the file in attachmnts "SchemaMetafile_DVD1.csc" is just renamed rar file
Use the example and find out this softwares power

IT REQUIRES PERFECT SIZE IN HEX hence I need A software 2 show Filesize and offset in hex

are you unable to change base yourself? Also, this program doesn't seem very "powerful" if it's unable to determine a files size on it's own.Hey BC can u Pls HELP me ??

i just want a software 2 show a file's offset and size in hexwhy don't you ask in a cdda game forum?
5357.

Solve : Bios Information and hard disk information batch file?

Answer»

Hi Guys
Just joined the forum and had a look through and looks very interesting well done on all work done so far and hoping you's can help me with my problem
i am trying to create a batch file that will pull off bios information like unit serial number, manufacturer, memory and hdd size pretty basic information really is this possible and if so id like to know also if it could be saved to a server

any help or information would be appreciated

midgeC:\WINDOWS\system32\dllcache>msinfo32.exe


C:\>debug /?
Runs Debug, a program testing and editing tool.

DEBUG [[drive:][path]filename [testfile-parameters]]

[drive:][path]filename Specifies the file you want to test.
testfile-parameters Specifies command-line information required by
the file you want to test.

After Debug starts, type ? to display a list of debugging commands.

C:\>

C:\>systeminfo.exe

Host Name:
OS Name: Microsoft Windows XP Professional
OS Version: 5.1.2600 Service Pack 3 Build 2600
OS Manufacturer: Microsoft Corporation
OS Configuration: Standalone Workstation
OS Build Type: Multiprocessor Free
Registered Owner:
Registered Organization:
Product ID: 7658887-OEM-0011903-00104
Original Install Date:
System Up Time: 0 Days, 3 Hours, 51 Minutes, 44 Seconds
System Manufacturer: Dell Inc.
System Model: Inspiron 530s
System type: X86-based PC
Processor(s): 1 Processor(s) Installed.
[01]: x86 Family 6 Model 23 Stepping 6 GenuineIntel ~
2493 Mhz
BIOS Version: DELL - 42302e31
Windows Directory: C:\WINDOWS
System Directory: C:\WINDOWS\system32
Boot Device: \Device\HarddiskVolume2
System Locale: en-us;English (United States)
Input Locale: en-us;English (United States)
Time Zone: (GMT-06:00) Central Time (US & Canada)
Total Physical Memory: 2,037 MB
Available Physical Memory: 1,496 MB
Virtual Memory: MAX Size: 2,048 MB
Virtual Memory: Available: 1,996 MB
Virtual Memory: In Use: 52 MB
Page File Location(s): C:\pagefile.sys
Domain: WORKGROUP

http://en.kioskea.net/faq/sujet-330-bios-commands


How to enter BIOS

To be able to access BIOS, depending on your computer model, you can use the following:
ESC key
F5 key
F8 key
DEL keyAnd what commands would you use to retrieve BIOS data Bill ? ?Quote from: patio on January 08, 2010, 11:08:48 PM

And what commands would you use to retrieve BIOS data Bill ? ?

http://en.kioskea.net/faq/sujet-330-bios-commands


To select an option
Press the ENTER key

To change values
Use the number keys
Use the -/+ keys to modify numerical values
Use the letter keys to enter the commands
DEL/BACKSPACE keys to delete values
Y for YES and N for NO to answer questions

To QUIT BIOS
ESC key to quit BIOS.
CTRL+ALT+DEL to promptly restart the systemThose are the basic commands for moving around/making changes in the BIOS...

Again i'll ask you what commands would you use to retrieve BIOS data Bill ? ?Quote from: patio on January 08, 2010, 11:31:55 PM
Those are the basic commands for moving around/making changes in the BIOS...

Again i'll ask you what commands would you use to retrieve BIOS data Bill ?

Patio,

Please provide the information you seek or start a new thread.

We have heard nothing from Madmidgy, the original poster.
I'll not start a new thread...i asked you a question...@OP, you can retrieve BIOS information using vbscript, as usual
Code: [Select]strComputer = "."
set objwmi = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set BIOS = objwmi.ExecQuery("Select * from Win32_BIOS")
For each objBIOS in BIOS
Wscript.Echo "Build Number: " & objBIOS.BuildNumber
Wscript.Echo "Current Language: " & objBIOS.CurrentLanguage
Wscript.Echo "Installable Languages: " & objBIOS.InstallableLanguages
Wscript.Echo "Manufacturer: " & objBIOS.Manufacturer
Wscript.Echo "Name: " & objBIOS.Name
Wscript.Echo "Primary BIOS: " & objBIOS.PrimaryBIOS
Wscript.Echo "Release Date: " & objBIOS.ReleaseDate
Wscript.Echo "Serial Number: " & objBIOS.SerialNumber
Wscript.Echo "SMBIOS Version: " & objBIOS.SMBIOSBIOSVersion
Wscript.Echo "SMBIOS Major Version: " & objBIOS.SMBIOSMajorVersion
Wscript.Echo "SMBIOS Minor Version: " & objBIOS.SMBIOSMinorVersion
Wscript.Echo "SMBIOS Present: " & objBIOS.SMBIOSPresent
Wscript.Echo "Status: " & objBIOS.Status
Wscript.Echo "Version: " & objBIOS.Version
Next
save as getbios.vbs and on command line
Code: [Select]c:\test> cscript //nologo getbios.vbs

to get operating system information, you can use Win32_OperatingSystem. That will not retrieve the BIOS settings...just the base info...but nice try GD.Quote from: patio on January 08, 2010, 11:08:48 PM
And what commands would you use to retrieve BIOS data?

I don't know the answer. I don't understand the question. I don't use or understand the BIOS. I have never used or adjusted the BIOS settings.
I don't have a clue of the information that is needed. I will leave all discussions of BIOS setting to the experts. I will have the local computer shop retrieve the BIOS data if needed. I have used COMPUTERS since 1968 and have never had a need for the BIOS data.

I'm sorry I cannot help. Tell me which posts are misleading and I will erase those posts. Thanks for your ACCURATE information.
5358.

Solve : Taskmager is disabled by your Administartor?

Answer»

Quote from: Helpmeh on January 09, 2010, 09:21:41 AM

So how do they get it to show in Windows Media PLAYER? Make a fake one that is the exact same as my colourized version?

It's almost always a little GIF or short animation, that links directly to the "codec" after showing an alert.

If WMP actually loads a video and asks for a codec, then it's a legit video.

Personally, I have yet to encounter any video that I don't have a codec for. K-Lite is PRETTY thorough.It asks for a special codec, then the installer runs. It was in WMP. WIERD.
5359.

Solve : How can I detect if a batch file is started as admin??

Answer»

How can I detect if a batch file is started as administrator?
Can you give us some more information?You know in Vista or Windows 7 where you click Run as Administrator, well I wanna detect if the user has clicked that on the batch file.
You COULD check your event log.Quote from: Quantos on January 09, 2010, 12:59:22 PM

You could check your event log.

No I mean check admin from within the batch file.
..Code: [Select]
if "%username%"=="Administrator" (
echo User is Administrator
) else (
echo User is not Administrator
)


Quote from: SALMON Trout on January 09, 2010, 02:38:02 PM
Code: [Select]
if "%username%"=="Administrator" (
echo User is Administrator
) else (
echo User is not Administrator
)

That ony APPLIES to the Administrator account. I ASSUME the OP wants to make sure the user has RUN the batch as an administrator. Although I have 0 experence in this, I use XP.

Quote from: Helpmeh
That ony applies to the Administrator account. I assume the OP wants to make sure the user has RUN the batch as an administrator. Although I have 0 experence in this, I use XP.

In that case, Vista & 7 have the whoami command. Type whoami /? at the prompt for full information.
Quote from: Salmon Trout on January 09, 2010, 05:54:54 PM
In that case, Vista & 7 have the whoami command. Type whoami /? at the prompt for full information.

Well isn't that neat. Can you post it? I don't have vista or 7 so I can't SEE for myself. Quote from: Helpmeh on January 09, 2010, 06:00:00 PM
Well isn't that neat. Can you post it? I don't have vista or 7 so I can't see for myself.
I don't know if this is what you are looking for, Google works great though Quote from: Quantos on January 09, 2010, 06:03:51 PM
I don't know if this is what you are looking for, Google works great though
Spot on quantos!
5360.

Solve : error message: Bad command or file name?

Answer»

The OP is definetely claiming that you are using more than one profile.
Thus the crack pipe comment.

I don't know you well, but I know you well enough to know that you wouldn't demean yourself like that in a thread.Quote from: Quantos on January 10, 2010, 02:27:17 AM

The OP is definetely claiming that you are using more than one profile.
Thus the crack pipe comment.

I don't know you well, but I know you well enough to know that you wouldn't demean yourself like that in a thread.

Hmmm. I have been thinking about my reply just now; I think it would have been more accurate for me to STATE that I once was called "Dias de Verano" on here, then I went away, eventually I came back some months later and chose the name "Salmon Trout" (A British steam locomotive of the 1920s) but I have never had more than 1 account active at any one time. I cannot see the point of it; to use them both in the same thread would be like talking to yourself compared to a genuine conversation, or like *censored* compared to, er... (Well you get my drift) Only a crazy person would do such a thing. I believe I have made myself as clear as is necessary?

On the other hand it COULD be fun...

[newboid1999] How can I get a list of all folders that start with the letter A?

[Salmon Trout] Why, newboid, just put this in your batch FILE! dir /s /ad B*

[newboid1999] Gee, thanks, Salmon! It works like a dream!

[Salmon Trout] Think nothing of it old fellow.

[newboid1999] Salmon, you're a GENIUS!

[Salmon Trout] Calm down! People will get suspicious.

[newboid1999] Oh. Er, right.

Quote from: Salmon Trout on January 10, 2010, 02:54:38 AM
... Only a crazy person would do such a thing....

On that note, maybe you would.
*ducks*Quote from: Quantos on January 10, 2010, 08:32:32 AM
On that note, maybe you would.
*ducks*

What physicist was it who told a student, "Your theory is crazy, but not crazy enough to be true" ?
Quote from: Salmon Trout on January 10, 2010, 08:38:53 AM
What physicist was it who told a student, "Your theory is crazy, but not crazy enough to be true" ?

That would be Niels Bohr.Ah, the AMBIGUITY. Can one be sure of anything?
5361.

Solve : Rename/replace?

Answer»

Quote from: Geek-9pm on January 10, 2010, 08:49:37 PM

Doing DIR /? gives the list of options.
It states you give the file name first and follow with the switches.
So why not try it the recommended way?
Using a feature that is not given in the documentation is not wise, unless you have a reason for it.
(So you just want to see what happens?)



The result is still the same. I get the same error message.
Sorry that did not help.
I am just shooting in the dark. That is why I am the Geek after dark.
You need the /s to get all sub directories. -Right?
Well, just move the DIR thing out of the for loop.
I have been following this third, but get lost in the stuff. Do you really need recursion? Can you just use iteration? Maybe I missed something.

Could you just do DIR *.JPG /B/S >big-list.txt
Then have the for loop precess each line in big-list.txt
That way the for loop does not have to do recursion. I guess.
I am not keen on using the recursion at all. I am just looking for a way to rename my files in many directories over many backup disks. In the process of renaming I need to remove/replace some strung from the file name.

I don't need a full blown rbust solution. Just a way to reduce the manula work. The script works for a single directory and it renames the files correctly. Here is an idea a threw EARLIER today. I am reposting for easy reference.

====================================================

Since the basic code works for a directory I think the following idea might work. but I don't have the knowledge base to do the programming in shell.

1. Parameterize the basic code, ie. pass the directory path to this script.
2. Make another script to scan through the subdirectories RECURSIVELY and when a it finds a directory call the first batch file (from POINT #1) with the directory as parameter.

This code seems to rename files recursively. May be the gurus can tweak it to make it work with the above routine.

For /r %%x in (*.jpg) do ren "%%x" *.jpeg

Notice the /r switch in the FOR clause for scanning the directories recursively.
===============================================================

Thanks,
myshutterclicks




Quote from: Geek-9pm on January 10, 2010, 09:13:08 PM
Sorry that did not help.
I am just shooting in the dark. That is why I am the Geek after dark.
You need the /s to get all sub directories. -Right?
Well, just move the DIR thing out of the for loop.
I have been following this third, but get lost in the stuff. Do you really need recursion? Can you just use iteration? Maybe I missed something.

Could you just do DIR *.JPG /B/S >big-list.txt
Then have the for loop precess each line in big-list.txt
That way the for loop does not have to do recursion. I guess.

Nobody gets any points for astuteness, perspicacity or just plain gumption here! None of you noticed that the OP posted the same number of error messages as there were files. Therefore, the problem was occurring in the loop, not in the FOR line which set it up.

Also, nobody bothered (come on guys!) to type rename /? at the prompt and read the help, whereupon it would have become clear where the problem lies.

Namely in the incorrect syntax being used with the ren / rename command.

The syntax is

Code: [Select]RENAME [drive:][path]filename1 filename2
The code was doing this

Code: [Select]RENAME [drive:][path]filename1 [drive:][path]filename2
To give a concrete example

This is wrong

Code: [Select]Rename "C:\My Documents\My Pictures\My Meals\Cheeseburger105.jpg" "C:\My Documents\My Pictures\My Meals\Hamburger105.jpg"
This is right

Code: [Select]Rename "C:\My Documents\My Pictures\My Meals\Cheeseburger105.jpg" "Hamburger105.jpg"
When you have to specify the full path of a file to rename, e.g. because it is not in the current directory, supply it once, before the present (old) filename and then supply just the new name (no path).

It actually says this in the rename /? help

Code: [Select]Note that you cannot specify a new drive or path for your destination file.
Dir /s /b always produces a full path for each file, so you need to get at the drive, path, name and extension information using the FOR variable modifiers which you can read about in the FOR /? documentation

Here is some commented code which (I hope) will make all this clear...

Code: [Select]
@echo off

REM You need this because you are setting variables (and reading them)
REM inside a parenthetical structure (a loop in this case)
setlocal enabledelayedexpansion

REM The /f switch tells FOR to treat the output of the command
REM as a series of text lines to be processed
REM I have changed the variable to upper case to make
REM the variable modification clearer
for /f "delims=" %%A in ('dir /s /b *_MG_*.JPG') do (

REM If %%A is a file path and name (or just a filename)
REM %%~dpA is its drive and path...
set filepath=%%~dpA

REM ... and %%~nxA is its name and extension
REM Thus we have removed the drive and path...
set filenameold=%%~nxA

REM Modify just the name without path
REM to get the new name
set filenamenew=!filenameold:_MG_=!

REM Give the Rename command the full path & old name
REM for the file to be renamed, and just the new name
rename "!filepath!!filenameold!" "!filenamenew!"
)


Since we have now got up to 7 pages, I feel justified in having a moan about how standards are slipping here on CH. Somebody posts a question, somebody else (who shall be nameless) posts a partial solution, the OP tries it out, it doesn't work, and then a whole bunch of people just post guesses. Nobody read the command documentation; nobody tried specimen code.

Quote from: Salmon Trout on January 11, 2010, 01:26:10 AM

Since we have now got up to 7 pages, I feel justified in having a moan about how standards are slipping here on CH. Somebody posts a question, somebody else (who shall be nameless) posts a partial solution, the OP tries it out, it doesn't work, and then a whole bunch of people just post guesses. Nobody read the command documentation; nobody tried specimen code.


Hi Salmon,

I just tried your code and it works like a charm. I cannot thank you enough for this. It's definitely going to save a lot of time for me.

Your attention to the details and understanding of the problem are great and I am sure you enjoy a healthy dose of success and satisfaction in your daily LIFE. I wish you great success as well.

I am a photographer and I know a bit about it. Do not hesitate to get in touch with me if you need any tips about photography.

Great forums. Keep up the good work.

Lifespan of one's residue is mostly determined by what one does for common good throughout one's lifetime.

Best regards,
http://www.kankooz.com
5362.

Solve : using a batch file to read a directory to start/stop programs within that dir?

Answer»

how do I do this?
There is a father folder with several child folders within it.
I want to :
1. get the name of the first child folder
2. modify the PATH name of a second BATCHFILE by inserting the child folders name into it.
3. execute the modified second batch file name.
4. if there are more child folders go to 1.
5. else end
In EFFECT the first batchfile executes a PROGRAM which will then execute a program within each of the child directories

5363.

Solve : Start a batch file as a different user??

Answer»

Now normally I am usually fine with this sort of thing...but I'm hitting wall here and I need help. I am trying to run one batch file from another batch file, but the batch file being ran from the other needs to be run from a different user on the network. So here is the pseudo-code.

bf1.bat
Code: [Select]@echo off
start bf2.bat as User password
bf2.bat
Code: [Select]@echo off
echo info. > Z:\file.txt
type Z:\file.txt
pause > nul
exit
It may help if you know my reasoning. Each user on the network has his/her own Z drive. The Z drive is just a mapped drive to I:\_%username%. The users have read-only priviliges on I:\_Common. Because I need write capabilities, that is not useful to me. The only place each user has read/write capabilities is on their Z drive (I:\_%username%). All the other folders in the drive have no access (so you can't access another user's Z drive). I will have a specific file on my Z drive, that I need all the users running my batch file to be able to access (with read and write). The only way to acomplish this is to run the batch file as the specific user, but is there a way to automatically do it?

Bonus points: If this is even possible it would be better. If I could keep bf2.bat in my Z drive, and the users are just running it from bf1.bat (within I:\_Common) then I wouldn't have to REALLY worry about my source and I could modify it without having someone with full read/write privilages swap it around. have you tried runas?"When prompted, type the administrator password."
The users who will be running this will not know the password (the reason for the batch file in the first place) and I can't find anything on the PAGE about auto-inputting the password.

Thanks for the idea ghostdog...we're on the right track. How many users?
Why not just deploy the file to all of your users?Quote from: Geek-9pm on January 10, 2010, 10:23:57 PM

How many users?
Why not just deploy the file to all of your users?
Same file needs to be accessed by ALL users. The content changes quite often. Quote
Same file needs to be accessed by ALL users.
The content changes quite often.

Fine. Yes you can find a way to do that.
Is this an academic CHALLENGE?
Or is this a real-world issue that needs a PIRATICAL solution?

These question are posed here because Academic challenges too often focus on a narrow area whee the students are pushed into an answer the teacher wants. But the Piratical answers are found by thinking "outside the box", metaphorically speaking.This is not an adademic challenge. It would be more "piratical" so-to-speak.
What I am attempting to do is in a way, use the Z drive as a server.
5364.

Solve : Auto pass credentials in AT command?

Answer»

Dear Experts,
How to auto PASS the credentials(username & password) of remote COMPUTER in AT COMMAND,

my command is,
At \\
D:\&GT;at \\WRCP7F0BCU22 16:50 /INTERACTIVE /every:m,t,w,th,f,s,su d:\windows\calc.
exe
Access is denied.

Thanks in advance,

5365.

Solve : Renaming Specific Part Of File?

Answer»

Hi Every 1

I m Back With another Mad Query

If My FILES are named as

00000000.ogg
00000001.ogg
00000002.ogg
and so on....

I want 2 Rename it as

Test.zip_00000000.ogg
Test.zip_00000001.ogg
Test.zip_00000002.ogg
and so on

then WAT should b my BATCH file

5366.

Solve : How I can make batch file that will save list of my folders to txt file?

Answer»

How I can make BATCH file that will save list of my folders to txt file
C:\>type listDirec_astxt.bat

Code: [Select]@ echo off
cd \
dir /B /AD > direc_txt.txt
rem dir /s /B /AD > direc_txt.txt
type direc_txt.txt
Output:
C:\>listDirec_astxt.bat


app
app program
batch
bat_extra
bin
boot
cname
DECCHECK
DELL
Documents and Settings
drivers
HPDESK
jpeg
MSOCache
mydirectory
oldbat
orig
Program Files
program1
RECYCLER
TEMP
test
tmp1
tmp2
WINDOWS
.
.
.

C:\>wow, so fast!!! thanks a lot!

now I need some EXPLANATION...

it's work in root directory and how I can do same thing with "c:/windows/system" for example?Quote from: alechko on January 08, 2010, 11:59:30 AM

wow, so fast!!! thanks a lot!

now I need some explanation...

it's work in root directory and how I can do same thing with "c:/windows/system" for example?
After the /AD in the dir command, add your desired path. Bill's just goes through all the folders of the systemdrive. Quote from: alechko on January 08, 2010, 11:59:30 AM
Now I need some explanation...
It's work in root directory and how I can do same thing with "c:/windows/system" for example?

you must cd to: C:\WINDOWS\system

The following is not a batch but the information is directly from the command line


rem wc -l counts the number of directories. I use XP pro and
rem C:\WINDOWS\system has no sub directories on my machine

C:\WINDOWS\system>dir /B /AD | wc -l
0

C:\WINDOWS\system>cd ..

C:\WINDOWS>dir /B /AD | wc -l
120

C:\WINDOWS>dir /s /B /AD | wc -l
1879

C:\WINDOWS>

p.s. You may run the above without : " | wc -l"please make batch file for me, I don't understand how this work...
I need list of all folders in specific directory.
please explain how I can change directory too.

thanks!Quote from: alechko on January 11, 2010, 03:01:26 AM
please make batch file for me, I don't understand how this work...
I need list of all folders in specific directory.
please explain how I can change directory too.

thanks!
Use the code in reply #1 and read what I said in reply #3. hi, I make batch file from first reply it's work only in root, i trying to run in in other directory but not successfully...

I need batch file where I can set path to directory that I need... I dont' understand your second reply.Quote from: alechko on January 08, 2010, 07:42:44 AM
How I can make batch file that will save list of my folders to txt file
try this syntax: short and simple and i'll also add my comments for help..
DIR ; creates a list of files in a folder
c: ; identifies the files to be listed in this instance it will list all folders in your c:drive you can ammend it by drawing file as well ie. *.doc
/s ; indicates that the search should include all subdirectories
/b ; indicates the list should be bare , only including the filename and LOCATION
> ; directs the output to a file
c:\list.txt ; creates a file with this name and places the output of the dir command into it.


**this is run from the dos prompt if you go to start run and type cmd in the text box you'll get there. Type the complete syntax on one line with the directory that you are wanting to create your list from. example:
DIR c: /s /b > c:\list.txtQuote from: alechko on January 11, 2010, 04:50:39 AM
hi, I make batch file from first reply it's work only in root, i trying to run in in other directory but not successfully...

I need batch file where I can set path to directory that I need... I dont' understand your second reply.
see my post below and you can change it to any directory that you want. for example p:

C:\>type listdir.bat
Code: [Select]@ echo off
cd c:\windows\system
dir /B /AD | wc -l
echo no sub directories under "c:\windows\system"
cd c:\windows\
dir /B /AD | wc -l
dir /B /AD > direc_txt.txt
rem dir /s /B /AD > direc_txt.txt
type direc_txt.txt
Output:

C:\>listdir.bat
0
no sub directories under "c:\windows\system"
$
$NtUninstallKB960803$
.
.
.

addins
AppPatch
assembly
CAVTemp
Config
Connection Wizard
Corel
Cursors
Debug
Downloaded Installations
Downloaded Program Files
Driver Cache
ehome
Fonts
Help
HPSETUP
ie8
ie8updates
ime
inf
Installer
java
L2Schemas
Media
Microsoft.NET
msagent
msapps
msdownld.tmp
mui
Network Diagnostic
Offline Web Pages
pchealth
PeerNet
Performance
PIF
Prefetch
Provisioning
pss
Registration
repair
Resources
security
setup.pss
ShellNew
SoftwareDistribution
srchasst
Sun
system
system32
Tasks
Temp
twain_32
WBEM
Web
WinSxS

C:\WINDOWS>dir DIRECTORY_OF_FOLDER\*.* /b >list.txt


for ex

dir E:\Test\Test001\*.* /b >List.txt

Text file will b saved FRM wer batch file was ranQuote from: the_mad_joker on January 12, 2010, 08:09:54 AM

dir E:\Test\Test001\*.* /b >List.txt

Text file will be saved from where batch file was run.

"Text file will be saved from where batch file was run."

With the exception:

When there is a cd command to a new directory at the beginning of batch.
5367.

Solve : DOS 6.22 etc?

Answer»

Please, the code to enabling LPT1 printing device. AUTOEXEC.BAT?

I use DOS 6.22 and XP for running ny VBDOS(1P)-written programmes.
Of the latter, "Direct Access 5" is necessary.
Then to change the HUE of the screen, I use "PRISM".

Thansk for your help.Quote from: KRAUSS on January 12, 2010, 10:45:52 AM

Please, the code for enabling LPT1 printing device.


http://geekswithblogs.net/dtotzke/articles/26204.aspx

( All the following information from the above link. I have not used or tested the information.) Good luck

"In order to print from DOS in an offline environment, you will need to do a couple of things."



1) Install the Microsoft Loopback Adapter

a) In Control Panel, double click on Add Hardware.

b) Click Next

c) When the scan finishes, select "Yes, I have already connected the hardware"

d) Click Next

e) Scroll to the bottom of the list and select "Add a NEW hardware device"
Click Next

f) Select "Install the hardware that I manually select from a list (Advanced)"

g) Click Next

h) Select "Network Adapters"

i) Click Next

j) Select "Microsoft" under the Manufacturer list.

k) Select "Microsoft Loopback Adapter" in the Network Adapter list.

l) Click Next

m) Click Next

n) Click Finish



2) Configure the Adapter

a) The loopback adapter is a virtual network adapter and can be configured the same as a regular network card.

b) Set the adapter to have a static IP address such as 192.168.1.1/ 255.255.255.0



3) Share the printer.

a) I recommend you use a share name that you will remember. I used “Printer” in the new machines that are already deployed.



4) Capture the printer port.

a) NET USE LPT1: \\[Computer Name]\Printer /PERSISTENT:YES

Now, not that I like to encourage this type of behaviour, but if you have done the above and still can't get it to print, you may find some help through one of the articles located here:

http://support.microsoft.com/search/default.aspx?mode=a&query=kbhowto+kbprint+dos&spid=global&catalog=LCID%3D1033&1033comm=1&res=20

Get Help Now
Contact a MS support professional by E-mail, Online, or Phone

http://support.microsoft.com/common/international.aspx?RDPATH=dm;en-us;select&target=assistance
5368.

Solve : Can this be done??

Answer»

I have to move a file (I'll call it file.txt) from one folder to another on approximately 500 PCs. I'm wondering if a batch file can be written that could be run on each PC by the user rather than me have to do each one manually. three folders on each PC contain a file.txt and each one is a different size

c:\profiles\folder1\file.txt
c:\profiles\folder2\file.txt
c:\profiles\folder3\file.txt

I need to copy the largest of the 3 to another location. The problem is that folder1, folder2, folder3 are going to be named differently on every PC. Is it possible to write a batch file that can look into all subfolders of c:\profiles and copy the largest file.txt to another location? Adjust the paths/filenames to suit - not tested, no allowance made for paths/filenames containing spaces. Hope it helps.

Code: [Select]@echo off>%temp%\dir.txt
cls

setlocal

dir /s /b c:\profiles\file.txt >%temp%\dirfil.txt

for /f "delims=*" %%1 in (%temp%\dirfil.txt) do (
echo %%~zf1>>%temp%\dir.txt
)

sort /R < %temp%\dir.txt > %temp%\dirsorted.txt

for /f "tokens=2" %%1 in (%temp%\dirsorted.txt) do (
copy %%1 Outfilepath\ >nul & goto :end
)

:end
exit/b

Good luck.Quote from: T.C. on January 11, 2010, 04:01:11 AM

Adjust the paths/filenames to suit - not tested, no allowance made for paths/filenames containing spaces. Hope it helps.

Code: [Select]@echo off>%temp%\dir.txt
cls

setlocal

dir /s /b c:\profiles\file.txt >%temp%\dirfil.txt

for /f "delims=*" %%1 in (%temp%\dirfil.txt) do (
echo %%~zf1>>%temp%\dir.txt
)

sort /R < %temp%\dir.txt > %temp%\dirsorted.txt

for /f "tokens=2" %%1 in (%temp%\dirsorted.txt) do (
copy %%1 Outfilepath\ >nul & goto :end
)

:end
exit/b

Good luck.
It will just crash. One thing I noticed in the for loop, %%1? It needs to be a letter (uppercase and lowercase are different). And what's with @echo off>%temp%\dirfill.txt? It's unnessasary. That file gets created in the dir command anyway. Quote from: Helpmeh on January 11, 2010, 04:40:06 AM
One thing I noticed in the for loop, %%1? It needs to be a letter

It is an undocumented fact that you can use %%0 to %%9 and some other characters too; (? # $ _ for example) although the FOR documentation says a-z and A-Z and says you can only have 52 variables existing at once.

Code: [Select]for /f "tokens=1-3 delims= " %%0 in ("cat DOG horse") do @echo %%0 %%1 %%2
Code: [Select]cat dog horse


Quote from: T.C. on January 11, 2010, 04:01:11 AM
Adjust the paths/filenames to suit - not tested, no allowance made for paths/filenames containing spaces. Hope it helps.

Code: [Select]@echo off>%temp%\dir.txt
cls

setlocal

dir /s /b c:\profiles\file.txt >%temp%\dirfil.txt

for /f "delims=*" %%1 in (%temp%\dirfil.txt) do (
echo %%~zf1>>%temp%\dir.txt
)

sort /R < %temp%\dir.txt > %temp%\dirsorted.txt

for /f "tokens=2" %%1 in (%temp%\dirsorted.txt) do (
copy %%1 Outfilepath\ >nul & goto :end
)

:end
exit/b

Good luck.

That works just like i need it too but when i try to change the path from c:\profiles to the actual path where the file RESIDES I'm having trouble. the filename is actually user.aco (not file.txt as i said earlier) and it exists in these folders:

C:\Documents and Settings\All Users\Application Data\myco\MQ1\Cache\User Profiles\92606\7354904
C:\Documents and Settings\All Users\Application Data\myco\MQ1\Cache\User Profiles\92689\8459875
C:\Documents and Settings\All Users\Application Data\myco\MQ1\Cache\User Profiles\123456\6546544

The last 2 numeric folders are going to be diferent on each PC and the largest user.aco needs to be copied to c:\program files\myco


Thanks for the help so far. Could you help me get the rest of the way?



Quote from: T.C. on January 11, 2010, 04:01:11 AM
Adjust the paths/filenames to suit - not tested, no allowance made for paths/filenames containing spaces. Hope it helps.


Good luck.
is there a way to make allowance for path containing spaces? Forgive me for being so dumb. DOS is definitely not my strong suit but it would be a huge help if I could get this worked out.Quote from: aschrier on January 11, 2010, 08:08:46 PM
is there a way to make allowance for path containing spaces?

Quote marks

"C:\Path with\some spaces\"

Quote from: helpmeh
It will just crash. One thing I noticed in the for loop, %%1? It needs to be a letter (uppercase and lowercase are different). And what's with @echo off>%temp%\dirfill.txt? It's unnessasary. That file gets created in the dir command anyway.

FYI Although it's undocumented, in a For loop the variable can be any printable ASCII/Extended ASCII code in the range dec 33 thru dec 254.

In a testing environment it is wise to ensure that any file created using redirection >> is deleted, otherwise, if the script is run more than once, data will be appended rather than the file being created with new data. @echo off>%temp%\dirfill.txt is just one way of overwriting the existing file with a zero length file. One could also use If Exist Filename Del Filename, or simply Del Filename when that file is no longer required, or any other method of removing the file.

According to the OP Quote from: aschrier
That works just like i need it too
the script did not "just crash" but appears to have been helpful.

aschrier - Salmon Trout has already advised on paths/filenames containing spaces.

Again - Good Luck.
Quote from: T.C. on January 12, 2010, 12:43:26 AM
FYI Although it's undocumented, in a For loop the variable can be any printable ASCII/Extended ASCII code in the range dec 33 thru dec 254.

These are the ONES you can't use

34 37 38 44 59 60 61 62 124

Method

Code: [Select]
Set fso = CreateObject("Scripting.FileSystemObject")
Set Shell = CreateObject("Wscript.Shell")
For c = 33 To 255
WriteFileName="test" & CStr(c) & ".BAT"
Set TextFile = fso.OpenTextFile (WriteFileName, 8,True)
Textfile.WriteLine("@for /f " & Chr(34) &"delims= " & chr(34) & " %%" & Chr(c) & " in (" & chr(34) & "cat Dog horse" & chr(34) & ")" & " Do @Echo %1 %%" & Chr(c) & ">> report.txt")
Textfile.Close
Shellstring="%comspec% /c " & WriteFileName & " " & CStr(c)
Shell.run ShellString,2,1
Next
Set fso = Nothing
Set Shell = Nothing


Quote from: S T
These are the ones you can't use

34 37 38 44 59 60 61 62 124

Did you try Escaping the chars?

Code: [Select]@echo off
setlocal
cls

echo character_used>%temp%\trial.txt

for /f %%^" in (%temp%\trial.txt) do (
echo %%^" (double quote^) is chr dec 34)

del %temp%\trial.txt

Quote from: T.C. on January 12, 2010, 02:10:15 PM
Did you try Escaping the chars?

Escaping brings the ones that don't work down to these: 37 ( % ) 38 ( & ) 44 ( , ) 59 ( ; ) 61 ( = )
5369.

Solve : Impressionable Variables and Game Making With Batch.?

Answer»

Hello. this is my first POST, and I came here to try to learn how to make impressionable variables (like a characters hp and MP, or stats), and any other batch game MAKING tips. Please help.Well, learn the SET command (set /?), and learn to use
Echo TEXT %VARIABLE% &GT; FILE
Set /p VARIABLE=<FILE

5370.

Solve : Calling up another batch file?

Answer»

How do I created a batch file that calls up another batch file if I type a name in the first batch file?Quote from: henksey on January 12, 2010, 08:40:03 AM

How do I create a batch file that calls up another batch file if I type a name in the first batch file?


C:\batch>type twobatch.bat
Code: [Select]@echo off

call batch_1.bat
echo return to main after batch one
call batch_2.bat

echo return to main after batch two

pauseC:\batch>type batch_1.bat

Code: [Select]echo DATABASE backup
rem rman target user/pwd @<path_to_file_to_run> log <path_to_log_file>
exit /b
C:\batch>type batch_2.bat

Code: [Select]echo CommVault backup

REM qlogin -cs "server_name" -u "user" -p "pwd"

exit /bOUTput:

C:\batch> twobatch.bat
Database backup
return to main after batch one
CommVault backup
return to main after batch two
Press any key to continue . . .
C:\batch>I have a distinct feeling that's not what he meant by 'type', Bill...
Thanks Bill. I really appreciate your reply. is there a more simple way of creating this type of batch. I am very very NEW at this, and i'm not understanding all your commandsI was talking about typing in the echo screen that comes up a name of another batch file to call it up. Something that says; " Type in name, then click on any key" once I do that then another specfic batch would open.You want set /p for that
hello I mis-stated my 1st question. So i'll restate it; How do I created a batch file that calls up another batch file, by typing the name in the 2nd batch file and then clicking on a key to bring it up? Trout, could you give me an example?

Thanks@echo off
set /p batchname=Batch name:
call "%batchname%"

Quote from: henksey on January 12, 2010, 09:33:58 AM
Could you give me an example?


C:\batch>type st.bat
Code: [Select]@echo off
echo Enter name of batch file.
set /p x=

call %x%
echo return to main after batch one

echo Enter name of batch file.
set /p y=

call %y%

echo return to main after batch two

pause
Output:

C:\batch>st.bat
Enter name of batch file.
batch_1.bat
Database backup
return to main after batch one
Enter name of batch file.
batch_2.bat
CommVault backup
return to main after batch two
Press any key to continue . . .
C:\batch>Thanks S.T., I think this will workC:\batch>call /?
Calls one batch program from another.

CALL [drive:][path]filename [batch-parameters]

batch-parameters Specifies any command-line information required by the batch program.

_________________________________

Keep in mind that the subBatch must contain the exit /b command for control to return to the main Batch.
For example:

echo in CommVault backup

REM qlogin -cs "server_name" -u "user" -p "pwd"

exit /bQuote from: BillRichardson on January 12, 2010, 10:05:50 AM

Keep in mind that the subBatch must contain the exit /b command for control to return to the main Batch.


Not exactly. When a CALLED batch terminates naturally (i.e. reaches the last line of code), control is passed back to the CALLING batch, which proceeds to the line FOLLOWING the call command. There is no need for the last line to be exit /b. However the exit command with the /b switch is useful for situations where you need to exit before the end of the batch is reached. The /b switch prevents a complete exit from cmd.exe.




Quote from: Salmon Trout on January 12, 2010, 01:12:03 PM
Not exactly. When a called batch terminates naturally (i.e. reaches the last line of code), control is passed back to the calling batch, which proceeds to the line following the call command. There is no need for the last line to be exit /b. However the exit command with the /b switch is useful for situations where you need to exit before the end of the batch is reached. The /b switch prevents a complete exit from cmd.exe.





Yeah or use

GOTO EOF
commands
:EOF
5371.

Solve : Determine Day of Week?

Answer»

Quote from: nothlit on January 07, 2010, 02:10:09 PM

Such LOVE, thanks for all the information and the replies.


Downloads GNU

Wait! There's more!


Don't you want the list of links with batch files the go on and on?Calculating the day of the week

Here's wikipedia's algorithm, seem to work and I think you can use it in any common language (C, C++, etc), you just need the right syntax corresponding to the language you want to get the program to do the math.Quote from: Geek-9pm on January 06, 2010, 09:48:54 PM
I was just JOKING about the new moon

BC, you are making this harder than it needs to be. Years ago I did this sort of thing in assembler. There is a call in DOS that gives you what you need to know about the current date. Don't remember what it was, but it is also somewhere in the Visual Basic library. But just invoke DATE at the port or in a batch and it tells all. Somebody else showed how to parse the strings and SEPARATE it into the components.


you can't call DOS INTERRUPTS from NT's command line, and you can't parse strings in standard DOS batch files.Quote from: Geek-9pm on January 07, 2010, 04:06:39 PM

Wait! There's more!


Don't you want the list of links with batch files the go on and on?


I enjoy free information and tools so if there is more by all means please share.
5372.

Solve : .?

Answer»

Quote from: pchelp on JANUARY 13, 2010, 06:48:00 PM

so i want to KNOW how to PROGRAM but sometimes...
...when people say things can be used for malicious intent, and there is no LEGITIMATE REASON to learn how to make critical errors, maybe you should heed their advice and stop repeating the same thing over and over.

Just because you "love to program" doesn't mean we're going to teach you how to prank your buddy. I suggest you read up on the forum rules (which by registering, you agreed to follow) before posting again.Ask BC programmer in a nice way and he will show you how to make a box come up on the screen from the command line.
You CREATE the program musing another programming tool.
The the batch file will invoke the new program you make.

Hate to quote myself too:
Quote
From the few posts made by pchelp I get that nagging gut-feeling that we have another wouldbe writer of malicious scripts among us. Individually each post seems a genuine quest for info but put together... Just a feeling
from here..

5373.

Solve : Installing DOS on Sata drives?

Answer»

I have a Dos 7 install CD.
I just bought a new Sata Motherboard, and drives, and my DOS install won't find my Drives.
?Any Ideas how to GET around this?Install the MBoard SATA drivers 1st...re-boot and try again.DOS cannot use SATA. You'll need to set your SATA CONTROLLER to compatibility MODE in the BIOS.

5374.

Solve : Mistaking In Batch?

Answer»

Hi Every 1
I m Mistaking Sumwhere in this batch

I Wanna Make A batch File to choose Either Yes Or no
Code: [SELECT]@echo off
color 0c
echo Type Either Yes Or No
set /p tp = :
IF %tp% equ yes GOTO ONE
IF %tp% equ no GOTO TWO
:ONE
cls
echo.
echo.
echo You Pressed Yes
echo.
echo.
pause
:TWO
cls
echo.
echo.
echo You Pressed no
echo.
echo.
pause
And Specially I wanna know After inserting Yes or no How 2 delete all Files in same folder I'm surprised a self described Guru such as yourself would need assistance with such a trivial matter. You have to write defensive code. No matter what the prompt says you never know what a user may actually type. Be a Boy Scout and be prepared.

Code: [Select]@echo off
color 0c
:tryagain
setlocal
set /p tp=Type Either Yes Or No:
IF /i .%tp% equ .yes GOTO ONE
IF /i .%tp% equ .no GOTO TWO
goto tryagain

:ONE
cls
echo.
echo.
echo You Pressed Yes
echo.
echo.
pause
goto :end

:TWO
cls
echo.
echo.
echo You Pressed no
echo.
echo.
pause

:end
endlocal

You GAVE no paths, so I leave it to you for the delete instruction. (del path\*.*). FYI: if the batch file path is the same as where the files to be deleted live, you'll end up deleting your own batch code.

Quote

And Specially I wanna know After inserting Yes or no How 2 delete all Files in same folder

If you're going to delete files whether the answer is yes or no, why bother asking?



>:(Hey SideWinder You Dont Know Something about Ur-Self



U R THE BEST!!!!! Thanks For The Help! I Wish You A Long Life

Thanx For The Help

Topic Closed Quote from: Sidewinder on January 29, 2010, 06:22:35 AM

If you're going to delete files whether the answer is yes or no, why bother asking?


Or in other threads "COMPUTER Experts" check to see if a certain file exists? If the file does not exist, the the OS will report that! Why check? If we try to create a file and it already exists, the OS will not allow it. So why go through the above procedure? A waste of time.Quote from: BillRichardson on January 29, 2010, 09:39:21 AM
Or in other threads "Computer Experts" check to see if a certain file exists? If the file does not exist, the the OS will report that! Why check? If we try to create a file and it already exists, the OS will not allow it. So why go through the above procedure? A waste of time.

checking to see if a file exists is a good idea if you plan to read from the file. If the file exists, you read the values from it; otherwise, you use the default values. If you don't check and INSTEAD blindly try and read, the values will not have the intended default values.

Or, in the case of an actual windows program, you'll crash when you try to use a file handle that doesn't exist (createfile will return -1 and getlastError() will be 2) and unless you check the handle (which is basically checking if the file exists, which as you've said we shouldn't be doing) then you'll try to read or write to a file handle of -1, which is not valid.Quote from: BillRichardson on January 29, 2010, 09:39:21 AM
Or in other threads "Computer Experts" check to see if a certain file exists? If the file does not exist, the the OS will report that! Why check? If we try to create a file and it already exists, the OS will not allow it. So why go through the above procedure? A waste of time.

Please explain more. The OP is deleting files, not creating them and is using a wildcard. The OP simply WANTS to empty a directory.

Quote from: the_mad_joker on January 29, 2010, 01:43:59 AM
And Specially I wanna know After inserting Yes or no How 2 delete all Files in same folder

Quote from: Sidewinder on January 29, 2010, 06:22:35 AM
If you're going to delete files whether the answer is yes or no, why bother asking?

The question remains. If the logic is to delete the files no matter what the response to the prompt is, why bother with the prompt at all?

PS. This is how threads turn into 5 page marathons that have nothing to do with anything.. The OP never mentioned creating files or reading from files.
I have a headache...
5375.

Solve : batch file to start then stop a program?

Answer»

Hi,

I am trying to write a batch file to start two programs and then stop one of the programs say after 5-10 seconds.

this is what i have so far

@echo off
start "title" "c:\program files\file 1"
start "title" "c:\program files\file 2"

then i would like to kill "file 1" after "file 2" has fully LOADED but not sure how to.
can anyone help?

thanks, phil
Try looking at
tskill /?

If they both open up in the same program, then it might be a little bit more challenging.file 1 is an EXECUTABLE file and file 2 is a seperate executable file.Did you read what I said you to read?


So, this would be your code...

start "" program1.exe
start "" program2.exe
tskill program1
rem MAKE sure to leave out the .exe in the tskill command.I did look up tskill, i cant get that too close my program down though, Quote from: mrphil on January 28, 2010, 05:24:42 PM

I did look up tskill, i cant get that too close my program down though,
Try this:

Run tasklist (from the command prompt). Locate your program. That (minus the .exe) is what you add after the TSKILL in your batch file.

If you don't have tasklist, check you've typed the proper process name.

What is the exact error you get when you run Tasklist [processname]?No error, but program is not stopping after i run the batch file. the batch file starts both programs fine but tskill is not being recognized and doesnt stop the first program. Quote from: mrphil on January 28, 2010, 04:09:53 PM
Then I would like to kill "file 1" after "file 2" has fully loaded but not sure how to.
Can anyone help?


C:\batch>type mrphil.bat

Rem Usage: mrphil.bat title ( program name )
Code: [Select]@echo off

echo hello > c:\batch\file1.txt

echo hello > c:\batch\file2.txt

start %1 c:\batch\file1.txt > nul
echo start file2
start %1 c:\batch\file2.txt


tasklist | findstr "%1" > killpid.txt


for /f "tokens=1,2 delims= " %%i in (killpid.txt) do (
echo pid=%%j

taskkill /pid %%j
exit /b

)
Output:


C:\batch>mrphil.bat notepad

C:\batch>Rem Usage: mrphil.bat title ( program name )
start file2
pid=496
SUCCESS: Sent termination signal to the process with PID 496.

C:\batch>Bill, nul =/= null.
Quote from: Helpmeh on January 28, 2010, 05:46:58 PM
Bill, nul =/= null.

How does that change post#7 ?

Yes, you are right I created a file called null.

I meant to send to nul.

It did not change the output.

____________________________________

It might be of interest that the "exit /b" is necessary INSIDE the for loop.
There are two processes with the same name and we need to kill only the first process.

QED

p.s. Major assumption: When the same program is listed twice with Tasklist, we assume the first process is listed first.
5376.

Solve : Configuring ADSL modem from command prompt?

Answer»

Dear ipconfig masters , I want to configure my wire LAN connected ADSL modem from command prompt to access internet via wire connected broadband . I have to configure the IP address , gateway , DNS , enable DHCP . How can it be done from command prompt, please ?
With regards spdCHF.Quote from: spdCHF on January 28, 2010, 09:29:11 AM

I have to configure the IP address , gateway , DNS , enable DHCP .


C:\>ipconfig /?

USAGE:
ipconfig [/? | /all | /renew [adapter] | /release [adapter] |
/flushdns | /displaydns | /registerdns |
/showclassid adapter |
/setclassid adapter [classid] ]

where
adapter Connection name
(wildcard characters * and ? allowed, see examples)

Options:
/? Display this help message
/all Display full configuration information.
/release Release the IP address for the specified adapter.
/renew Renew the IP address for the specified adapter.
/flushdns Purges the DNS Resolver cache.
/registerdns Refreshes all DHCP leases and re-registers DNS NAMES
/displaydns Display the contents of the DNS Resolver Cache.
/showclassid Displays all the dhcp class IDs allowed for adapter.
/setclassid Modifies the dhcp class id.

The default is to display only the IP address, subnet mask and
default gateway for each adapter bound to TCP/IP.

For Release and Renew, if no adapter name is specified, then the IP address
leases for all adapters bound to TCP/IP will be released or renewed.

For Setclassid, if no ClassId is specified, then the ClassId is removed.

Examples:
> ipconfig ... SHOW information.
> ipconfig /all ... Show detailed information
> ipconfig /renew ... renew all adapters
> ipconfig /renew EL* ... renew any connection that has its
name starting with EL
> ipconfig /release *Con* ... release all matching connections,
eg. "Local Area Connection 1" or
"Local Area Connection 2"

C:\>IPCONFIG only allows you to obtail the IP address information. It also allows some control over an active TCP/IP connection.

To configure the IP settings mentioned in your post, you will need to use netsh.
5377.

Solve : Batch command to find the existance of a folder?

Answer»

Hi,
Can any one tell me
how to FIND if a folder exists in the given UNC PATH or not
using batch command

All I want to do is
1> Go to a UNC path
2> Check if folder exists
if YES copy the file from source to destination
if NO Create the folder with currentdate and then move the file

I going to the UNC path by saying
pushd %XMLFileDestination%

I am trying something like this

IF %XMLFileDestination%(
Echo FolderAlreadyExists
) else (
mkdir %date:~12,2%%date:~4,2%%date:~7,2%
Echo FolderCREATED
)

where %XMLFileDestination% is a UNC path
how about
Code: [Select]IF EXISTS %XMLFileDestination%
SORRY for the TYPO
IF Exist "%XMLFileDestination% (

this is what I am trying
its not working ((Quote from: Fire_Hope on January 28, 2010, 02:18:19 PM

IF Exist "%XMLFileDestination%" (
5378.

Solve : Batch to Rename!?

Answer»

Helloo every1

I need help with a batch file

i have all my files in E:\TEMP\000000.wav , 000001.wav... and so on

on the other hand i hav same files in E:\Test\ , Just With their names changed.! (Name Includes Hex OFfset and Hex size)

Suppose the file is 000000.wav in Temp Folder

then d Same File in Test folder will b Test.zip_000000_1a15.wav


I WANT THE BATCH 2 ....
write this stuff in text file for every file

COPY /Y ".\000000.wav" ".\Test.zip_000000_1a15.wav"So what have you DONE so far?
Quote from: SALMON Trout on January 26, 2010, 12:23:31 PM

So what have you done so far?

Cant Understand ur Meaning ST Quote from: the_mad_joker on January 27, 2010, 09:04:17 AM
Cant Understand ur Meaning ST

If you want US to help you write a batch, show us what you have done so far.

If you want us to write a batch for you, my rates start at $100 per hour.

Quote from: Salmon Trout on January 27, 2010, 11:27:04 AM
If you want us to help you write a batch, show us what you have done so far.

If you want us to write a batch for you, my rates start at $100 per hour.


U r Very Costly ST

In 100$ I cud hire an Mercenary 2 kill sum1I Think i Wrote my Query Too Long

I Just Want a Batch File Who Wud record the Names Of Files in two different folders

For Ex .

".\TECHNiC.RoX_11ed4415_0000261e.tec" ".\TECHNiC.RoX_138d5c44_0000261e.tec"
".\TECHNiC.RoX_11ed4415_0000261e.tec" ".\TECHNiC.RoX_09513b0e_0000261e.tec"

Quote from: the_mad_joker on January 28, 2010, 05:33:47 AM
In 100$ I cud hire an Mercenary 2 kill sum1

Never trust a Merc that only charges $100. The really good ones charge way more then that and would probably take you out just for the insult of only offering them $100.

Of course after they take you out they will probably take your $100 so actually you would be PAYING $100 to have some one taken out. It just wouldn't end very good for you.Quote from: mroilfield on January 28, 2010, 05:43:35 AM
Never trust a Merc that only charges $100. The really good ones charge way more then that and would probably take you out just for the insult of only offering them $100.

Of course after they take you out they will probably take your $100 so actually you would be paying $100 to have some one taken out. It just wouldn't end very good for you.
Really That Was a nice one
5379.

Solve : Copy DOS screen after it's Displayed?

Answer»

Quote from: timrob on January 24, 2010, 04:45:28 PM

Is there a way to copy a DOS screen?



They may be a limit of about 7 screens. When I scroll the screen it looks like about seven pages and the it truncates pages before that. So a screen capture would not get as much DATA as the redirection.Quote from: Geek-9pm on January 27, 2010, 01:18:09 PM
They may be a limit of about 7 screens. When I scroll the screen it looks like about seven pages and the it truncates pages before that. So a screen capture would not get as much data as the redirection.

You can edit the screen buffer size (H: chars V: lines) in the cmd window properties.Quote from: Salmon Trout on January 27, 2010, 01:24:33 PM
You can edit the screen buffer size (H: chars V: lines) in the cmd window properties.

Great! Now how do you find the pointer to the screen buffer? And is it a 32 bit absolute address? If so, you could compile a simple C# program to grab the whole thing and put it into a file. You would run it after the batch was all done. Theat way you would not have to modify the batch in any way. other that starting the screen buffer grabber at the end of the job.

Is that what he wants?

Quote from: Geek-9pm on January 27, 2010, 01:18:09 PM
They may be a limit of about 7 screens. When I scroll the screen it looks like about seven pages and the it truncates pages before that. So a screen capture would not get as much data as the redirection.

The setup for the screen shot and text capture are similar.

Then,

1) Either PrintScreen key for a screen shot.
or
2) click copy for text capture
or
3) Redirection before the text is displayed

Which method does TimRob need?Quote from: Geek-9pm on January 27, 2010, 01:32:51 PM
Great! Now how do you find the pointer to the screen buffer? And is it a 32 bit absolute address? If so, you could compile a simple C# program to grab the whole thing and put it into a file. You would run it after the batch was all done. Theat way you would not have to modify the batch in any way. other that starting the screen buffer grabber at the end of the job.

Is that what he wants?



http://msdn.microsoft.com/en-us/library/ms682073%28VS.85%29.aspxQuote from: timrob on January 25, 2010, 04:06:16 PM
Sorry, I misread your statement. I meant I wanted to capture what ever is on the DOS screen.

whatever is on the DOS screen is whatever your DOS batch program spewed out via echo statements. Therefore, you can just redirect them to a file using > or >>. The rest of what's on your DOS screen are the cmd.exe prompt, plus whatever text you type in, which I don't really know why you want to capture them as well. There used to be, sometime in the dim past, a way to redirect all console output to a serial port. Would that be a hardware method?
I think taht is still used when doing debugging on some kinds of system programs.
Quote from: Geek-9pm on January 27, 2010, 01:32:51 PM
Great! Now how do you find the pointer to the screen buffer? And is it a 32 bit absolute address? If so, you could compile a simple C# program to grab the whole thing and put it into a file. You would run it after the batch was all done. Theat way you would not have to modify the batch in any way. other that starting the screen buffer grabber at the end of the job.

Is that what he wants?


Quote from: Salmon Trout on January 27, 2010, 01:38:13 PM
http://msdn.microsoft.com/en-us/library/ms682073%28VS.85%29.aspx

Main issue being that you'd need to somehow acquire the console handle, and even then I don't think you'd have much luck, since HANDLES aren't accessible cross-process.

Quote
And is it a 32 bit absolute address? If so, you could compile a simple C# program to grab the whole thing and put it into a file.

Have you ever used C#? or programmed for the NT environment?

FIRST: it doesn't matter if you had a pointer. every memory pointer is only valid within the address space of a single process. you cannot, for example, take a handle to a string from one program and access that string in another program using that pointer; it simply doesn't work that way. Two programs can be running at the same time that have pointers that are the same but point to other items. Thus is the benefit of PROTECTED memory space and Virtualization.

Additionally, even IF that was possible C# doesn't really give you any easy way of using direct pointers. C does, though it wouldn't be simple. How would you determine the size of the buffer? you don't, your pretty much forced to guess, and chances are you'll overrun that storage area and start emitting some other stuff from elsewhere.


Quote from: Geek-9pm on January 27, 2010, 08:08:48 PM
There used to be, sometime in the dim past, a way to redirect all console output to a serial port. Would that be a hardware method?
I think taht is still used when doing debugging on some kinds of system programs.


Yes. that's still possible. If you have a checked build of windows (read: dev build). And it doesn't output "Console" data it outputs messages direct from the kernel.Thank you , BC_Programmer,
No I have not down programming is a NT environment. NT was after my days. I did assembly language in the old DOS environment . We just had to know where the segment was. I used to do this like this:
Code: [Select] ...
push cs
pop dx
...
Well, that is all i can remember, am not sure if it means anything anymore.
Quote from: Geek-9pm on January 27, 2010, 08:54:53 PM
Thank you , BC_Programmer,
No I have not down programming is a NT environment. NT was after my days. I did assembly language in the old DOS environment . We just had to know where the segment was. I used to do this like this:
Code: [Select] ...
push cs
pop dx
...
Well, that is all i can remember, am not sure if it means anything anymore.


yep, good ol' Segment:offset, IIRC; actually, although MS seems to claim otherwise in their literature, Win 9x never had a "protected memory model" you could inspect the memory of any process through ASM in a DEBUG session, I think.

being based on a "protected memory pre-emptive tasking environment" was one of the requirements MS had to meet in order to get into the government market; It's more secure for the same reasons it's more difficult to work with in some scenario's. If you could inspect a command sessions memory for the command buffer you could just as easily inspect "super high profile banking application" for passwords stored directly in variables; or, if the program is designed properly, you'd be able to inspect the memory contents after the user typed in the super ultra secure password and copy it down. Of course they are contrived examples but it prevents spyware from being used against the government too much.

On the other hand, it's still possible to inspect the memory of any process; the trick is to get a piece of code to run within that process, and then communicate (perhaps via named pipes) to the "main" process that collects the information. There are a few METHODS of injecting code into other processes, but it's rather involved. the "easy" way is to simply write a small DLL that get's loaded via the appInit_DLLs key in the registry; then there will be a DLL loaded into every single EXE process that starts, and that problem is solved; and Interprocess communication can be initiated between any process since that process will have "your" DLL loaded.To get back to the OP. You wold have to get the CMD.EXE to load another DLL that would "SPY" on the memory assignment.
In the OP, he said in a batch file. Maybe he did not know that for a one-time thing anybody can do it manually by scrolling back into the screen buffer and then select EDIT MARK COPY and then open notepad and paste it into notepad.

When he said batch. and screen capture i took him literally.

We should have asked what he might earlier.
5380.

Solve : Get Drives.?

Answer»
Hi ! to all.

I REQUEST TO MY ALL DEAR FRIEND.

i want to get all my PC's drive latter in ARRAY in to display. like i GO in DISKPART in this list volume we show all volume of drive but i want that programming to how to do this ?? Batch code can only handle text, not arrays which are objects. You can use the for command to parse the OUTPUT from this little snippet.

Code: [Select]@echo off
fsutil fsinfo drives

Good luck.

Thanks for the Replay ...

But it is possible to store in any variable ...... like in %%a or like that!!

i try FOR command but i only enter in diskpart i can't get all dive so pls help me.

Thanks.
I'm still not certain what it is you want.

This snippet will show only the drive letters and drive labels:
Code: [Select]@echo off
echo list volume > diskpart.txt
echo exit >> diskpart.txt
for /f "skip=8 tokens=3-4" %%i in ('diskpart /s diskpart.txt') do (
echo %%i: %%J
)
del diskpart.txt

This snippet will show all the fields:
Code: [Select]@echo off
echo list volume > diskpart.txt
echo exit >> diskpart.txt
for /f "skip=6 tokens=*" %%i in ('diskpart /s diskpart.txt') do (
echo %%i
)
del diskpart.txt

Good luck.

I try this.

Thanks for the replay.
5381.

Solve : your current security settings do not allow this action.?

Answer»

Do anyone know why, when i run "my documents" it SAYS that my current
SECURITY settings do not allow this action?


[Saving space, attachment deleted by admin]Quote from: rem_bc on January 27, 2010, 06:41:57 PM

Do anyone know why, when i run "my documents" it says that my current
security settings do not allow this action?

My Documents is a directory not a executable program. You may cd to My Documents and the list the files in My Documents.

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Bill Richardson>cd My Documents

C:\Documents and Settings\Bill Richardson\My Documents>
C:\Documents and Settings\Bill Richardson\My Documents>dir *.exe
Volume in drive C has no label.
Volume Serial Number is F4A3-D6B3

Directory of C:\Documents and Settings\Bill Richardson\My Documents

01/09/2010 06:02 PM 741,376 530_1018.EXE
10/02/2009 04:32 PM 60,857,536 Ad-AwareAE.exe
05/12/2009 10:16 AM 851,968 lj1100cuwinnt42kxp-en.exe
01/13/2010 07:05 PM 5,230,592 proxyway.exe
4 File(s) 67,681,472 bytes
0 Dir(s) 302,517,923,840 bytes free

C:\Documents and Settings\Bill Richardson\My Documents>dir *.gif
Volume in drive C has no label.
Volume Serial Number is F4A3-D6B3

Directory of C:\Documents and Settings\Bill Richardson\My Documents

12/21/2009 08:42 AM 113,645 Christmas.gif
06/02/2009 01:11 AM 193,818 raining.gif
2 File(s) 307,463 bytes
0 Dir(s) 302,517,923,840 bytes free

C:\Documents and Settings\Bill Richardson\My Documents>Quote from: BillRichardson on January 27, 2010, 06:52:33 PM
My Documents is a directory not a executable program. You may cd to My Documents and the list the files in My Documents.

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Bill Richardson>cd My Documents

C:\Documents and Settings\Bill Richardson\My Documents>
C:\Documents and Settings\Bill Richardson\My Documents>dir *.exe
Volume in drive C has no label.
Volume Serial Number is F4A3-D6B3

Directory of C:\Documents and Settings\Bill Richardson\My Documents

01/09/2010 06:02 PM 741,376 530_1018.EXE
10/02/2009 04:32 PM 60,857,536 Ad-AwareAE.exe
05/12/2009 10:16 AM 851,968 lj1100cuwinnt42kxp-en.exe
01/13/2010 07:05 PM 5,230,592 proxyway.exe
4 File(s) 67,681,472 bytes
0 Dir(s) 302,517,923,840 bytes free

C:\Documents and Settings\Bill Richardson\My Documents>dir *.gif
Volume in drive C has no label.
Volume Serial Number is F4A3-D6B3

Directory of C:\Documents and Settings\Bill Richardson\My Documents

12/21/2009 08:42 AM 113,645 Christmas.gif
06/02/2009 01:11 AM 193,818 raining.gif
2 File(s) 307,463 bytes
0 Dir(s) 302,517,923,840 bytes free

C:\Documents and Settings\Bill Richardson\My Documents>

I mean that i double click on "my document"
i am the administrator of the computer.Click start button, then RIGHT click for menu and choose open :

( There is a malfunction with "double click" ?)
FIND a working mouse and try it.

and/or

http://en.kioskea.net/forum/affich-23157-drives-and-folders-not-open-by-double-click

Quote from: BillRichardson on January 27, 2010, 07:02:20 PM
Try right click for menu and choose open :
You cannot right click it, it will say the same thing: your current security settings do not allow this action.

[Saving space, attachment deleted by admin]Quote from: BillRichardson on January 27, 2010, 07:02:20 PM
( There is a malfunction with "double click" ?)
Find a working mouse and try it.
My mouse work gook. Just the pop up: Your current security settings do not allow this action.
Quote from: rem_bc on January 27, 2010, 07:04:44 PM
You cannot right click it, it will say the same thing: your current security settings do not allow this action.

Do a SYSTEM restore to a day when all was well:

start, All Programs, accessories, System Tools and click System Restore.Quote from: rem_bc on January 27, 2010, 07:17:31 PM
My mouse work good. Just the pop up: Your current security settings do not allow this action.


Download, install and run Malwarebytes' Anti-Malware

http://download.cnet.com/Malwarebytes-Anti-Malware/3000-8022_4-10804572.html
5382.

Solve : Explore unknown drive?

Answer» HI!

I'd like to have a batch for my MultiSlotCardReader. It's suppose to check drive K: L: M: and N: for directorys AND/OR files. If there are any files present then it should EXPLORE the drive.

Can't get it working with wildcard-files and directorys, only specified filetypes.

Any smart ideas?

Thanks!It's for Windows XP btw Try this
Code: [Select]@echo off
dir K:\ *.* /s >> scan.txt
dir L:\ *.* /s >> scan.txt
dir M:\ *.* /s >> scan.txt
dir N:\ *.* /s >> scan.txt
echo Done!
pause> nulUhm YEAH, that code prints the content of the drives to scan.txt.

I want it to Explore the drives if any files exist.

Code: [Select]@echo off
IF NOT EXIST C:\test\1\*.txt GOTO two (
) ELSE (
explorer C:\test\1.
:two
IF NOT EXIST C:\test\2\*.txt GOTO three (
) ELSE (
explorer C:\test\2.
:three
IF NOT EXIST C:\test\3\*.txt GOTO four (
) ELSE (
explorer C:\test\3.
:four
IF NOT EXIST C:\test\4\*.txt GOTO End
) ELSE (
explorer C:\test\4.
:END

That code almost does it, but I don't want to specify the filetype. If I SET ..
Code: [Select]IF NOT EXIST C:\test\1\*.*, GOTO two (
) ELSE (
explorer C:\test\1.
..all drives is opened.So you want to be able to explore them within the shell. OK you could cheak to see if the drive or path is there and if it is change directiory (cd)Hmm okay, any EXAMPLES on that? I think this will do what you want:
Code: [Select]@echo off
for %%a in (K L M N) do dir %%a: >NUL 2>&1&if not errorlevel 1 start explorer /root,%%a:\Thank you! I'll try that out tomorrow Ahh, that works GREAT! Thank you very much Gary!No problem.
5383.

Solve : 10 options?

Answer»

Hello,

I would like to know how to ask for the user input with more then 10 options.So far I have tried:

echo 1-
echo 2-
echo 3-
echo 4-
echo 5-
echo 6-
echo 7-
echo 8-
echo 9-
echo 0- Options
CHOICE /n /C:1234567890 Choose the Action you want to Perform :

echo 1-
echo 2-
echo 3-
echo 4-
echo 5-
echo 6-
echo 7-
echo 8-
echo 9-
CHOICE /n /C:123456789 Choose the Action you want to Perform :

But that doesn't work I get the second set of optiopns what EVER option I choose for the first choice.

Thank You

AlmnHow about something like:
Code: [Select]@echo off
echo A-
echo B-
echo C-
echo D-
echo E-
echo F-
echo G-
echo H-
echo I-
echo J-
echo K-
echo L-
echo M-
echo N-
echo O-
echo P-
echo Q-
echo R-
echo Z- Options
CHOICE /n /C:ABCDEFGHIJKLMNOPRQZ Choose the Action you want to Perform :OK thank you
But what if I gave more than 24 options then ??

Thank You

AlmnCHOICE has an /s switch which makes your choices case sensitive. This should up your options to 62 (upper and lower case alpha plus ten digits).

What are you doing that you need so many options for?

8-)

Curious: I thought you were running the French version of XP. CHOICE has not shipped with any of the Windows NT family.Sidewinder has a good soultion.

Also, if you have more than about 24 options, then they will probably start scrolling off your screen (unless you CREATE multiple columns, or expand on the default number of rows). If you have that many, I would try to group them and have sub choices under the groups.

5384.

Solve : Simulating Enter in Batch?

Answer»

Hey,
I'm very very new to Batch files, working on my first one right now as a potential solution to a problem I am facing. For a background, I use a Kyocera KR1 mobile AP CONNECTED through an EVDO card for mobile internet access. The problem is, the router is often times POWERED down, and each time it is powered down, I must go through and access the router with ADMIN rights to reconnect to the EVDO service. As FAR as I can TELL, there is no auto-connect option built into the router... for whatever reason. Anyways, I've worked it down to I've got the exact site I need to go to, with my username and pass set to auto login, I just need to somehow simulate pressing an enter key.... is there anyway to do this within the batch file?

I'm doing something like...
start http://xxx.xxx.x.x/do_connect.cgi

i then get prompted for user name and pass, which is auto filled, I just need to somehow simulate the Enter Key being pressed... any help would be greatly appreciated. Thanks much!

JoeI am not aware of any batch method of simulating the enter key. I suspect your start command will launch your browser with the router's address. For Windows, you can use VBScript or JScript both of which are free and suppport the SendKeys method.

Also for Windows and free is AutoIt which claims anything can be scripted.

Good luck. 8-)Thanks for your assistance. I was in face able to find a solution for my problem, using a WshShell, but thanks for your suggestion!

5385.

Solve : using ethernet card for internet connection?

Answer»

please excuse me if this sounds stupid, because i am a newbie.
i am USING FreeDOS. i have installed Arachne graphical web browser.
i am UNABLE to use my modem because it is a winmodem.
my PC is not on a network, but i have a BUILT in PCI Ethernet Card.
is it possible to use this to connect to The Internet from DOS.
If yes, what other software are required?
Thanx in advanceDo you have a router to an internet CONNECTION? If so this can be done, but difficult. If not and you have no access this is impossible.no. i do not have a router.
i suppose an external modem is my only option.
thanx again for the replyI got an external 56K at COMPUTER Geeks for $7.50 last week

http://www.geeks.com/details.asp?invtid=56SX92WB-BULK&cat=MDM


At that price, there is no excuse.

5386.

Solve : Window display?

Answer»

I have a program that runs through DOS and while I can get the SCREEN to be a full screen, the data inside only takes up the top half of the screen. How do I get the program to use the full screen? When I set it up, I selected that option, but it's still not working.Try pressing [Alt]+[Enter]

Is that the result you are looking for?Just curious, is there anyway to script that action ??

Cheers,
CameronI think that Windows will remember a fullscreen the next time you run the program.

As far as scripting it inside a batch file ... I think you will need the help of VB or assembly for that. I'll see if I can dig out my assembly books to script a solution tomorrow.Many thanks Gary.
So long as you don't have to spend too much time hunting it down - it is the w/end after all.

Again, thanks for the follow-up. Hey Gary,

Hope you had a good w/end.
Any success find searching for a solution in your diggings ?

Cheers,
CameronHey, CAMERON. Yes, had a good WEEKEND. And you?

I did some searching but haven't found anything to work yet. I tried emulating Alt+Enter in VB (through a batch file) and that didn't work. I also found some assembly code that is supposed to "toggle windowed mode" (int 2f, ax=0x1684) that can be assembeled in a batch file with debug, but that didn't work either.

I have some code that will emulate KEYSTROKES (int 16, ah=0x05) that may work, but I have to figure out the scancode for Alt+Enter to test it. I should be able to get to that today.

I'll let you know what I find.Scancodes:

http://www.torsten-horn.de/techdocs/ascii.htm


hope it helps
uliThanks for the scancodes ... but my int 16 idea didn't work either. I GUESS the next step is to try forcing a video mode. I'll see what I can find on that and let you know.

5387.

Solve : New to this?

Answer»

Hello I'm new to batch FILES and would appreciate some help. I am wondering if while running an installer from the batch file, you are able to "hardcode" the cd-KEY SOMEWHERE so you wouldn't have to have any user interaction. Thanks in advance. That usually depends on the program and the installer. There is often a way to automate the CD key, but it probably wouldn't be in DOS or a batch file. For example, for Windows 98 I remember you could enter the CD-key into the "msbatch.inf" file to automate that part of the process. Other programs MAY have a smillar method, but it will be program specific.

Scripts can be written to "push" KEYSTROKES. The easiest way to push keystrokes to a Window would probably to use sendkeys in a VBScript.

5388.

Solve : file length?

Answer»

how would I get my batch file to return how many LINES a file is (test.txt)use find /C to COUNT the matching linesok THINKS

5389.

Solve : Boot?

Answer»

Hello,

I would like to know how to run a batch file when I boot or boot from a batch file.

Thank You

Almngive a more concrete example of what you want to do...I thought my example was prettyclear but basicily I am trying to make a disk that boots then runs my batch file which is compiled in an exe by the way. So I get you COULD look at it as a DOS Operating System.

Thank You

AlmnWhat operating system are you planning to boot into? Win2000/XP does not run on top of DOS.Quote

I thought my example was prettyclear but basicily I am trying to make a disk that boots then runs my batch file which is compiled in an exe by the way. So I get you could look at it as a DOS Operating System.

Thank You

Almn
although i don't know what exactly you are doing, but nonetheless, you can type something like "create windows boot disk" in google and there are sites that shows you how to make boot disk. After creating your boot disk, put your compiled exe in it and off you go.If you are running off a "DOS" boot disk, then you would call your program from a line in the AUTOEXEC.BAT file. Using an example of a boot floppy disk running DOS, and your program is called "MyBat.exe" in the root of the floppy, you would do:
AUTOEXEC.BAT
Code: [Select]MyBat.exe
If you are running Windows, and want it to start automatically at the launch of Windows, put it in the STARTUP folder under Start Menu. Put it under "All Users" if you want it to run when any user logs in, or under the specific user(s) if you want it to run for just certain users. Example would be to copy your MyBat.exe to "C:\Documents and Settings\All Users\Start Menu\Programs\Startup"
OK hello everyone my problem is a simple one i hope. Please help me. My friend gave me an old computer if his, DAID it was mine as long as i nuked the HARD drive, awsome so i did. unfortunately he doesn't have a restore disk for it and i dont either. So i need to install an operating system on it. i have a Windows Millenium edition CD, but no way to access it. I created a boot disk using our family XP machine, but i dont know how to use DOs and get past the screen the pops up when i turn on the downed machine. How to i either A) install windows ME using the cd or B)simply use DOS.wingsrule, it is better to start your own topic, rather than hijack someone else's thread, but you do need to download a WinME boot disk (free at www.bootdisk.com) and then boot with that and then type in

format c:/u/s and press enter
fdisk/mbr and press enter
e:\setup and press enter

that will start the install.

If you can't go from here, please do start your own thread in the Windows forum.SOrry will do.
5390.

Solve : filtering results?

Answer» TRY:

dir /B /a-dthen its ALRIGHT to use dir | findstr /V "" &GT; output_file.txt
5391.

Solve : MSDOS Boot Diskette Problem?

Answer»

I have recently created a MSDOS boot up disk, and on my computer I have two drives C: and D:, C: being the master and D: the slave. After BOOTING my computer into dos mode i have access to one DRIVE which is C: HOWEVER the drive C: is infact the computers D: so only the slave how do I access the the real C: drive? I am running Windows XP Professional.

ThanksIt souns like your original C: is formatted in NTFS, in which case a standard "DOS Boot disk" will not be able to READ that file system. You can try using NTFS4DOS, or look at http://www.bootdisk.com/ntfs.htm.Thats probably my problem, Ill have to SEE to it, Thank you

5392.

Solve : Make directory using current date?

Answer»

Hi everyone, my FIRST post!
It would be great if anyone could give me a hand in making a batch file.

My operating system is Windows 98SE
(Windows 98 version 4.10.2222)

I am intending to have the batch file on the desktop.
I would love it to be ABLE to:

1) Make a new directory inside of “C:\My Documents\folder”, using the current date and time as the name of the new folder. So an example would be: C:\My Documents\folder\%SomeDateTimeFormat%

2) Move all files from “C:\Test\TestFolder”, to the newly created folder of: %SomeDateTimeFormat% (inside of C:\My Documents\folder).

I hope that this is not too hard and I look forward to your suggestions.
Thanks in advance
Quote

Hi everyone, my first post!
It would be great if anyone could give me a hand in making a batch file.

My operating system is Windows 98SE
(Windows 98 version 4.10.2222)

I am intending to have the batch file on the desktop.
I would love it to be able to:

1) Make a new directory inside of “C:\My Documents\folder”, using the current date and time as the name of the new folder. So an example would be: C:\My Documents\folder\%SomeDateTimeFormat%

2) Move all files from “C:\Test\TestFolder”, to the newly created folder of: %SomeDateTimeFormat% (inside of C:\My Documents\folder).

I hope that this is not too hard and I look forward to your suggestions.
Thanks in advance


I don't know how hard it is what I have asked for, would it be easier if I just asked for the new folder named with just the "today's date" and not the time also?

Thanks again and I look forward to any replyhi
do a search first in this forum. enter "date time" as the search KEYS, show entries for the last 3 MONTHS , or last 1 year and you can find some posts that shows how to manipulate dates/times in batchDate and time manupilation is not easy under Windows 98 DOS. It is very easy to do under Windows 2000 and newer.

Date only is easier. I think most (or all) of the posts you will find on doing this are for Windows NT/2000/XP/2003.

Give me a few minutes, and I'll post some code that can do it in Windows 98 ... but it won't be pretty.This assumes that the directory "C:\My Documents\folder" already exists:
Code: [Select]@echo off
echo. |date >date.txt

echo e 100 >debug.txt
echo 73 65 74 20 64 61 74 65 73 74 72 3d >>debug.txt
echo m 11a 11d 10c >>debug.txt
echo m 114 115 110 >>debug.txt
echo m 117 118 112 >>debug.txt
echo rcx >>debug.txt
echo 14 >>debug.txt
echo n datestr.bat >>debug.txt
echo w >>debug.txt
echo q >>debug.txt

debug date.txt <debug.txt
del date.txt
del debug.txt
call datestr.bat
echo Date is %datestr%
del datestr.bat

md "C:\My Documents\folder\%datestr%"
move "C:\Test\TestFolder\*.*" "C:\My Documents\folder\%datestr%"GuruGary,

Thanks very much for your help.
I thought that it would be a difficult thing to do under win98.
Yes, I have seen plenty of code for the newer OS’s.

Thanks again
No problem. Did it work the way you wanted? Or even work at all?If batch is not easy to manipulate dates and time, why not go for scripting langauges like VB, perl, python? date and time manipulation is easier. here's a simple one in python

Code: [Select]import time,os,shutil
thedate = time.strftime("%Y%m%d",time.localtime()) #only get the date, not time
rootdir = os.path.join("C:\\", "My Documents" , "folder")
newfolder = os.path.join(rootdir,thedate)
testfolder = os.path.join("C:\\", "Test" ."TestFolder")
os.makedirs(newfolder)
os.chdir(testfolder)
for files in os.listdir(testfolder):
shutil.move(files,newfolder)

its easier to understand ...Thanks to GuruGary, the Batch worked great!
Thanks too to ghostdog74, for writing the Python script!
It's nice to know that there are people out there that still like to help.
All for free too!
Have a good day
Cheers
5393.

Solve : Sending string to multiple users...?

Answer»

I want to create a VARIABLE that is a string, like "Hello", and send to multiple users using net send. I can use net send, but cannot create a variable to be sent. I am just trying to avoid updating each net send statment when the message changes.

Does anyone have any ideas about this?

Thanks!To make sure I understand, you already have a process for sending to the multiple users, but you are trying to automate sending a particular string of text to those users? Or do you NEED to automate both parts?Here is what I am trying to do:

variable = "Good Morning"

net send AA56697 variable
net send BN45949 variable
net send YR93856 variable
etc.

This would send the message "Good Morning" to all three users listed. It currently works if I type "Good Morning" on each line, but the message is actually much longer, and I don't want to have to change each line when the message needs updating.

Thanks!You are very close already. Try this:

Code: [Select]set variable="Good Morning"

net send AA56697 %variable%
net send BN45949 %variable%
net send YR93856 %variable%Or if you want to make it a little fancier, you could try:

Code: [Select]set variable="Good Morning"
for %%a in (AA56697 BN45949 YR93856) do net send %%a %variable%Thanks, but both options give me the following error message:


Sending files is no longer supported.

More help is available by typing NET HELPMSG 3777.

Make sure the Messenger service (not to be confused with Windows Messenger) is started on the sending and receiving machines.

Start==>Run==>Services.msc

Scroll down the screen until you find Messenger and make any changes accordingly.

Hope this helps a little. 8-)Thanks, but it didn't work. Both machines have Messenger service started.

I am able to use:

net send AA43455 "Hello"

but not:

variable = "Hello"
net send %variable%

Any other ideas?Quote

variable = "Hello"
net send %variable%

I believe previous posts mentioned that you have to set the variable. Both the SET command and the NET SEND must be done in the same window.

Code: [Select]set variable = "Hello"
net send computername %variable%

GuruGary's solution still applies. 8-)Sorry, I mistyped.

I've been doing exactly that. I have these two lines in a file called send.bat:

set variable "Hello"
net send AA54546 %variable%


Can anyone reproduce this using either network Id or computer name successfully?I was able to get your send.bat file to work without any problems. Used a different computername of course.

What OS and type of network are you using?

8-)

It's highly recommended to disable the Messenger Service as this can be the source of UNWANTED popups from the script kiddies.I'm actually using my Windows (2000) network login, not computer name. I will try it with the computer name instead.

Not sure of the network type.Be sure there is an EQUALS sign (=) between the variable and Hello. The line should be exactly like this:
Code: [Select]set variable="Good Morning"
If that still does not work, then put an "echo" at the beginning of the first line so we can see the output, and then post the results. EXAMPLE, change your batch file from:
Code: [Select]@echo off
set variable="Good Morning"
net send AA56697 %variable%to
Code: [Select]@echo off
set variable="Good Morning"
echo net send AA56697 %variable%
5394.

Solve : Need batch file?

Answer»

I need a rather simple batch file!!

I want to CHECK for a particular file in a FOLDER - EXAMPLE "aaa.txt" and if found rename it to "ccc.txt". If I don't FIND "aaa.txt" - check for "bbb.txt" and rename to "ccc.txt".

That's it -- Any help will be appreciated.Welcome to the forum
it would be
if exist aaa.txt (
ren aaa.txt ccc.txt
) else (
ren bbb.txt ccc.txt
)

I am ASSUMING that bbb.txt will be present and that the file is ran from the same directoty as the files.
All that information canbe found easily just google ms dos help

Almn

5395.

Solve : for?

Answer»

When I do a forloop this one

Code: [Select]for /f "skip=%dirs%" %%a in ('dir /b /o:g') do set dirf=%%a
it only displays one line
this is the whole script


Code: [Select]@echo off
:start
for /f "tokens=1 delims= " %%a in ('dir *.* ^| find /i "Dir(s)"') do set dirs=%%a
echo %dirs%
pause
for /f "skip=%dirs%" %%a in ('dir /b /o:g') do set dirf=%%a
echo %dirf%
pause




This is because each time around the loop you are setting the dirf variable to the current value of the looping variable, therefore it will only ever HOLD the last line.

Grahamso what can i do to get all of the linesCode: [Select]@echo off
:start
for /f "tokens=1 delims= " %%a in ('dir *.* ^| find /i "Dir(s)"') do set dirs=%%a
echo %dirs%
pause
for /f "skip=%dirs%" %%a in ('dir /b /o:g') do echo %%a
pause

Naturally the list will be missing the items you skipped.

8-)Here is another problem if you run it on the DESKTOP when it cheaks for the # of dirs it will include the systom ones (like: My computer and My network places) then when it does the BEAR display (dir /b *.*) it will not display the system folders so it will skip to manny lines taking out some of the files. Any idea on what to do. :-? :-?Which way do you want it to work?never mind that i have know idea what the dirs at the top are when i use it on my desktop dir named "." and another named ".." show up when i do dir *.* and do not show up if i do dir /b *.*
The "." and ".." are implied for all subdirectories.
. = current directory
.. = parent directory

Here are some tips that MAY help shorten THINGS up for you:

To count the number of directories including hidden and system, use:
dir /b /ad |find /v /c "*"

To count the number of directories including hidden (but including system), use:
dir /b /a:d-h |find /v /c "*"

To count the number of directories excluding hidden and system, use:
dir /b /a:d-h-s |find /v /c "*"
ok i will mess with that think you

5396.

Solve : adding to a file?

Answer»

how do i add a variable to the start of every line in a fileYou would probably have to rewrite the file. To add a colon as the first character in each line of a TEXT file, you can set the variable to the colon and process the file like:
Code: [Select]@echo off
set PREFIX=:
set Infile=test.txt
set Outfile=new.txt

if exist %Outfile% del %Outfile%
for /f "delims=" %%a in (%Infile%) do echo %Prefix%%%a >>%Outfile%
If you WANT to replace the original file with the modified VERSION, you would add:
Code: [Select]del %Infile%
ren %Outfile% %Infile%If either INFILE or OUTFILE have spaces in them, be sure to surround them in double-quotes.Quote

how do i add a variable to the start of every line in a file

You should already know how to loop over a file using for loop.
so just set the variable, eg set var=somevariable
then while you are looping over the file, do an echo %var%%%i

this will add the variable in front of the line.OK THINK you i did not think a for loop would work i thought that it would just add to the first line
5397.

Solve : Next?

Answer»

Hello,

I would like to create a batch that finds the first FILE on the computer sets it as a variable then run a program with it then find the next file and start all over again. Like this:

find filepath
set filepath=source
md5 %source%
:start
find nextfile
set nextfile=source
md5 %source%
goto start

Thank You

AlmnQuote

Hello,

I would like to create a batch that finds the first file on the computer sets it as a variable then run a program with it then find the next file and start all over again. Like this:

find filepath
set filepath=source
md5 %source%
:start
find nextfile
set nextfile=source
md5 %source%
goto start

Thank You

Almn

seems like you want to hash your files with md5.
you can use the fciv command. Download from here http://support.microsoft.com/?kbid=841290
There are examples on how to use it.
Do you want to do this on all files, then recurse subdirectories and keep going? Or all files on the entire computer?

Here is a command to run on all files in the current directory (all in one line):
Code: [SELECT]for /f "delims=" %%a in ('dir /a-d /b') do md5 "%%a"
Here is a command to run on all files in the current directory and recursing all subdirectories:
Code: [Select]for /f "delims=" %%a in ('dir /a-d /b /s') do md5 "%%a"
from what you seem to be doing, you are going to be writing ANOTHER batch to check these md5 with the ones you collected. fciv can save you the time to write the checking module.There is a free microsoft toy - http://www.logparser.com/ that would fit the BILL here, it works against logfiles, the registry and the filesystem. It has a nice clean SQL front end and can output to a myriad of formats.

It is easily called by the command line
Grahamactally I think that I mis-posted my thread, I was using md5 as an example. :-/
So can you give me the FORMAT,I would like to run a few lines to check whether the file has the string computer and key as well as name in it then echo it.
Sorry I mis explained:-[


AlmnI took into consideration that you may have given an unrelated example and answered your question the way you asked it, so my code should still work.
Do you want to do this on all files, then recurse subdirectories and keep going? Or all files on the entire computer?

Here is a command to run on all files in the current directory (all in one line):
Code: [Select]for /f "delims=" %%a in ('dir /a-d /b') do md5 "%%a"
Here is a command to run on all files in the current directory and recursing all subdirectories:
Code: [Select]for /f "delims=" %%a in ('dir /a-d /b /s') do md5 "%%a"
5398.

Solve : runthis.bat to fix virus; dos not staying on scr.?

Answer»

No problem. Glad you GOT it to run.

You probably STILL need to fix the PATH problem if you haven't already. Try this:
Right-click on "My Computer" -> Properties -> "Advanced" tab -> "Environment VARIABLES" button -> select "Path" in the bottom window and click the "Edit" button.

Each entry in this should be SEPARATED by a semicolon ( ; ), and I am guessing that neither:
c:\windows\system32
c:\windows
are in there. Windows XP is usually "c:\windows", but if you are running Windows 2000 or something else it may be "c:\winnt" or something different.

Good luck and let us know if we can help you with ANYTHING else.

5399.

Solve : a .bat to enable a NIC in WinXP?

Answer»

I have an individual who has a problem with her NIC being DISABLED in Win XP. I need a batch file that will enable that if it is disabled when Win XP BOOTS. I have RESEARCHED and can't seem to find that or figure out how to accomplish it.

I WOULD appreciate if anyone could help me out with this problem.you can TRY the devcon utility from M$
http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q311272

5400.

Solve : Tracert self?

Answer»

Is is POSSIBLE to do something like tracert local_server or something that would trace the current computer?Yes, you can ... but I don't KNOW what you would gain from doing that. Try:

tracert localhost

Or if that is not what you are looking for let US know what you are trying to accomplish.ok THANKS for that...now how do i have that save in a text file?You can use the ">" to REDIRECT the output to a file. Here is an example with a file named "OUTPUT.TXT":

tracert localhost >OUTPUT.TXTThis is an exercise in futility. But if you insist.........

tracert localhost > mytrace.txt

This will save it in the current directory. If you want it saved elsewhere, provide the path. For example, trace localhost > c:\mytrace.txt would put it in the root directory.

Edit: Har! Har! I type to slow.