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.

7301.

Solve : BATCH FILE TO BACK UP PHOTOS TO A MEMORY STICK??

Answer»

Hi guys
Just NEW to batch files ive manages to make on that copies from one folder to another in c:\ but when i TRY and copy from c:\documents and settings\daniel\my documents\my pictures to f:\ COME up with errors. I was HOPING to have the batch file on the memory stick so all the girlfriend has to do is click the file and everything is copied over
Any help would be GREATLY appreciated
DanielWhat errors ? ?Those caused by not quoting a path with spaces? Memory stick write protected?


7302.

Solve : put time condition in .bat file?

Answer»

I create a .BAT FILE to log the WINDOWS startup time under C drive

@echo off
cls
echo Windows Started %date% %time% >> c:\startup.txt

question:
how to ADD a condition, if the time boot to windows is more than 5minutes, then this will generate a statement under log file.

is that possible to do it?

Purpose is to let that user know what time before/after the windows fail to boot up in time (3-4mins). this is good when doing power cycling text for overnight. Because the log file will have MANY lines of date and time.

7303.

Solve : IF ELSE command in batch files?

Answer»

Hi All...

I am a NEW bie and have no knowledge on batch files.. plz help me out of this

i write a batch file which checks whether arguements are passed to the batch script as an input or not

like

@echo off
IF "%1"=="" GOTO END ELSE GOTO Syntax
:Syntax
echo SUCCESS
:END
echo failure

pause

when i eecute in commandpromt as call filename.bat
gives me failure
but when i GIVE as call filename.bat HI
gives me success and failure too but i want that as only success .. any trick here please helpQuote from: luckey on October 01, 2007, 01:07:12 AM

Hi All...

I am a new bie and have no knowledge on batch files.. plz help me out of this

i write a batch file which checks whether arguements are passed to the batch script as an input or not

like

@echo off
IF "%1"=="" GOTO END ELSE GOTO Syntax
:Syntax
echo success
:END
echo failure

pause

when i eecute in commandpromt as call filename.bat
gives me failure
but when i give as call filename.bat HI
gives me success and failure too but i want that as only success .. any trick here please help

Your batch file needs changing. When a line is finished, it passes to the next one.

In the "success" situation, it will pass to the the next line. This is the :END label.

This is what I SUGGEST

@echo off
IF "%1"=="" GOTO fail

echo success
goto end

:fail
echo failure

:end
pause


7304.

Solve : IF command to run new bat file?

Answer»

I am somewhat of a newbie at bat files, so I HOPE I can explain this clear enough.. I am trying to get another bat file to run if any file in a certain folder has been modified today. So basically , if "c:\*.doc" was modified today then run "modfile.bat" and if no "c:\*.doc" files where modified today then run "nofile.bat"

I am running windows XP if that makes any difference. Any help on this would be greatly appreciated.

Thanks,
Psycho DanIn a FOR loop, get each file modified date (the date shown by DIR) and compare it to the %date% system variable.


Thanks contrex...

This is what I have come up with, and it seems to work

for %%F in (*.doc) do (for /F %%D in ("%%~tF") do (set mdate=%%D))
for /F "tokens=2" %%D in ('date/t') do set cdate=%%D

if "%cdate%"=="%mdate%" start modfile.bat
if not "%cdate%"=="%mdate%" start nofile.bat

It will only find the last file in the folder (if there are more than one) because you have the loop that finds the files all on one line.

Also, why use date /t when you have %date% available to you?

Shouldn't you be LOOKING at the 1st token of %%~tF rather than of the OUTPUT of date /t ?

I don't know about your location, but where I am, (Europe) %date% is

30/09/2007

and %%~tF would have this format

30/09/2007 11:27



7305.

Solve : Unmountable boot volume error message!!!?

Answer»

I received this error message when I plugged an old printer and cable. Not it won't BOOT. I downloaded a boot CD and copied it USING Nero. When I try to boot up, it displays [DR-DOS] a:\> I changed DRIVE to d:\ to list dir -- it displays winxp_ene exe but I don't know how to reinstall WindowsXP from here! Please HELP!!!See here and here.

Good luck & Welcome to the CH forums.

7306.

Solve : For loop problem?

Answer»

Howdy,

I have a for loop that parse a txt file and replaces some lines if it matches a certain string. The problem is there is ONE line in the file that contains a coup "&" symbols. When the batch file runs the commend "set line=%~1" it basically errors out because it takes it as a special character rather than just text. I know normally you could escape this with a ^ but since this is a variable, not hard code, I'm not SURE what to do. Please find the script and problem line below. As always any help is appreciated.

Script:
Code: [Select]for /F "delims=" %%a in (%TEMP%\lexw.ini) do call :process "%%a"
goto :EOF

:process
set line=%~1
set line2=
if "%line%"=="[MENU]" set line2=DAY=Daily Operating Report System (DOR)
echo %line% >> "%systemroot%\lexw.ini"
if defined line2 echo %line2% >> "%systemroot%\lexw.ini"
:EOF

Problem:
Code: [Select]set line=MRU3=\\<removed>\CPM\MMM\SYSRPTS\<removed>\Z300 F&B\F&B Summary w EDR.lrf
You do know that folder and files names containing the "poison character" & are STRONGLY deprecated in NT? That your IT people are, therefore, dorks?

This might help

Quote


Handling "&" in a folder name

http://tinyurl.com/2qenvy






Quote from: contrex on SEPTEMBER 28, 2007, 01:23:54 PM
That your IT people are, therefore, dorks?
i believe you know who the bigger dorks are?Quote from: ghostdog74 on September 28, 2007, 08:06:35 PM
i believe you know who the bigger dorks are?

The people who post here asking us to do their jobs or school assignments for them, or us, for doing it?

7307.

Solve : Copy from HTTP location??

Answer»

Hi Guys,
This is my FIRST post and first venture into DOS(!)
I've been writing small reporting applications in MS Access and need a script to copy a file from one location to another.
Is it possible to copy from an internal webserver using DOS commands?
Thanks in advance
SteveWelcome.

I can't THINK of an EASY to download a file over HTTP using only native commands, but you can download WGET.EXE (http://users.ugent.be/~bpuype/wget/) and it should do exactly what you want. To copy a file named "file.txt" on internal WEB server named "webserver" to your current directory, just do:
Code: [Select]wget http://webserver/file.txtor to copy to a new location, use:
Code: [Select]wget -O C:\New\Path\file.txt http://webserver/file.txtyou can use this VBSCRIPT if you can't use other tools
Code: [Select]URL = "http://www.google.com"
set WshShell = WScript.CreateObject("WScript.Shell")
Set http = CreateObject("Microsoft.XmlHttp")
http.open "GET", URL, FALSE
http.send ""
WScript.Echo http.responseText
set WshShell = nothing
set http = nothing
usage:
Code: [Select]c:\> cscript /nologo myscript.vbs > outfile

7308.

Solve : shut down win98 on close application?

Answer»

well,i'm WONDERING if anyone can help me with this problem.i just wanna shut down the win98 automatically when i CLOSE a application.how can manage it with the batch files?

7309.

Solve : Pre MS-DOS?

Answer»

I am TRYING to get an Osborne 1, Portable PC up and running.

It is a 1982 Osborne 1
processor -- Zilog Z80 @ 4 Mhz
RAM -- 65 kb
drives -- dual 5 1/4 single-sided 40 track floppy


It USES CP/M os which is pre microsoft DOS. but I'm missing the os disk
Does anyone have any knowledge of this stuff?http://www.vintage-computer.com/vcforum/archive/index.php/t-2843.html

http://z80cpu.eu/mirrors/www.guntersville.net/osborne/

http://www.google.co.uk/search?source=ig&hl=en&q=osborne+cp%2Fm&btnG=Google+Search&meta=

Good luck!

Have you looked --->Here ?street1, your link, which was just so-informatively called "here", is to a page of software for the BRITISH Amstrad PCW and CPC range of 8-bit COMPUTERS, which are not the same as the Osborne.

7310.

Solve : batch file to replace a document?

Answer»

Hi i'm new to batch file scripting and was wondering if ANYONE could help me

I'm LOOKING to RUN a batch file that will replace one document with another

i.e. C:\temp\master.doc to C:\temp\minor.doc

I want to keep the master copy but replace the minor copy with an image of the master.

Any help greatly appreciated. there is a batch section here..

see

can i get a mod to move this thread for me pls so we don't get a double post..

thank YOUTOPIC has been MOVED to the appropriate section.

7311.

Solve : How do I start an application shortcut from a batch file??

Answer»

The action would be relative to a click action from the start menu. My shortcut calls my application that exists on a different server and I prefer to keep all my apps there. The shortcut also ensures that all of the REQUIRED files are available.

How can I start up my application by REFERENCING a shortcut from my batch file?


Does ANYONE know what I need to do?

Thanks for any help,
RuthWhatever the shortcut points to, you want to start from a batch file? Is that right? ONE way is that you can right click the Start button, choose "Explore", navigate to the shortcut in question, right click on on it, go to the "Target" section in the dialog that you see, highlight the text (which will be the path and name of a program or other executable) and copy-and-paste it into your batch file.






7312.

Solve : DOS question!!?

Answer»

Hello guys,

I'm confuse to do a chkdsk in DOS and have the DOS checked for any ERRORS and repair those errors do I need to type /f /r or is it -p -r

Thank you!! Quote

SwitchEffect

filename


FAT only. Specifies the file or set of files to check for fragmentation. Wildcard characters (* and ?) are allowed.

path


FAT only. Specifies the location of a file or set of files WITHIN the folder structure of the volume.

size


NTFS only. Changes the LOG file size to the specified number of kilobytes. Must be used with the /l switch.

volume


FAT only. Specifies the drive letter (followed by a COLON), mount point, or volume name.

/c


NTFS only. Skips checking of cycles within the folder structure.

/f


Fixes errors on the volume. The volume must be locked. If Chkdsk cannot lock the volume, it offers to check it the next time the computer starts.

/i


NTFS only. Performs a less vigorous check of index entries.

/l


NTFS only. Displays current size of the log file.

/r


Locates bad sectors and recovers readable information (implies /f ). If Chkdsk cannot lock the volume, it offers to check it the next time the computer starts.

/v


On FAT. Displays the full path and name of every file on the volume.
On NTFS. Displays cleanup messages, if any.

/x


NTFS only. Forces the volume to dismount first, if necessary. All opened HANDLES to the volume are then invalid (implies /f ).


To have access to this list just type chkdsk /? at the prompt...

/r should be sufficient.thank you so much Patio!!


I'll try that..
7313.

Solve : reference an exe file in the documents and settings?

Answer»

I am ATTEMPTING to CREATE a batch file that starts an exe from an application reference. The application reference is under the “documents and settings” folder. I think the spaces within the folder NAME are interfering with the start commands execution. It cannot FIND the exact path to the file.

How do I reference the path that includes the “documents and settings” folder?



RuthQuote from: ruth.sanders on September 27, 2007, 12:42:33 PM

I am attempting to create a batch file that starts an exe from an application reference. The application reference is under the “documents and settings” folder. I think the spaces within the folder name are interfering with the start commands execution. It cannot find the exact path to the file.

I've never heard of an "application reference". If you MEAN the full path and file name of an executable program or any other type of file, if any of these have spaces in them, enclose the whole thing in quote marks thus

start "C:\Documents and Settings\Jim\Blah Blah\program.exe"

THANK YOU! THANK YOU! THANK YOU!

7314.

Solve : Setup Maps off of two different Usernames?

Answer»

I need to setup a batch that will map my the network drives for me based on 2 seperate domain passwords. One Domain uses different username and passwords per user the other the same username and password REGARDLESS. I alos need to disconnect all drives before continuing. So here is what I have so far.

Code: [Select]@ ECHO OFF

:START

'PTC MAPS
net use F: \\PTC1SVR204\dallas /user:%username% /PERSISTENT:yes
net use G: \\PTC1SVR206\colorado /user:%username% /persistent:yes
net use H: \\PTC1SVR204\noc /user:%username% /persistent:yes

'JSA Maps (L is a must for system application)
net use K: \\server\g\scans /user:ABC /persistent:yes
net use L: \\server\c /user:ABC /persistent:yes
net use M: \\server\e /user:ABC /persistent:yes

'IVS Maps
net use S: \\PTC1SVR204\productionbatches /user:%username% /persistent:yes
net use T: \\PTC1SVR204\archivedbatches /user:%username% /persistent:yes
net use U: \\PTC1SVR205\ivsscans\scans /user:%username% /persistent:yes
net use V: \\PTC1SVR205\ivsscans\splitdocs /user:%username% /persistent:yes



:ENDSide Note: I have only ever used batch files before to copy files or start SOFTWARE (you know, one liners) so take it easy on me.Well let me ask this:

How can I set the password from within the script?

7315.

Solve : How to run Pathping mutiple times and output it to a text file????

Answer»

I need to create a batch script to run the pathping command 10 times in a row and OUTPUT that all to a text file....

This should be easy i just can't FIGURE it out? Can someone please help me!

Thanks!USE the > redirection character for the FIRST LINE of the batch file, where you redirect the pathping output into your chosen text file.
Use the >> character for the next 9 lines, to append the output to that same text file.

This is your homework, isn't it?

7316.

Solve : Exit Command Twist?

Answer»

I am new to command file scripting. What does the "-4" after the exit command do?
Example "Exit -4"

Thanks
You must be running a batch file that looks something like this..

@echo off
:menu
set choice=
echo 1 - menu
echo 2 - exit
set /p choice="enter the number of your choice"
if '%choice%'='1' GOTO :menu
if '%choice%'='2' GOTO :exit

:exit
prompt $P$G



if it is a batch file you can right click it and click edit to view the commands.

anyway the "exit -4" is most likely not a command; just a menu which has echoed to the screen

if it is a command the the -4 would mean nothing as long as there is a space (delimetor) after the exit... the exit command terminates the cmd prompt windowWelcome to the CH forums.

The NUMERIC code SETS the errorlevel to the numeric code specified.. See here.

Ohh yea. those things... ive seen them around....ive got some more reading to do ....


excuse my ignorance. thats why im here.Quote from: Woodman on September 24, 2007, 05:26:43 PM

Welcome to the CH forums.

The numeric code sets the errorlevel to the numeric code specified.. See here.



Thank you! Now I get it. It makes sense because the code should not have gotten here if all went well.

Thank You! hamelinpiper, you have done this at least twice now! Posting a -- long -- answer when you know nothing about the question!

Quote
C:\>exit /?
Quits the CMD.EXE program (command INTERPRETER) or the current batch
script.

EXIT [/B] [exitCode]

/B specifies to exit the current batch script instead of
CMD.EXE. If executed from outside a batch script, it
will quit CMD.EXE

exitCode specifies a numeric number. if /B is specified, sets
ERRORLEVEL that number. If quitting CMD.EXE, sets the process
exit code with that number.

7317.

Solve : Batch file to move files if gtr 0?

Answer»

Hey, just stuck on a little something that I'm overlooking obviously. I'm using the following to check for files in a specified directory. If the size is greater than 0, I want to MOVE those that are greater than 0 to an archive folder.

As you can see, what it is doing is moveing every file to the archive not just those greater than zero size. So I'm obvioulsy missing something or incorrectly stated something...any thoughts?

@echo off
Rem Echo Filename & Size
cls
for %%a in (dir C:\CoreFTPOutgoing\*.txt) do (
if %%~za GTR 1 (
move C:\CoreFTPOutgoing\*.txt C:\CoreFTPOutgoing\archive\
echo %%a %%~za
)
)


What happens when you make your condition

if NOT %%~za==0 (

GrahamThanks for the reply Graham. Unfortunately, it still moves all the files regardless of size (or no size).

Here is the cmd file with the condition change:

@echo off
Rem Echo Filename & Size
cls
for %%a in (dir C:\CoreFTPOutgoing\*.txt) do (
if NOT %%~za==0 (
move C:\CoreFTPOutgoing\*.txt C:\CoreFTPOutgoing\archive\
echo %%a %%~za
)
)
Guess what? You kinda stuffed up...


move C:\CoreFTPOutgoing\*.txt C:\CoreFTPOutgoing\archive\
When this is executed, it moves every text file to /archive, not just the ones GTR 0.

What you probably want is this:
move C:\CoreFTPOutgoing\%%~nxa C:\CoreFTPOutgoing\archive\


If that doesn't work, just tell me. If it does, tell me anyway.

Thanks Dark Blade....that did the trick.

I knew it was MOVING everything because of that line, but I wasn't SURE what the correct syntax was since I don't WRITE these too often.

So YES, it is working properly now. Appreciate the replied from both of you.

7318.

Solve : batch script that creates directory with successive numbers?

Answer»

Hi i am TRYING to create a batch script that will create a directory named test_XX where XX is a incremental number starting from 01.

eg. test_01 and then test_02, and if they exist it will just increment right up to test_100

CHeers!

try this

@ECHO OFF
:HSF0
echo 0>>%temp%\iss.txt
echo 1>>%temp%\iss.txt
echo 2>>%temp%\iss.txt
echo 3>>%temp%\iss.txt
echo 4>>%temp%\iss.txt
echo 5>>%temp%\iss.txt
echo 6>>%temp%\iss.txt
echo 7>>%temp%\iss.txt
echo 8>>%temp%\iss.txt
echo 9>>%temp%\iss.txt
echo 10>>%temp%\iss.txt
echo 11>>%temp%\iss.txt
echo 12>>%temp%\iss.txt
echo 13>>%temp%\iss.txt
echo 14>>%temp%\iss.txt
echo 15>>%temp%\iss.txt
echo 16>>%temp%\iss.txt
echo 17>>%temp%\iss.txt
echo 18>>%temp%\iss.txt
echo 19>>%temp%\iss.txt
echo 20>>%temp%\iss.txt
echo 21>>%temp%\iss.txt
echo 22>>%temp%\iss.txt
echo 23>>%temp%\iss.txt
echo 24>>%temp%\iss.txt
echo 25>>%temp%\iss.txt
echo 26>>%temp%\iss.txt
echo 27>>%temp%\iss.txt
echo 28>>%temp%\iss.txt
echo 29>>%temp%\iss.txt
echo 30>>%temp%\iss.txt
echo 31>>%temp%\iss.txt
echo 32>>%temp%\iss.txt
echo 33>>%temp%\iss.txt
echo 34>>%temp%\iss.txt
echo 35>>%temp%\iss.txt
echo 36>>%temp%\iss.txt
echo 37>>%temp%\iss.txt
echo 38>>%temp%\iss.txt
echo 39>>%temp%\iss.txt
echo 40>>%temp%\iss.txt
echo 41>>%temp%\iss.txt
echo 42>>%temp%\iss.txt
echo 43>>%temp%\iss.txt
echo 44>>%temp%\iss.txt
echo 45>>%temp%\iss.txt
echo 46>>%temp%\iss.txt
echo 47>>%temp%\iss.txt
echo 48>>%temp%\iss.txt
echo 49>>%temp%\iss.txt
echo 50>>%temp%\iss.txt
echo 51>>%temp%\iss.txt
echo 52>>%temp%\iss.txt
echo 53>>%temp%\iss.txt
echo 54>>%temp%\iss.txt
echo 55>>%temp%\iss.txt
echo 56>>%temp%\iss.txt
echo 57>>%temp%\iss.txt
echo 58>>%temp%\iss.txt
echo 59>>%temp%\iss.txt
echo 60>>%temp%\iss.txt
echo 61>>%temp%\iss.txt
echo 62>>%temp%\iss.txt
echo 63>>%temp%\iss.txt
echo 64>>%temp%\iss.txt
echo 65>>%temp%\iss.txt
echo 66>>%temp%\iss.txt
echo 67>>%temp%\iss.txt
echo 68>>%temp%\iss.txt
echo 69>>%temp%\iss.txt
echo 70>>%temp%\iss.txt
echo 71>>%temp%\iss.txt
echo 72>>%temp%\iss.txt
echo 73>>%temp%\iss.txt
echo 74>>%temp%\iss.txt
echo 75>>%temp%\iss.txt
echo 76>>%temp%\iss.txt
echo 77>>%temp%\iss.txt
echo 78>>%temp%\iss.txt
echo 79>>%temp%\iss.txt
echo 80>>%temp%\iss.txt
echo 81>>%temp%\iss.txt
echo 82>>%temp%\iss.txt
echo 83>>%temp%\iss.txt
echo 84>>%temp%\iss.txt
echo 85>>%temp%\iss.txt
echo 86>>%temp%\iss.txt
echo 87>>%temp%\iss.txt
echo 88>>%temp%\iss.txt
echo 89>>%temp%\iss.txt
echo 90>>%temp%\iss.txt
echo 91>>%temp%\iss.txt
echo 92>>%temp%\iss.txt
echo 93>>%temp%\iss.txt
echo 94>>%temp%\iss.txt
echo 95>>%temp%\iss.txt
echo 96>>%temp%\iss.txt
echo 97>>%temp%\iss.txt
echo 98>>%temp%\iss.txt
echo 99>>%temp%\iss.txt
echo 100>>%temp%\iss.txt
IF EXIST %temp%\iss.txt GOTO HSF1
GOTO HSFZ

:HSF1
@SET B=1
GOTO HSF2

:HSF2
FOR /F "tokens=1*" %%a in (%temp%\iss.txt) do mkdir %%a



Thanks for that, i was looking to create directories and after looking around i found the following method that worked for me (see below)

Now i need one more feature and that is for all the existing files in the current directory to be copied to the new directory that is created from the script below...any ideas?

for /l %%x in (1,1,9) do (
if not exist folder_0%%x\nul (
set Dump=folder_0%%x
md folder_0%%x
goto next
)
)
:: create folder versions 10 through to 99
for /l %%x in (10,1,99) do (
if not exist folder_%%x\nul (
set Dump=folder_%%x
md folder_%%x
goto next
)
)
:next
Includes more compact way to create dirs sequentially numbered from 1 to 100 with number padded to 3 figures

Quote

@echo off
setlocal enabledelayedexpansion
FOR /L %%N IN (1,1,100) DO (
IF %%N EQU 100 set pad=
IF %%N LEQ 99 set pad=0
IF %%N LEQ 9 set pad=!pad!0
if not exist folder_!pad!%%N mkdir folder_!pad!%%N
copy *.* folder_!pad!%%N
)
Thanks guys
7319.

Solve : push pop?

Answer»

Ok. so i have heard of a WAY to "push" stuff into ram and "pop" it back out ... leaving a computers hard drive untouched (i think this falls in to the field of computer forensics)... the catch is you must push them on in the reverse order of how you want to pop them off.... any info on this topic would be appreciated.Push and Pop are features (commands) in Assembly programming language (the language of the Gods) and I'm sure there are other references to it. As you will see from the following LIFO is the sequence you mention (extract from this site.)

"The Stack
The stack is a place where data is TEMPORARILY stored. The SS and SP registers point to that place like this: SS:SP So the SS register is the segment and the SP register CONTAINS the offset. There are a few INSTRUCTIONS that make use of the stack. POP and PUSH are the most basic ones. PUSH can "push" a value on the stack and POP can retrieve that value from the stack. It works like this:

MOV AX,1234H
PUSH AX
MOV AH,09
INT 21H
POP AX

The final value of AX will be 1234h. First we load 1234h into AX, then we push that value to the stack. We now store 9 in AH, so AX will be 0934h and execute an INT. Then we pop the AX register. We retreive the pushed value from the stack. So AX contains 1234h again. Another example:

MOV AX, 1234H
MOV BX, 5678H
PUSH AX
POP BX

The final values will be: AX=1234h BX=1234h. We pushed the AX to the stack and we popped that value in BX.
As in the first program, you have to define a stack segment. It is easy done by the instruction .stack that will create a stack of 1024 bytes. Yes, there's more about the stack than just this. The stack usses a LIFO system (Last In First Out) Another example:

MOV AX,1234H
MOV BX,5678H
PUSH AX
PUSH BX
POP AX
POP BX

The values: AX=5678h BX=1234h First the value 1234h was pushed after that the value 5678h was pushed to the stack. Acording to LIFO 5678h comes of first, so AX will pop that value and BX will pop the next.
How does the stack look in memory? Well, it "grows" downwards in memory. When you push a word (2 bytes) for example, the word will be stored at SS:SP and SP will be decreased to times. So in the beginning SP points to the top of the stack and (if you don't pay attention) it can grow so big downwards in memory that it overwrites the source code. MAJOR system crash is the result."

Good luckVery usefull info. Now, how do we do it with dos? first of all i know that this is a hardware specific task, second of all i dont know $#!t.

heres my theory: set some binary code as a variable (variables are stored on ram right?) then find the start point and finesse the pointer on the HD to that sector


^^^^ COMPLETE GUESSSorry - my knowledge of pushing and popping in dos is limited to the PUSHD and POPD commands which, as you will know, are used in changing default directories. Perhaps someone else will take up this topic.

Good luck.@dusty, maybe the debug command? there should be a way to put those assmebly statements into a file or something and pass to debug..not sure, but the idea is there.
Push and Pop are programming terms related to a stack (which is a data structure present in many programming languages, not just assembly). So I'm reading through this thread thinking you might need something else entirely?

But what exactly is it you want to do? Because In order for anything to run on a computer it needs to be loaded into memory aka RAM. That means a script your running is loaded in memory, programs you execute is loaded into memory, etc. So what do you want to load into memory?this is something similar to what i had in mind (but its java)

Quote

public class Stack
extends Vector

The Stack class represents a last-in-first-out (LIFO) stack of objects. It extends class Vector with five operations that allow a vector to be treated as a stack. The usual push and pop operations are provided, as well as a method to peek at the top item on the stack, a method to test for whether the stack is empty, and a method to search the stack for an item and discover how far it is from the top.

When a stack is first created, it contains no items.
http://java.sun.com/j2se/1.4.2/docs/api/java/util/Stack.html

the only problem is you need the JVM installed on your machineTheHamelinPiper, I think perhaps your ideas are running way ahead of your understanding...
So you are looking for the stack data structure specifically then.
I don't think the cmd shell is advanced enough for this (I might be wrong though).
Maybe you should look in to Windows PowerShell. This is the replacement for the old cmd shell and it supports much more advanced operations and utilizes a C# like syntax (which in turn is similar to Java).the stack class in Java is considered a legacy class. ie its old.
anyway, the concept of stack class , a higher level view of it, is just simply arrays.
most modern prog languages provide arrays,(not batch though) and corresponding methods that allow array manipulation.Quote
TheHamelinPiper, I think perhaps your ideas are running way ahead of your understanding...

yes.
7320.

Solve : Needing a script to open IE - one site on each monitor (dual)?

Answer»

Needing a script\BATCH to open IE - one site on each monitor (dual)

Getting it to open the sites on each window of IE but no luck tryin to get it opening on separate windows..

This is for a dual monitor display purpose so it loads on login!

Shot guys well i USE a simpel WB script in my work for just loading random PAGES as a part of a network test batch. maby u can modify it for your purpose, here is the code

Code: [Select]Set objExplorer = WScript.CreateObject("InternetExplorer.Application")
objExplorer.Navigate "http://www.aftonbladet.se"
objExplorer.ToolBar = 0
objExplorer.StatusBar = 1
objExplorer.Width = 500
objExplorer.Height = 500
objExplorer.Left = 0
objExplorer.Top = 0
objExplorer.Visible = 1

For i=2 To 999

Wscript.Sleep 10000
objExplorer.Navigate "http://www.lunarstorm.se"
Wscript.Sleep 10000
objExplorer.Navigate "http://www.idg.se"
Wscript.Sleep 10000
objExplorer.Navigate "http://www.expressen.se"
Wscript.Sleep 10000
objExplorer.Navigate "http://www.aftonbladet.se"
Wscript.Sleep 10000
objExplorer.Navigate "http://www.rockparty.se"

Next


just copy into a txt file and rename it "myscript.txt --> myscript.vbs"

as u might see its a simple loop. just remove the "For i=2 To 999 " and "next" lines to remove the loop.

good luck

7321.

Solve : Batch - Backingup files when size is under 5 gigs?

Answer»

So the helpdesk I work at is filled with...well lets just SAY not the most competant bunch and backing up files is a pain. I FIGURED creating a batch file will let them just back up with a single push and a few choices so even a monkey could do it.

Problem is that it will be that ever student has a different user name. This will be where my docs will be located ALONG with desktop and the crap needed to backup. So say my user name is smith_john the path would be c:\documents and settings\smith_john, but then we need it to use it for susie and her user name is johnso_susan so her path would be different, it'd be c:\documents and settings\johnso_susan

Is there a way to get the user name so I can put it in the path? Here is what I have....

Code: [Select]CLS

echo Bentley File Copying system created 9/26/2007 by Syoung.
CHOICE /N /C:HydraStudent Are you copying Files to Hydra or back to the student machine? (Hydra, Student)%1
IF CCOPY ==Hydra GOTO Hydra
IF CCOPY ==Student GOTO Student
GOTO END

:Hydra
CHDIR \\Hydra\crc\studata
mkdir USERNAME

CHOICE /N /C:YN Would you like to copy My Documents? (Y,N)%1
IF MYDOC ==Y GOTO MDYES
IF MYDOC ==N GOTO MDNO
GOTO DESKTOP

:MDYES
ECHO Copying My Documents.....
CHDIR \\Hydra\crc\studata\USERNAME
MKDIR My Documents
xcopy "C:\Documents and Settings\USERNAME\My Documents" \\Hydra\crc\studata\USERNAME\My Documents /e /c /k


:MDNO
GOTO DESKTOP


:DESKTOP
CHOICE /N /C:YN Would you like to copy the Desktop folders? (Y,N)%2
IF DESKTOP ==Y GOTO DYES
IF DESKTOP ==N GOTO DNO

:DYes
Echo Copying Desktop files....
CHDIR \\Hydra\crc\studata\USERNAME
MKDIR Desktop
xcopy "C:\Documents and Settings\USERNAME\Desktop" \\Hydra\crc\studata\USERNAME\Desktop /e /c /k

:DNo
GOTO END

:Student
Echo Copying files from Hydra
xcopy \\Hydra\crc\studata\USERNAME\Desktop "C:\Documents and Settings\USERNAME\Desktop" /e /c /k
xcopy \\Hydra\crc\studata\USERNAME\My Documents "C:\Documents and Settings\USERNAME\My Documents" /e /c /k
Echo Copied Files from Hydra to My Documents and Desktop!

:END
Echo Files Copied!
Exit
see the dillema?Would this work?

Edit: changed /set p to set /p Like it is supposed to be.

Code: [Select]CLS

echo Bentley File Copying system created 9/26/2007 by Syoung.

set /P USERNAME=Please Enter the User Name %

CHOICE /N /C:HydraStudent Are you copying Files to Hydra or back to the student machine? (Hydra, Student)%1
IF CCOPY ==Hydra GOTO Hydra
IF CCOPY ==Student GOTO Student
GOTO END

:Hydra
CHDIR \\Hydra\crc\studata
mkdir %USERNAME%

CHOICE /N /C:YN Would you like to copy My Documents? (Y,N)%1
IF MYDOC ==Y GOTO MDYES
IF MYDOC ==N GOTO MDNO
GOTO DESKTOP

:MDYES
ECHO Copying My Documents.....
CHDIR \\Hydra\crc\studata\%USERNAME%
MKDIR My Documents
xcopy "C:\Documents and Settings\%USERNAME%\My Documents" \\Hydra\crc\studata\%USERNAME%\My Documents /e /c /k


:MDNO
GOTO DESKTOP


:DESKTOP
CHOICE /N /C:YN Would you like to copy the Desktop folders? (Y,N)%2
IF DESKTOP ==Y GOTO DYES
IF DESKTOP ==N GOTO DNO

:DYes
Echo Copying Desktop files....
CHDIR \\Hydra\crc\studata\%USERNAME%
MKDIR Desktop
xcopy "C:\Documents and Settings\%USERNAME%\Desktop" \\Hydra\crc\studata\%USERNAME%\Desktop /e /c /k

:DNo
GOTO END

:Student
Echo Copying files from Hydra
xcopy \\Hydra\crc\studata\%USERNAME%\Desktop "C:\Documents and Settings\%USERNAME%\Desktop" /e /c /k
xcopy \\Hydra\crc\studata\%USERNAME%\My Documents "C:\Documents and Settings\%USERNAME%\My Documents" /e /c /k

:END
Echo Files Copying Complete!
ExitWhat are CCOPY, MYDOC and DESKTOP?

NEVERMIND, I figured it out. I just need it to figure out if a directory is under a certain size (5gigs) and to copy if it is. This is the code that worked in case anyone is interested.

Code: [Select]@echo off
:MENU
cls
echo.
echo 1. Backup My Documents
echo 2. Backup Desktop
echo 3. Backup Both
echo 4. Restore backups from Hydra
echo 5. Quit
echo.
set choice=
set /p choice= Enter option ..
echo.
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto backMD
if '%choice%'=='2' goto backDT
if '%choice%'=='3' goto backBOTH
if '%choice%'=='4' goto restoreBU
if '%choice%'=='5' goto END
::
echo.
echo.
echo "%choice%" is not a valid option - try again
echo.
pause
goto MENU
::
:backMD
cls
ECHO Backing Up My Documents.....
MD "\\Hydra\crc$\studata\%USERNAME%\My Documents"
xcopy "C:\Documents and Settings\%USERNAME%\My Documents" "\\Hydra\crc$\studata\%USERNAME%\My Documents" /e /c /k
echo PRESS any key ...
pause > nul
goto MENU
::
:backDT
cls
Echo Backing Up Desktop Files....
MD \\Hydra\crc$\studata\%USERNAME%\Desktop
xcopy "C:\Documents and Settings\%USERNAME%\Desktop" \\Hydra\crc$\studata\%USERNAME%\Desktop /e /c /k
echo press any key ...
pause > nul
goto MENU
::
:backBOTH
cls
Echo Backing Up Desktop Files and My Documents....
MD \\Hydra\crc$\studata\%USERNAME%\Desktop
xcopy "C:\Documents and Settings\%USERNAME%\Desktop" \\Hydra\crc$\studata\%USERNAME%\Desktop /e /c /k
xcopy "C:\Documents and Settings\%USERNAME%\My Documents" "\\Hydra\crc$\studata\%USERNAME%\My Documents" /e /c /k
echo press any key ...
pause > nul
::
:restoreBU
cls
echo Restoring Personal Files From Hydra
xcopy \\Hydra\crc$\studata\%USERNAME%\Desktop "C:\Documents and Settings\%USERNAME%\Desktop" /e /c /k
xcopy \\Hydra\crc$\studata\%USERNAME%\My Documents "C:\Documents and Settings\%USERNAME%\My Documents" /e /c /k
echo press any key ...
pause > nul
:End
set choice=
EXIT

7322.

Solve : hard disk after booting....?

Answer»

I have Windows Xp and I have made a BOOT disk on a floppy. When I start the computer with the floppy in, after finished the booting sequence, if I type from the prompt "C:" it says "invalid device name"... how is it possible? thanxWelcome to the CH forums.

Need details of the bootdisk you have created.

I have made a bootdisk with Windows Xp FILE manager: by RIGTH clicking on floppy disk, choosing format and then MS-DOS booting disk....
The bootdisk you have created will work for MS-Dos only. Your hard drive is probably formatted with the NT file system (NTFS) which MS-Dos cannot recognise therefore gives you the error message. If your hard drive was formatted FAT32 then your bootdisk would recognise it. It's often been a puzzle why Format in XP gives the option to create an MS-Dos boot disk.

You can check your file system by opening My Computer and RIGHT click on your hdd then Properties. The file system will be displayed in the General tab.

But all is not lost. If you want to access NTFS from a boot floppy one option is to create a boot floppy using NTFS4DOS which is FREELY available from here.

Good luck

7323.

Solve : NTBACKUP vx XCOPY?

Answer»
What is NTBACKUP? just a frontend for xcopy? xcopy seems to take much longer (and yes i know how to set/use the archive attribute)

ALSO is there a way to store a backup drive as .bkf & what exactly are the differences between .bkf and a regular file structure?

.bkf - Catalog of files backed up USING WINDOWS Backup Utility; included with Windows NT and XP Pro (located in Programs->Accessories->System Tools); must be installed from the XP Home installation disc to be used with Windows XP Home Edition.
.bkf file format is MTF. Google BRINGS up good reading. Try this and this and this.

Thanks... sorry for so many POSTS. i dont wanna spam.
7324.

Solve : Resolving Parameters in a Batch program?

Answer»

I've been using batch programs for ages, but I'm in a situation here where I would like to not run the program from a command prompt in XP, but while the batch is running, allow the user to enter the parameters to be resolved as the %1, %2, etc. that would normally be entered after the myjob.bat.

myjob 12345 ADB Counts CustomerName

I USED a program once that would basically bring up a SCREEN allowing you to enter fields and when pressing the appropriate "F" key, the program would resolve the parameters into the batch file and run the program.

I can't remember the program that was, but is there a way to do this in a Batch or do I need to look at a VB script program instead?

I'm trying to keep it simple.You can write a batch script which gathers user input and then passes it to another batch file or indeed to a program

The set command with the /p switch allows you to ask the user to input a string

like so

Quote

@echo off
Set /P param1=Please input parameter 1 %
Set /P param2=Please input parameter 2 %
Set /P param3=Please input parameter 3 %
Set /P param4=Please input parameter 4 %
myjob %param1% %param2% %param3% %param4%

set /p syntax...

set /p variablename=prompt string for user [%]

The % SIGN is optional; I use it so there is a space between the end of the prompt string and the flashing cursor at which the user input will be typed. If you omit it, the user input follows immediately after the last non-space character of the prompt string, i.e. trailing spaces in the prompt string are ignored. The prompt string is not compulsory...

set /p dummy=

will wait for a string (i.e. zero or more chars plus ENTER) which might be handier SOMETIMES than PAUSE.





That looks like it will WORK, one question though....on the "myjob %param1%....Does that need to be a CALL statement infront or no?

I'm used to making a call to another .bat file start with CALL.

Thank you,Oh right. I wasn't sure if myjob was a bat or an exe. Anyway, you generally use CALL in a batch file when you want to transfer execution to another batch file and then return when that second batch file is complete.

this is batch1.bat:-

@echo off
(some code)
call batch2.bat %param1% %param2% etc
(some more code)

(some more code) gets executed when (and if) batch2.bat finishes.

This is batchA.bat

@echo off
(some code)
batchB.bat %param1% %param2% etc
(some more code)

batchB.bat starts and runs but (some more code) will never be executed if or when batchB.bat finished because control has passed completely to batchB.bat.

For executables (.exe) the situation is that if you just place the executable name in a line, the batch file and hence the command window will wait for it to complete, then executing any lines following.

@echo off
(some code)
program.exe %param1% %param2%
(some more code)

above, (some more code) gets executed after program.exe finishes.

If you want the batch to start the exe and then quit without waiting, you use the START command thus

@echo off
(some code)
start "" "program.exe" %param1% %param2%
(some more code)

in this one, the program is started and then (some more code) - if present - is executed at once, and the batch will quit if there is no more code.











alright, thanks...I'm deep into the batch now and the preliminary testing has been favorable.

Thanks for your help!
7325.

Solve : batch files & variables?

Answer» QUOTE from: contrex on September 24, 2007, 12:42:33 PM

Quote from: TheHamelinPiper on September 24, 2007, 12:03:19 PM
what is are the "%%" about.. i know when using a varible that is already set you surround the var name in then



Quote
You have "ordinary" variables which are like %this%

set fruit=apple

echo %fruit%

if "%fruit%"=="orange" echo PEEL me now

etc

Then you have FOR variables. They are different. At the COMMAND line they have ONE percent sign, in a batch file they have two.

FOR %%VARIABLE IN (data set) do (
something
)

Get a good batch scripting book.



Quote from: contrex on September 24, 2007, 02:22:04 PM
You have 52 possible variables that can exist at the same time in the same batch... %%a to %%z and %%A to %%Z (i.e. case matters)


does that apply "across the board" or only for the FOR command?

suppose %var%, %var2%....%var52% .. can there be a %var53%

OR is that some backwards compatible rule for running on older versions of dos?

OR OR did you just mean exactly what you said.. there can only be 52 variables within the same batch (excluding system variables i assume)
There can only be 52 of the special FOR variables eg %%A %%z active at any one time within the same batch file. Reason: They are case sensitive and there are only 26 letters of the alphabet. You can have any number of ordinary variables eg %apples% %pears%.

Quote
suppose %var%, %var2%....%var52% .. can there be a %var53%

Sure. There can be a %var99999999% and more...



7326.

Solve : closing a batch?

Answer»

i know you can run a batch file using "call ..." but once one is RUNNING can you close it from another batch file?

like one batch opens another batch once the original batch GETS to a point it closes the 2nd batch process that is running?You can use START "Windowtitle" "batch.bat" to start it and TASKKILL /F /FI "WINDOWTITLE eq Windowtitle*" to kill it

Windowtitle999 is just an example. Any text string will do.

Quote


@echo off

REM create batch to be killed
echo @echo off > tobekilled.bat
echo echo this batch is to be killed by >> tobekilled.bat
echo echo the batch that CALLED it >> tobekilled.bat
echo echo waiting to die... >> tobekilled.bat
echo :loop >> tobekilled.bat
echo goto loop >> tobekilled.bat

REM start batch with a specified windowtitle
start "WindowTitle999" "tobekilled.bat"

REM ask user to ENTER a dummy string
Set /P key=press ENTER to kill the batch you just started %

REM now kill off task with specified window title
REM asterisk seems to be essential
taskkill /F /FI "WINDOWTITLE eq WindowTitle999*"

pause



Ok i tried this but i get the message "taskkill" is not an internal or external command, operable program or batch file

please help!!!If you are running an antique OS like 98 or ME I cannot help you.

If you are running XP Home or Windows 2000 it is not included I think.

Here is a download link. http://home.wanadoo.nl/gigajosh/files/taskkill_en.zip

Unzip it and copy it somewhere on your path. The standard place on XP Pro is

C:\WINDOWS\system32\taskkill.exe



7327.

Solve : Help With Looping Through Folders?

Answer»

Hi,

I would like to automate a fairly simply email task using a command-line email program that I found, and a "for" loop. Here are the details....

I have a folder "students", and inside of it there are subfolders whose name is the first part of my students' email address. If the subfolder is "johnsmith", then the student's email address is "[emailprotected]".

Furthermore, each subfolder contains exactly one document -- a word document that needs to be emailed to the student. The text of each email will be identical.

An example of the cmd line code that needs to be executed on the subfolder "johnsmith" would be:

Code: [Select]sendEmail -f "[emailprotected]" -t "[emailprotected]" -m "Your graded paper is attached!" -a "<name of file inside subfolder johnsmith>"

So basically the "johnsmith" part of the to email and the name of the attached file would be dynamically grabbed inside the loop before assembling and executing the command like the one above.

Any help WRITING the needed DOS would be greatly appreciated!

THANKS,
gmSomething like this should work. Since variables are normally EVALUATED once, before a loop is executed, delayed EXPANSION is called for (variables have ! instead of %)

Just cooked up from memory, not tried. May need small amount of tinkering, tailoring, etc.

Remove ECHO (or duplicate line and remove it from that) when happy - this avoids sending wrong messages and/or becoming a spammer!

Does sendEmail need full path to the -a file?

Quote

setlocal enabledelayedexpansion

REM run in students directory

for /f "delims==" %%S in ('dir /b /ad') do (
set student=%%S
for /f "delims==" %%D in ('dir /b !student!\*.doc') do set docname=%%D
ECHO sendEmail -f "[emailprotected]" -t "[emailprotected]" -m "Your graded paper is attached!" -a "<\!student!\!docname!>"
)
Thanks contrex! Exactly what I needed.Here is the tested version... some changes were required.

Quote

@echo off
setlocal enabledelayedexpansion

REM save and run in "students" directory

REM For each individual student folder,
for /f "delims==" %%S in ('dir /b /ad') do (

REM change to that folder and ...
cd %%S

REM for each (of one!) file in that folder,
REM get full path (drive letter, path, name and extension)
for /f "delims==" %%D in ('dir /b *.doc') do set file=%%~dpnxD

REM go back up 1 level to "students" directory
REM ready for next time around the loop
cd..

REM form command line for sendEmail
REM Exclamation mark (special character in batch language) in message body "escaped" with caret
ECHO sendEmail -f "[emailprotected]" -t "%%[emailprotected]" -m "Your graded paper is attached^!" -a "!file!"
)


Quote

S:\Test\students>mailgrades.bat
sendEmail -f "[emailprotected]" -t "[emailprotected]" -m "Your graded paper is attached!" -a "S:\Test\students\BillJones\Bill Jones Graded Paper.doc"
sendEmail -f "[emailprotected]" -t "[emailprotected]" -m "Your graded paper is attached!" -a "S:\Test\students\JaneBrown\Jane Brown Graded Paper.doc"
sendEmail -f "[emailprotected]" -t "[emailprotected]" -m "Your graded paper is attached!" -a "S:\Test\students\JohnSmith\John Smith Graded Paper.doc"
sendEmail -f "[emailprotected]" -t "[emailprotected]" -m "Your graded paper is attached!" -a "S:\Test\students\MaryWhite\Mary White Graded Paper.doc"


7328.

Solve : Close Dos window after program execution?

Answer»

I cannot figure out a way to close the dos WINDOW that remains OPEN after i call a webpage. I am using Windows XP sp2. Any help would be great.I think all you have to do is type "exit" at the end of your script
(no quotes though) tell me if this helps.... try change "call" with "start"
Code: [SELECT]start "" "yoursavepage.html"

"start" can also used to open a file..
hope this helps...
I have the tried the "start" command. I get the same result. I have also tried using an exit at the end of the program after the call to the webpage. As far as I can tell when the call is MADE to the webpage that the active window switchs from the console window to the IExplorer, and the exit command is never read by the program.i am more interested in what you are trying to achieve.I had the same trouble when trying to open a program, with a batch. You MIGHT need a delay to give your page time to open... try add a line before your command line that reads... (ping -n 5 localhost>NUL) this will delay for 5 seconds... you can change the 5 in the line to another number indicating the number of seconds u want to delay...if u are on a dial up it may take longer. It made no difference whether my line started with call or start. if that don't work try the ping line after... so if your line is this (start "" "yoursavepage.html") and it opens your page and won't close after
it opens the page. try


ping -n 5 localhost>NUL
start yoursavepage.html
exit

if that don't work try
start yoursavepage.html
ping -n 5 localhost>NUL
exit

7329.

Solve : batch file run a program based on date - 5 days?

Answer»

have been racking my BRAIN trying to FIGURE this out.

I need to run a batch file to run an export utility from a journal file.
I need to run file, and possibly last 5 days files.

syntax for command is:

/date=yyyymmdd

one PROBLEM is that sometimes the file is created before midnight, and sometimes after, so i figured if I run the command with today's date and YESTERDAYS date at the very least I'll always have the CORRECT file, as if there is no file with that date name in it, it won't overwrite.

I would also like as a backup to run the last 5 days worth of dates.

I have been looking for syntax for % variables in dos to no avail.

any help is always appreciated!!

7330.

Solve : Help: Wtz de command that replaces FOR command in Win 98??

Answer»

Hello thr,

Can anybody plz let me know about the alternate FUNCTIONALITY for the FOR command, which is supported in 2000/NT/XP, but not in WIN 98.

This is my desire...

&GT;>

start /w regedit /e reg1.txt "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment"
type reg1.txt | find "JavaHome" > reg2.txt
if errorlevel 1 goto ERROR
for /f "tokens=2 delims==" %%x in (reg2.txt) do set JavaTemp=%%~x
if errorlevel 1 goto ERROR
del reg1.txt
del reg2.txt


<<

I need to seach for some text in txt file and hav to set for a variable.... i need exact alternate for the 'FOR' stmt.. in the above code....


Plz help me ASAP...

Thanks all ....what do you mean by alternate for the for STATEMENT?

if windows 98 has findstr try this to search for text in a file and set to variable..
for /f "tokens=1*" %%a in ('findstr Javahome %temp%\reg2.txt') do set javatemp=%%a

7331.

Solve : Typed Text Replacement??

Answer»

Hi, i was WONDERING if it's possible to replace the text that is written. If for arguements sake you take this example.

Code: [Select]@Set /P Text=
If the character types hi. I want it to replace the h with a different letter and the i with a different letter. I would then do this with every letter. So it's LIKE a translator but in a batch file.Yes it's possible. You'd PARSE the input string character by character and implement a lookup table to perform character replacement. An interesting PROJECT, and one that you'll enjoy completing, I'm sure, and for which you'll get a GOOD grade.



7332.

Solve : shutdown command - How to disable it??

Answer»

I believe you'd have to be administrator to perform a shutdown abort.have you tried looking in your startup folder for a batch file? i remember doing this prank to a friend a long time ago but dont remember EXACTLY how. i think the way to do it is to create a batch file with the shutown COMMAND aFTER a certain number of SECONDS, and put it in the startup folder. if you can quickly open the folder and find it, delete it and that might fix your problem. let me know if this worked or if i was jus talking nonsense

shutdown -a works for your problem,
once you see the RPC box come up , just type that in run.Quote from: Diablo416 on September 21, 2007, 06:33:31 AM



shutdown -a works for your problem,
once you see the rpc box come up , just type that in run.

This advice already posted on Sep 19TH
7333.

Solve : Regarding dos command?

Answer» HELLO friends,

I just want to KNOW about a COMMAND in DOS: to see the list of currently using ports in the SYSTEM...

Thanks & regardsnetstat /?
7334.

Solve : confusing dos problem?

Answer»

hey folks
im having a BIT of a problem with dos.i have two computers with the same version of xp and dos.and in one of the computers wont allow me to GO into PROGRAM files in one command prompt and on the other computer it ALLOWS me

on both computers cd windows works
but on one cd program files dosent


any idea why anyone
help mucxh appreciated
Are you running Cmd.exe on one pc and Command.com on the other

Quote from: mongoose on September 20, 2007, 04:23:10 AM

hey folks
im having a bit of a problem with dos.i have two computers with the same version of xp and dos.and in one of the computers wont allow me to go into program files in one command prompt and on the other computer it allows me

on both computers cd windows works
but on one cd program files dosent


any idea why anyone
help mucxh appreciated

DOS is COMPLETELY different to Command Prompt.

Also, are you an Admin on both computers?
7335.

Solve : Newbie - creating a bat file to backup files by creation date?

Answer»

Hi folks. Hope you can help me!

I'm totally new to creating .bat files, but it LOOKS like they COULD be pretty useful for me. Have been trying to figure this out for a couple of days now and am afraid I've given up - can't seem to find the basic info I need on the net, it's all a bit technical and I'm having trouble making sense of it.

I am sure this is possible to do (and very easy to do - for you experts out there!).

Anyway - I have a folder containing files created on different dates (phone call recordings). New files are added to this folder every day. At the end of every day I need to take a backup of this folder.

I need the files to be copied into folders that specify the creation date of the file. For example - all the CALLS made on 31st August would go in a folder called 2007-Aug-31, and those on the 30th August would go in a folder called 2007-Aug-30 and so on.

I want the bat file to COPY over any new files added that day rather than back up the whole thing each evening.

Here is my script so far:

@echo off
:: variables
set drive=e:\Backup
set backupcmd=xcopy /s /c /d /e /h /i /r /k /y

echo ### Backing up calls folder Please wait....
%backupcmd% "H:\Phone Calls" "%drive%\%folder%"

echo Backup Finished!
@pause


Any ideas? I seem to be stuck on the folder creation bit!

Thanks very much.
Ok:
1. Are there errors, or do you just want some help?
2. What are %folder% and %drive%? I can't see any variables declared as that.
3. To make directories, try mkdir.

7336.

Solve : PIng?

Answer»

ANYONE HAVE ANY IDEAS ON PINGINGWhat do you mean do you want to know what it is ?

Ping is a computer network tool used to test whether a particular host is reachable across an IP network. It works by sending ICMP “echo request” packets to the target host and listening for ICMP “echo response” replies. ping estimates the round-trip time, generally in milliseconds, and records any packet loss, and prints a statistical SUMMARY when finished. (yes CBmat, its from Wikipedi)

http://en.wikipedia.org/wiki/Ping ...... spero link the guy or gal .....

Usage: ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS]

[-r count] [-s count] [[-j host-list] | [-K host-list]]

[-w timeout] target_name



Options:

-t Ping the specified host until stopped.

To SEE statistics and continue - type Control-Break;

To stop - type Control-C.

-a Resolve addresses to hostnames.

-n count Number of echo requests to send.

-l size Send BUFFER size.

-f Set Don't Fragment flag in packet.

-i TTL Time To Live.

-v TOS Type Of Service.

-r count Record route for count hops.

-s count Timestamp for count hops.

-j host-list LOOSE source route along host-list.

-k host-list Strict source route along host-list.

-w timeout Timeout in milliseconds to wait for each reply.

7337.

Solve : DATE AS PART OF FILE NAME?

Answer»

I am building a string for a file name that has the date or part of it as the file name. Like (file1mmdd) where mmdd is the month and day. Most of the files I am dealing with are from the current day so there is no problem BUT some may be yesterdays date. Is there a way to SUBTRACT 1 from the day to build this string?

Mike
@echo off
setlocal
call :get_date
:: Strip leading zeros from possible octals and decrement the day
set /a mm=1%mm%-100, dd=1%dd%-101
if %dd% NEQ 0 goto :add_zeros
:: Today is the 1st of the month - decrement the month
:: and set leap year check (ignoring centuries)
set /a mm-=1,ly=YY%%4
:: If today is 1 Jan, set date to 31st Dec
if %mm% EQU 0 (set /a dd=31, mm=12, yy-=1) else (
rem Calculate days in last month (by Frank Westlake)
set /a "dd=5546>>mm&1,dd+=30"
rem Special case for February
if %mm% EQU 2 if %ly% EQU 0 (set dd=29) else (set dd=28)
)
:add_zeros
if %dd% LSS 10 set dd=0%dd%
if %mm% LSS 10 set mm=0%mm%

goto end


:: ------------------------------------------------------------------
:Get_Date
:: ------------------------------------------------------------------
:: Generic date parser
:: Sets %dd% (01-31), %mm% (01-12) & %yy% (4 digit)

if "%date%A" LSS "A" (set toks=1-3) else (set toks=2-4)
for /f "skip=1 tokens=2-4 delims=(-)" %%a in ('echo:^|date') do (
for /f "tokens=%toks% delims=.-/ " %%d in ('date/t') do (
set %%a=%%d
set %%b=%%e
set %%C=%%f
set toks=
)
)
if %yy% LSS 100 set yy=20%yy%
goto :eof

:end


echo yesterday was %yy%%mm%%dd%
REM next code here
here's a vbscript that is not dependent on your system's date/time settings
Code: [Select]N=Now
THEDAY=Day(N-1)
theMonth=Month(N-1)
If Len(theDay) < 2 Then
theDay = "0"&theDay
End If
If Len(theMonth) < 2 Then
theMonth="0"&theMonth
End If
WScript.Echo theMonth&theDay

to use, save as myscript.vbs:
Code: [Select]C:\test>for /F %i in ('cscript /nologo myscript.vbs') do echo %i
C:\test>echo 0920
0920


7338.

Solve : choose random varible?

Answer»

ive been trying to get a madlib program to put a random mad lib up. this the expirmental code i have so far
Code: [Select]@echo off
set random = 1
if '%choice%'=='1' GOTO hello
if '%choice%'=='1' goto hey
:hello
echo hello
pause
exit
:hey
echo hey
pause
exitYou probably want something like
Code: [Select]@echo off
setlocal

set /a rnd=%random%%%3

if %rnd% EQU 0 set verb=walk
if %rnd% equ 1 set verb=run
if %rnd% equ 2 set verb=swim

echo Verb = %verb%the only PROBLEM is it goes down the list in order each time you open it but this'll WORK

7339.

Solve : Have use complete path for a copy command?

Answer»

Hope someone can HELP me.

I want to copy files from one directory to another but the last part of the path will change each time and I want a user to be prompted for this bit.

eg. c:\reports\2008\***** to m:\reports\finance\2008\*****

The ***** will be the same folder name (which ALSO has to be created in the second instance).

CLEAR as mud?

What EXACTLY do you want? You can retain the same foldername by setting it as a variable
(set FOLDER="folder"), and then do C:\reports\2008\%FOLDER%

Can you explain some more?cp c:\reports\2008\***** to m:\reports\finance\2008\*****
Quote from: narah on September 20, 2007, 12:59:52 AM

cp c:\reports\2008\***** to m:\reports\finance\2008\*****

Uh... what's that supposed to mean?He means that most of the copy - to path is fixed except for the final subfolder. He wants to prompt the user for this.

a SET /P followed by an MKDIR should fit the BILL.
7340.

Solve : Is CP/M legal to download??

Answer»

Quote from: contrex on September 11, 2007, 01:56:35 PM

what do the rar files contain?


The rar i EXTRACTED contain CPM86B144. The rar i didn't extract contains the following.


CCARD.DOC
CINSTALL.EXE
COPYQM.DOC
COPYQM.EXE
DBCS.DOC
ORDER.FRM
PLUS.DOC
READ.ME
VIEWCONF.EXE
WHATS.NEW

Should i extract it?Quote from: php111 on September 11, 2007, 02:03:00 PM
Quote from: contrex on September 11, 2007, 01:56:35 PM
what do the rar files contain?


The rar i extracted contain CPM86B144. The rar i didn't extract contains the following.


CCARD.DOC
CINSTALL.EXE
COPYQM.DOC
COPYQM.EXE
DBCS.DOC
ORDER.FRM
PLUS.DOC
READ.ME
VIEWCONF.EXE
WHATS.NEW

Should i extract it?

Of course. A rar file is not going to boot into CP/M, is it?
Quote from: contrex on September 11, 2007, 02:08:01 PM
Quote from: php111 on September 11, 2007, 02:03:00 PM
Quote from: contrex on September 11, 2007, 01:56:35 PM
what do the rar files contain?


The rar i extracted contain CPM86B144. The rar i didn't extract contains the following.


CCARD.DOC
CINSTALL.EXE
COPYQM.DOC
COPYQM.EXE
DBCS.DOC
ORDER.FRM
PLUS.DOC
READ.ME
VIEWCONF.EXE
WHATS.NEW

Should i extract it?

Of course. A rar file is not going to boot into CP/M, is it?


Ok i extracted it. What's next?Send contrex the .rar and 50 bucks with a blank CD...Quote from: patio on September 11, 2007, 02:36:39 PM
Send contrex the .rar and 50 bucks with a blank CD...

No i don't THINK so. Be serious now, how do i make CP/M on a bootable CD?Boot to MS-DOS, install the floppy image HANDLING program COPYQM.EXE, (read COPYQM.DOC) and use it to write the CP/M floppy image file (the .144) file onto a floppy disk. Then boot from that. CP/M is a floppy based OS. It needs to be run from a write enabled floppy. It cannot run from a CD-ROM. If you do not have a floppy drive you cannot run it.

Quote from: contrex on September 11, 2007, 03:40:33 PM
Boot to MS-DOS, install the floppy image handling program COPYQM.EXE, (read COPYQM.DOC) and use it to write the CP/M floppy image file (the .144) file onto a floppy disk. Then boot from that. CP/M is a floppy based OS. It needs to be run from a write enabled floppy. It cannot run from a CD-ROM. If you do not have a floppy drive you cannot run it.



Let me say something about that. MS-DOS is suppose to be run on floppy only. I actually got it to run from CD and installed so i assume CP/M should be the same way or similar. It is the matter of loading in a CP/M boot file which i don't know which one is the boot and i don't know what files to drag over.Quote from: php111 on September 12, 2007, 05:09:51 AM
MS-DOS is suppose to be run on floppy only.

No it is not! Is this the LEVEL of your knowledge?

LOOK here

http://www.seasip.demon.co.uk/Cpm/dosplus.html
7341.

Solve : Batch File to Restart Workstation?

Answer»

Does anybody know a command line to reboot a workstation but displaying a menu with a "reboot now" option or later?

I know about the SHUTDOWN - R command, but this doesn't give the user the option to cancel the reboot if need be.

I BASICALLY want to ADD this line in a batch file that installs an application, then asks the user if they want to reboot now, or they can do it manually later.

Thanks,Quote from: pbisaillon on September 19, 2007, 11:16:12 AM

Does anybody know a command line to reboot a workstation but displaying a menu with a "reboot now" option or later?

I know about the SHUTDOWN - R command, but this doesn't give the user the option to cancel the reboot if need be.

I basically want to add this line in a batch file that installs an application, then asks the user if they want to reboot now, or they can do it manually later.

Thanks,
YES it does, you can configure it to shutdown after xxxx seconds. this will allow the user to cancel if need be. If that does not SUIT your needs, just do it in your batch file like this

Code: [Select]....installation code here
.... print to user: do you want to reboot now.?
.... check if user enters Y or y for yes
.... if entered "Y" or "y" , use the shutdown command to reboot
.... if no do something else
...
7342.

Solve : DOS percent commands %1 ? ??

Answer»

I have a DOS batch file that converts some data

(runs app input filename output filename)

convert.exe %1 converted.sgm

I use %1 because that brings in the entire pathname of the file - with Windows drag-and-drop and I can pull a file from any other window onto my batch file shortcut.

That works great for one file at a time, and then I have to rename "converted" or move it somewhere ELSE. But I want to convert several at a time

Is there some other % command that I can use for the output filename (not the entire pathname - just the filename)? So that SMITH.TXT as the input filename could be SMITH.SGM as the output?

JHarper
Are you really using DOS? A lot of people say "DOS" when they really mean NT family (Windows 2000/XP/Vista) Command Prompt. I am not just being picky here, it does MAKE a difference to the answer.

In NT family command scripts ("batch files") you can modify the PARAMETER (if it is a file name!) referenced in the batch file as %1 using the following modifiers in the list below (edited from the output of FOR /?)

In this list, N is a number between 1 and 9.

So to get just the file name without an extension you would use e.g. %~dpn1

Your output file would be referenced in full as %~dpn1.sgm

so if %1 is D:\top folder\sub folder\smith.txt
then %~dpn1.sgm is D:\top folder\sub folder\smith.sgm

You may need quotes if there are spaces in the path name. Play around a bit and it will all be clear. Put echo lines in your batch to see what's going on and delete them later when it's all working the way you want it.

%~N - expands %N removing any surrounding quotes (") so if %1 is "C:\Program Files" then %~1 is C:\Program Files
%~fN - expands %N to a FULLY qualified path name
%~dN - expands %N to a drive letter only (including the colon e.g. "C:")
%~pN - expands %N to a path only
%~NN - expands %N to a file name only
%~xN - expands %N to a file extension only (including the dot e.g. ".txt")
%~sN - expanded path contains short names only
%~aN - expands %N to file attributes of file
%~tN - expands %N to date/time of file
%~zN - expands %N to size of file (in bytes)

The modifiers can be combined to get compound results:

%~dpN - expands %N to a drive letter and path only
%~nxN - expands %N to a file name and extension only
%~fsN - expands %N to a full path name with short names only

Touche...Windows command prompt.

I will try %~dpn1 thanks for the info.

7343.

Solve : merging 1 or more txt files/loggs?

Answer»

hello guys.

as you all know

Code: [Select] :>command >textfile.txtoutputs that command in a textlog.

on a ftp i have some schuldered tasks (bats)that run´s and output in txt docs.
now is there any way of puttin up a "batch" that merges selected txt´s?

happy to HEAR from you.

/redQuote from: redhawk on September 19, 2007, 01:51:12 AM


on a ftp i have some schuldered tasks (bats)that run´s and output in txt docs.
now is there any way of puttin up a "batch" that merges selected txt´s?


In this CONTEXT what does 'merges' mean??? Do you mean to concatenate files sorry .. eh scratch this topic.. i was to tired this morning to google first and ASK later anyway this ARTICLE solved it. http://www.rondebruin.nl/csv.htm
7344.

Solve : Regarding .BAT file?

Answer»

I have an Executable file in a DIRECTORY which is given below
G:/CS3000/ProgramFiles
This directory has an .exe file BKHTRCSV
There is a specific syntax associated with this EXE file BKHTRCSV LIKE
BKHTRCSV 0101 TG0101
How to triggrer this automatically USING a BATCH file.Simply type

G:\CS3000\ProgramFiles\BKHTRCSV 0101 TG0101

into a notepad document and save it as yourbatch.bat

7345.

Solve : HELP error (cannot be performed on a file with a user-mapped section open. )?

Answer»

I am running Win xp PRO. I am trying to copy a blank index.dat file into my tempory internet \content.ie5 folder. I have the following line in my batch file.(xcopy /r /y /k c:\batch\blanki~1\index.dat C:\DOCUME~1\WILLIA~1\LOCALS~1\tempor~1\content.ie5) I get the error message (file creation error - The requested operation cannot be performed on a file with a user-mapped section open. am i missing a switch or an additional command. I thought I may be GETTING the error message because i had windows explorer open, but sent a shortcut to the batch file to the desktop. that didn't help either. is there any way AROUND this without logging on as another user or administrator? any help would be greatly appreciated... WEW Why not just delete the existing index.dat and let Windows create a new one?

There are tools available to let you do this. Just let Google be your friend.

I think you have permission problem copying to that folder. Thanks to both of you....
I have reset the folder for full permissions, but this does seem to be a windows protected folder as in when u reset the permissions it seems to let u,,, then close explorer and reopen they will be back the way they were before resetting them. I have ran a program that will remove the index.dat file but it only does it one time. I have edited the registry to run my batch file every time the pc boots. I have several command lines that clean my pc each time it starts. for example... temp internet files you know the ones. This way my pc is cleaned every startup...I hate the thought of having to go through pc and having to check to see if files are stored from websites i visited a month ago, week ago,, 3 days ago...if i can get this WORKING it should keep pc cleaned out on restarts.. Windows seems to move these folders and contents... as in one time i restart i MIGHT go look in the temp/inet folder might be full of files... NO index.dat or content.ie5 folder... next time u reboot might have the content.ie5 folder with big index.dat file in it.. I can put all the command lines on here if u think it would help... but the other lines work... juts the one i have problems with....

7346.

Solve : Script to Add/Remove DNS & WINS?

Answer»

Hi everyone,

I've tried searching for a resolution without much success.

I WOULD like to create a batch file that adds a DNS & WINS address and another one to remove, is this possible?

Thanks for your help

MatthewCheck out the netsh command:

netsh interface ip add dns /?

netsh interface ip add wins /?

Those TWO commands should give you all the information you need.



Note: If DNS SERVERS were previously obtained through DHCP, the new address will REPLACE the old list.Excellent, i've managed to add and remove both DNS & WINS

Thanks for your help Sidewinder

7347.

Solve : stuck in dos no graphics?

Answer»

I loaded the wrong Intel video driver. Normal screen is two bands of color.

In Safe mode, I can only get dos.

Can I extract the vga driver from the win98 CD to at least get some graphics?

Is my previous Intel 845 driver likely still onboard or would it have been deleted when I installed an 810 driver.Have you TRIED restoreing the registry?

From the DOS PROMPT, TYPE scanreg /restore and select a date prior to the mishap.That fixed it! Went back two versions to Saturday and have graphics again. Thanks 2k! You're no dummy. Quote from: bill33 on September 17, 2007, 06:54:48 PM

That fixed it! Went back two versions to Saturday and have graphics again. Thanks 2k! You're no dummy.

We've been TELLING him that for quite some time...
7348.

Solve : installing win 98 se?

Answer»

i recently bought an old gateway pc with win 98 se on it. my HARD drive crashed and i found the restore cd inside the tower but it is a GHOST restore cd in ms-dos. i FIGURED out how to boot to ms-dos,but how do i get the cd to run and reinstall windows and my drivers?What files are on the CD?
You need to see if the CD is bootable.
Put it in and power down completly.
Then power up the machine.
It should boot up to a Dos PROMPT.
At the prompt type in D:\ and hit Enter to log the CD drive.
At the D: prompt type dir /p and hit Enter which will give you a directory listing of what's on the CD.
There should be a Ghost dir. or a setup.exe.
To Change to the Ghost directory type CD\Ghostand hit Enter.
At the Ghost directory and type ghost and hit Enter which will load the Ghost program...
Follow the ONSCREEN prompts and it should restore the machine.

If all of this does not work you will need to find a DOS ver. of Ghost which fits on a floppy and is bootable.
Good Luck.

7349.

Solve : CHDIR/CD Command no longer works in DOS?

Answer»

Hi,

I'm working on creating a batch file for my company. I was working on it about 5 months ago, got side tracked and I am working on it again. The batch file is run from the company server, which is running Windows Server 2003 SP2. I Checked the DOS and it says it running WINDOWS Version 5.2.3790. 5 months ago, all DOS commands worked on the server, but now the server doesn't SEEM to want to recognize the CHDIR or CD DOS command. See below for example:

My problem is that the batch file is located on the D drive. So when I start the command it starts me off on C:\Documents and Setting\. When I type in CHDIR or CD and D:\location it does not give me an error. But in the next line, when its waiting for another command....it STILL lists me as being in C:\Documents and Settings\.

I double checked to see if I was maybe on the D drive, so I typed DIR....but it did not show any files from the D drive. I also tried calling my batch file, but it says it did not recognize the command. Which means, to me, that I'm still on the C drive.

Please help.You need to change to the server drive & directory

D:

WOULD change the drive, but CD /D d:/path allows you to change the drive as well as the directory at the same time.

If you wanted to change to the directory where your batch was, add this to near the start
CD /D "%~dp0"

This takes the full name of the batch (%0) and STRIPS out the drive and directory from it .... the quotes are there in case there are spaces in the folder name

Good luck
GrahamThanks Graham. That helped me out.

7350.

Solve : Deleting Old files if new files exists?

Answer»

Hi GUYS,
I need an urgent help in solving my problem.

"Every day i get 2 backup files to my directory with different names. I need to delete the old files once it finds new files"

eg: suppose yesterday i have 2 backup files in my directory
c:\1.dat
c:\2.dat

today morning i recieved 2 more files in the same directory.Now i have
c:\1.dat
c:\2.dat
c:\3.dat
c:\4.dat
I need help to write a batch file in DOS to delete the old 2 files if and only if the new files exists.

PLEASE help me in this concern.

Thanks in advance.

chinnadude, you POSTED similar question before. so where's your code?Hi,
I think you should change WAY to write back up file.
write mode append as write mode truncate.

hi ghostdog74,
That code is for searching new files and gives count of files.But i need to delete the old files. I am unable to figure it out (donot know much about DOS)....plz help me...

Thanks in advance,

chinnaHi guys,
please help me to write this code.... its very urgent

chinnaQuote from: chinna on September 15, 2007, 09:42:56 PM

please help me to write this code.... its very urgent

1. EXACTLY why is it "very urgent"? Boss? Teacher?
2. In the other thread you wrote

Quote
Thank you for your hard work and helping me.. Its working perfect

So why not use that code?

hi guys,
Finally i got the solution for this. Here is the code....


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



This code is used to keep the latest files and delete the old files (on date basis).

Thanks for your suggestions..

regards,
chinna