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.

4201.

Solve : change letter definition in ms-dos?

Answer»

i need to change the driver letter of mi hdd from c: to a: for a test.i don't think you can do this in DOS, or can it? does sombody have an answer?If I recall, MS-DOS had a assign command but that was in the year one and may have only been for floppy drives. Another possibilty is the subst command which suprisingly is still available in XP.

Good luck. alright, i have a question on this then, can you use this to make a DRIVE on your COMPUTER linked to someone elses c drive on another computer... (such as on a network that way you don't have to run from computer to computer and get files off a network drive...) I have tried to do net use, and haven't had much success with that....Quote

alright, i have a question on this then, can you use this to make a drive on your computer linked to someone elses c drive on another computer... (such as on a network that way you don't have to run from computer to computer and get files off a network drive...) I have tried to do net use, and haven't had much success with that....


i think thats impossible in dos, for doing stuff like that you need c++, or am i wrong?

greetz


blackberry it is 100% possible to have full DOS network support.
You can share the NETBIOS over TCP/IP in dos. Just look for Network boot disks. LAN manager etc.

Just like windows, you can create C$ shares in DOS if your network PROTOCOLS are LOADED in dos.
4202.

Solve : help me (drag n' drop)?

Answer»

i tried it with this code:i tried it with this code Code: [Select]
@echo off
for /f "tokens=1-2 delims=." %%i in ('dir *.jar /b') do (
mid2pexe -jar %i.%J -out %i.exe
)

doesn't seem that anything HAPPENS, the command prompt just opens and closes in the blink of an eye with no result.
if u wanna check the thing yourself find the software here
http://kwyshell.myweb.hinet.net/pager.html?Project/Midp2Exe/index.htmland i did change mid2pexe to midp2exe that was a typo in the code i just copy pasted the code above from the previous posttThere is some HOPE yet.. this is the COMPUTER HOPE form.

A simple drag and drop routine..

Create a script and mvoe it to your desktop. (no SHORTCUTS)
have your script handle incoming variables..

Example.
@echo off
echo.
TYPE %1
pause

now drag and drop a text file onto your script.
A dos box will open, lsit the contentst of the text file and then pause.

this is the bassis for what you need.
Just make sure you handle the incoming variables inside the script. then you re-asign them to any other program

4203.

Solve : Missing .dll file?

Answer»

Cannot connect to CERTAIN links in a webpage, my YAHOO Browser will FREEZE and I get get an error message "missing gifview.dll" Have located the file in the internet, but don't know where to install it. Can ANYONE help??Wrong post forum.

But try doing a software repair from the control pannel under "software". find your software title, and CLICK help if available and then click repair if available.

Fot the dll file. jsut save it into C:\WINDOWS\SYSTEM32.
Might also be C:\WINNT\SYSTEM32

4204.

Solve : Command prompt from backend?

Answer»

Dear All,

In my project I wrote code(SYSTEM() call thr' C++) to run command PROMPT .
I want to run command prompt(to run some commands through batch file) in my application.But I don't want to popup the command prompt screen EVERY TIME instead it should run at the backend and give the result.How can it be possible??or can it be run in minimized mode?

Please help me in this regard.

Thanks in advance.

Are you wanting to have it run per a schedule?

If so, you'd want to look at creating a scheduled task to run the batch in the background.

http://www.microsoft.com/technet/prodtechnol/windows2000serv/evaluate/featfunc/taskschd.mspx

Hope that's of some help to you.I don't think there is a way to supress the command prompt window while calling a batch file through the system() function. But since your program is written in C++, can you just code what you want to do?Hi
I am using system call as system("batchfile"); in my c++ program.. by this .. cmd.exe invokes and commands in that batch file RUNS but i don't want to popup the console. Instead batch file should run at the back end.
or I want to run the batch file with the minimized mode of the console.
How can i do that? Please suggest me....

Thanks.

4205.

Solve : string parsing in a textfile (Batch solution)?

Answer»

Hello,

I have have a huge textfile like this: (wget from a php SITE.)


number:name1:name2:orga:phone
number:name1:name2:orga:phone
....

I NEED it as a list like this:

number:name1:name2:orga:phone
number:name1:name2:orga:phone

How can I replace
through a return?

I am looking for a Batch SOLUTION.
(Using a Webbrowser to view and copy and paste is not an option.)

thanks in advance for any help
uli

Uli,

Batch parsing only recognizes single character delimiters. This little script might help you out:

Code: [Select]Const ForReading = 1
Const ForWriting = 2
filespec = "c:\filename.log" ' <== fully qualified name of your file

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(filespec, ForReading)
strData = f.ReadAll
f.Close
set f = fso.OpenTextFile(filespec, ForWriting)
strArray = Split(strData, "<BR>")
For x = 0 to UBound(strArray) - 1
f.Write strArray(x) & vbCRLF
Next

Save script with a VBS extension. You can LAUNCH the script from any batch file by including this line:

call cscript scriptname.vbs

Good luck. 8-)Nice Post Sidewinder. In addition to his great post if you're familiar with PHP you could also create a PHP script using some regular expressions to parse the file and do this for you. Unfortunately I'm more of a Perl man than a PHP man so not that familiar with PHP, but I believe the syntax is very close, espcially when it comes to regular expressions.

Something like the below example may work.
Code: [Select]#Get file into array
open (MYFILE, "<file.txt");
@myfile = <MYFILE>;
close (MYFILE);

$myfile = "@myfile";

#regular expression to replace the <br> tags with a new line.
$myfile =~ s/<br>/\n/g;

#Save output to new file.
open (MYFILE, ">newfile.txt");
print MYFILE "$myfile";
close (MYFILE);


In reguards to a .bat or batch file doing this, parsing and handling data is not something a batch file is really meant to do.It looks like text parsing is possible within a batch file (assuming you use a third-party utility). If you're really wanting to do this through a batch file you may want to use SED.

http://www.student.northpark.edu/pemente/sed/index.htmMany thanks for help.

Sidewinders solution works perfect.

I tried sed before and didn´t really understand how it works.

uli



hi
just curious, anybody uses edlin before. i suppose it has a search and replace function. am not sure whether it is too tedious or even possible to use it to "change"
to newline....
anyway, just wondering.....Oh, I didn´t think of edlin.
I never used it.

uliUgh edlin. It's been so long since I've used it I can't RECALL and honestly think it's best that I keep it forgotten. However, another good possible solution. I solved the problem with the carriage return. 8-) 8-)
Looks a bit strange cause HTML Tags have to be double quoted in variables.

set var="
number:name1:name2
number:name1:name2
.... "
set var=%var:
=#~#%
set var=%var:"=%
set var=%var:#~#=^&echo.%
echo %var%

cheers
uliI like Uli's trick replacing the
with &echo.. To avoid the double quotes and the strange code needed to work around the workaround parse the file directly into a variable using the FOR command:

Code: [Select]for /f "tokens=*" %%a in (textfile.txt) do set var=%%a
set var=%var:<br>=^&echo.%
echo.%var%I'm just afraid that this will not work for large files since the size of a variable in DOS may be limited. :-/

4206.

Solve : Run a Batch File as an Admin on a Users PC?

Answer»

Hi all,

I am new to writing batch files and am currently having a problem running a batch file on a users machine.

The batch file installs an application, but normal users do not have permissions to install applications on their PC. I am unable to change this, but what I thought I could do is run the batch file with an admin ID and Password incorpated so that it would install the application as an Admin, but on the users machine.

Only problem is I have no idea how to do this, and can't find this anywhere on the NET!

Can you guys help, i would be hugely greatful?

MANY thanks

Jon
In WinXP (at least) you can use the RunAs command like:

RunAs /user:Admin batch.bat

I looked it up here:http://dostips.cmdtips.com/?p=DtCodeSnips.htm

-p
try this : where "prog" is the dos PATH of the program you want to run as admin on a local user with limited rights, save the below code as admin.bat and copy the file to the startup of the user profile or run as a script, you can replace the word "prog" by any of ur desired destinations like c:\notepad.exe or anything you want to run.enjoy
******************
@echo off
setlocal
SET _Admin_=%COMPUTERNAME%\Administrator
set _Group_=Administrators
set _Prog_="cmd.exe /k Title *** %* as Admin *** && cd c:\ && color 4F"
set _User_=%USERDOMAIN%\%USERNAME%

if "%1"=="" (
runas /u:%_Admin_% "%~s0 %_User_%"
if ERRORLEVEL 1 echo. && pause
) else (
echo ADDING user %* to group %_Group_%...
net localgroup %_Group_% "%*" /ADD
if ERRORLEVEL 1 echo. && pause
echo.
echo Starting program in new logon session...
runas /u:"%*" %_Prog_%
if ERRORLEVEL 1 echo. && pause
echo.
echo Removing user %* from group %_Group_%...
net localgroup %_Group_% "%*" /DELETE
if ERRORLEVEL 1 echo. && pause
)
endlocal
8-)

4207.

Solve : filename (with spaces) specification??

Answer»

i am getting rename command syntax error trying to rename a filename that has spaces embedded.
I can't find good information on how to specify such a filename.
thx, billpCode: [SELECT]Rename "Name of FILE with spaces".txt filename.txt
It's IMPORTANT that you have those quotes in there. It's not limited to txt files; I just chose that one because it's COMMON. 8-)

4208.

Solve : Batch - HOW to No Console Window?

Answer»

I'm guessing this is a simple question.

Is there a way to have my batch file execute without the black CONSOLE window coming up? :-?Assuming that the batch file needs no input from the USER, yes. Just double-click on the batch file in Windows, and it will execute. The black window may blink, but so long as the user doesn't need to do ANYTHING, it won't stay there. Yeah, but that's what I meant. :-/

I was just curious if there was a way so it wouldn't even blink.That, no. It has to open cmd.exe to make sense of the batch file. Oh, well.

Although I suppose that wouldn't be an important feature ANYWAY.

4209.

Solve : Shutdown Permissions?

Answer»

I tried to shut down a XP machine down remotly using this:

Code: [SELECT]shutdown -s -m \\DELTA -t 120 -c "THIS COMPUTER IS SHUTTING DOWN."
And I recived a "Access is denied" error. Both machines are on the same network & workgroup. I can access files and other crap on the remote machine and I do KNOW the administrator password. How can I get around this? What other INFO do you guys need?I'm not aware that workgroup COMPUTERS can remotely run jobs. I could be wrong but I'm pretty sure you need a server OS and computers that connect as members of a domain.

8-)

4210.

Solve : Automatic Logon?

Answer»

How to perform automatic LOGON on windows XP Pro. on START up??

ThxQuote

How to perform automatic logon on Windows XP Pro. on Start up?

Thx


Select Run from the Start menu.

Type - control userpasswords2 - and click OK.

Select the Users tab.

Uncheck the "Users must enter a USER NAME and password to use this computer."
Click OK.
When the system prompts you, enter a username and password for users who automatically log on, and click OK.
That could still very well stop at the title screen, just that it wont REQUIRE a password.

Try using autologon.exe from http://www.sysinternals.com
4211.

Solve : is posible COPY longpath file??

Answer»

Hi there.

I'm try to do this kind of COPY:

copy \\main\c\dir0\dir1\dir2\dir3\dir4\file.txt \\additional /y

As a result i get this: The network path was not found.
When i try short path, like:

copy \\main\c\dir0\dir1\dir2\dir3\file.txt \\additional /y

Everything works fine.
Whay i'm doing wrong? Or may be there is some copy-comand restriction?

Thanks in ADVANCE.




Well...
copy [long_path] \\additional /y
\\additional is the name of a computer; you also need the name of a folder

You WANT to copy something to a folder in the computer "\\additional"; that folder it's a share; you can see the valid names you can use by verifying the share names on that computer. For example, on the computer called "additional" you have the following shares:
a -- which on additional computer is in fact: c:\dir1\share1 folder
b -- --II-- c:\dir1\share2
To copy to one of those folders:
copy \\main\c\dir0\dir1\dir2\dir3\dir4\file.txt \\additional\a /y

And YES, it is a filename length restriction: 256 CHARACTERS maximum for a path (if I remember well).
So, if your [long_path] has more than 256 characters, you have to do something to reduce it.
Keep in mind that Windows makes use of Hidden DRIVE shares.

your C: drive is shaerd as C$.
to make sure you can copy, you need to authenticate first if it is differrent network.

NET USE \\REMOTEPC\ADMIN$ /USER:MYDOMAIN\MYADMIN PASSWORD.

This will create a temporary connection to that machine.

So to copy from your PC to remote PC do this.

Copy /Y c:\temp\*.* \\remotepc\C$\TEMP.

To use Long File names and Spaces.. Do this.
copy /Y c:\temp\*.* \\"remotepc\c$\temp\directory with spaces"

I might be mistaken about the open " " it could be "\\..."

I believe there is a 256 character DOS LIMIT for typing commands.

4212.

Solve : Delete lines in text files?

Answer»

Hi

I have a folder that contains 6000 text files. I need to delete the 3rd last line in each file. I need a DOS program to loop through all files and delete the line. Can you post code PLEASE?

ThanksIs this a homework question?No its not a homework question. Considered implementaions in Java and VB but I assume a more strightforwrd approach can be achieved using DOS. I have no EXPERIENCE in DOS hence the question

ThanksI'm tempted to go off-topic and ask exactly what you're doing with 6000 text files. I don't think I have that MANY files on my WHOLE computer! *does search for "*.*"* Oh, wait, yes I do...

I don't think that can be done in DOS. I'd be hard pressed to find a way to do it in VB as well. I think it can be done in VB, but I'm pretty sure DOS is out of the question.The next code delete the 3rd last line for the file that you write in the command line.

del3rd yourTestFile.txt

Code: [Select]@echo off
for /f %%x in ('type %1 ^| find "[@##_^ stupid_line ^[emailprotected]#@]" /v /c') do set /A z=%%x - 2
sort /r /+1000000 %1 | more +3 | sort /r /+1000000 | more +1 > tmp
more +%z% %1 >> tmp
del %1
ren tmp %1

I wrote it for W2000 (I haven't installed XP) and it work fine if the file:

--> have not any line with the string: "[@##_^ stupid_line ^[emailprotected]#@]"
--> Haven't any line of 1000000 characters.

If it works for you, then you can write a 'FOR loop' for all your 6000 files.

Bye - Good luck

4213.

Solve : Ip address from text file?

Answer»

I am writing a batch file that will allow users to run REMOTE processes on other machines. I have that part down. I have now been charged with another duty. I am asking the user if they need to resolve a host name to ip address, I am unclear about how to do this. I'm thinking something like this

ping >file.txt

And here's where I'm stuck. I need a way for the batch file to parse the txt file and look for the word "Reply" (as in reply from) or "Request" (as in request timed out) and take the ip address and save it into a variable that I can call at a later time. I'm pretty sure that I am going to have to USE the FIND command but I have no clue on how to use it.You can use the pipe and dispense with the text file:

Code: [Select]for /f "tokens=1-3 delims=[] " %a in ('ping hostname -n 1 ^| find /i "pinging"') do set IP=%c

As usual there is more than one way to do this. Change hostname to something useful.

Hope this helps. 8-)Thanks for the help but I think that I need a little more. I am by no means an expert on the for command but I need the file to find weather or not the host is alive. I am assuming that the "pinging" section of your response only looks at the beginning of the ping output. I need the file to look to see if the host is alive by finding the "Reply from" part of the ping or if the host is turned off by finding the "Request timed out" part of the ping, then based on that I can tell the operator that the machine they want is either off or on and give them the IP address. Can the for command do that. Also if you don't mind, I would really like to know what the whole command you gave me actually means. Is there another part of the forum to go and look at how to use the FOR command as I am really starting to get into the batch file THING and I think that the FOR command could really help me out. In that case search for "Reply" and change the delimiters:

Code: [Select]@echo off
for /f "tokens=1-3 delims=: " %%a in ('ping hostname -n 1 ^| find /i "reply"') do set IP=%%c
if .%IP%==. echo Host is not reponding

Basically you're taking the output of the PING command and sending it thru the pipe | to the FIND command where the search for "REPLY" takes place. The FOR command acts as a parser. If you run PING from the command line, you'll notice the REPLY line consists of space delimited words which include the IP address. The IP also has a trailing semi-colon. By using the space and the : as delimiters, you can isolate the IP address. Also notice the IP is the third word on the line. We need three variables to get to this value and since we declared %%a in the FOR statement, the third variable is referenced as %%c.

Probably not the BEST explanation you'll ever get. Run FOR /? (this works for any command) from a command prompt for the official documentation. Not the best but reasonably better than most.

IMHO, with the batch file thing, you end up coding the data and not the method.

Good luck. 8-)You can use this in a batch file, and pass it the parameter of the host or IP address you are testing:
Code: [Select]@echo off
ping -n 1 %1|find /i "reply" >NUL&if errorlevel 1 (echo Host "%1" is dead, or ICMP is firewalled) else (echo Host "%1" is alive)So if you use this code in PingTest.bat, you could ust the command
PingTest 192.168.1.1
or
PingTest JSmith01
Thanks for the quick reply SideWinder. I am using what you gave me and it seems to be working, the only thing is that I cannot get the message that the "host is not responding".

Here's what I have so far

@echo off
set /p compname=Enter host name
for /f "tokens=1-3 delims=: " %%a in ('ping %compname% -n 1 ^| find /i "reply"') do set IP=%%c
if .%IP%==. echo Host is not reponding

If I put all T's in the compname variable (I don't have a computer with all t's) the batch doesn't show me "Host is not responding"

Something I am or am not doing right?I always forget the part to reset the variables:

Code: [Select]@echo off
set IP=
set /p compname=Enter host name
for /f "tokens=1-3 delims=: " %%a in ('ping %compname% -n 1 ^| find /i "reply"') do set IP=%%c
if .%IP%==. echo Host is not responding

Normally you would reset the variables at the bottom of the batch file.

Happy Computing. 8-)That fixed it. Thanks a ton. I'm gonna fool around with this and let you know how it turns out.

Also mybe while I got ya. Is there a way to tell the file to use one or the other variables if one of them has something in it and the other one doesn't . Lemme explain. The start of the file asks is you want to resolve a host name. You have fixed that part. But if the operator says no to the hostname thing and decides to put in the ip him/her self that is a whole nother variable. Basically what I am asking is if they say yes to resolving a host name then it sets one variable and leaves the other blank (if they had said no to resolving.) but if they say no to resolving then the other variable is filled while the compname variable stays empty. Is there a way to tell the batch file to only use the variable that has something stored in it and not to use the ones that nothing set to them.

I hope this makes sense to ya, I know it took me a while to figure out exactly what I wanted this thing to do.

Thanks again.If the user indicates no ping is needed, set the IP to whatever they input and BRANCH around the ping logic you developed in the previous post (you can use a goto/:label construct).

Ping works with both IP addresses and names. Personally I would not give the user that option. Do the ping regardless....don't rely on the user to get it right.

Just a thought. 8-)Thanks, After I posted that I started thinking it through and found a solution that will work with what I need.

Thanks a bunch for everything you really helped me out and saved me a ton of research time that I can use to learn VB and maybe write front end GUI's for this instead of DOS which I prefer but many don't.

Thanks again. I'll be back to pick your brain again no doubt.

4214.

Solve : "Ejecting" Removable Media Devices?

Answer»

On devices such as jumpdrives(aka flash drives or sticks), you can right click on the and click an eject command. Can anyone tell me the shell extension i can call from a batch file. I know it will involve rundll32.exe shell32.dll but im not sure of the command.I wasn't aware you can "eject" these devices, but this will allow you to stop the device for safe removal:

%SystemRoot%\System32\RUNDLL32.EXE shell32.dll,Control_RunDLL hotplug.dll

GOOD luck. 8-)thank you thats sorta what i meant because if you right click on the jumpdrive it has the command "Eject" on the drop down menu

how would i actually stop the device without the user having to do anything?This may help you out: DeviceEject

It's a C++ program. For help on how to run, use: DeviceEject /?

Good luck. 8-)
Thanks for the help.How would you go about stopping a flash drive, if you have more then one in the computer? Say, you want to stop the E: drive but leave the F: drive?This little script may help you out. Should have thought of this the first time around.

Code: [Select]On Error Resume Next

CONST MY_COMPUTER = 17

strDrive = "E:\" ' default drive/overridden if drive pass on command LINE

If Wscript.Arguments.Count > 0 Then
strDrive = Wscript.Arguments.Unnamed.Item(0)
End If

Set WshShell = CreateObject("Shell.Application")
Set WshNamespace = WshShell.NameSpace(MY_COMPUTER)
Set d = WshNamespace.ParseName(strDrive)

d.InvokeVerb "E&ject"
WScript.Echo "It is now safe to remove " & strDrive & " drive"

As written, the default drive is E:. You can OVERRIDE this by passing the drive letter along the command line. Save the script with a vbs extension and run from the command line or call it from a batch file: cscript scriptname.vbs driveletter:\

Note: There is no built in error CHECKING. The script will blindly attempt an eject, valid or not.

Good luck. 8-)Would I need to change this variable:

Code: [Select]CONST MY_COMPUTER = 17
Does this need to be the computer name? If so, can the script read that like a batch file does?

Code: [Select]%ComputerName%The MY_COMPUTER = 17 is a reference to the My Computer folder found on Windows machines. It has nothing to do with the computername variable in the environment. The script was written specifically to answer your post. You should not need to change anything.

As mentioned, if you don't pass along a drive on the command line, the script will default to the E: drive. You can override this by passing a drive parameter at run time.

Hope this helps. 8-)

4215.

Solve : Logic issue?

Answer»

Hi all,

Can't seem to get this to work as I'd expected (problem line highlighted)... have I missed anything here ?? Instead of performing the "goto RestartApp1", it is calling the "goto FinishOff".
The screen looks like.....
[size=10]Checking for BOS file ..

NOT FOUND: BOS.EAR file.
C:\BOS+CRM_Installs\BOS\Build\test03\bos.ear


Do any of the SQL runs performed require a RESTART of the `DEMO` instance?
Is a RESTART required ? [y/N]: y



Install `test03` for BOS instance `DEMO` now completed.


------------------------------------------------------------------------------
Finish of batch job orion_install on 2006-03-08 at 05:05
------------------------------------------------------------------------------ [/size]
And the script responsible reads ....
[size=10]@echo. >> %OutputLog%
@echo Checking for BOS file .. >> %OutputLog%
@echo.
@echo Checking for BOS file ..

set SQLRestart=

sleep 2

if not exist %InstDir%\bos.ear (

@echo. >> %OutputLog%
@echo NOT FOUND: BOS.EAR file. >> %OutputLog%
@echo %InstDir%\bos.ear >> %OutputLog%
@echo. >> %OutputLog%

@echo.
@echo NOT FOUND: BOS.EAR file.
@echo %InstDir%\bos.ear
@echo.

rem -----------------------------------------------------------------------------------
rem -- ASK user if a restart is required at all.
rem -- Some SQL updates require the Application to be restarted.
rem -----------------------------------------------------------------------------------

if "%SQLfiles%" EQU "TRUE" (

@echo.
@echo Do any of the SQL runs performed require a RESTART of the `%Instance%` instance?
[highlight]set /P SQLRestart=Is a RESTART required ? [y/N]: [/highlight]

@echo.
@echo. >> %OutputLog%

sleep 1

if /I "%SQLRestart%" EQU "Y" (

@echo Proceeding to RESTART the `%Instance%` instance of the `%Product%` Application. >> %OutputLog%
@echo Application Servers affected are : %Servers% . >> %OutputLog%

@echo Proceeding to RESTART the `%Instance%` instance of the `%Product%` Application.
@echo Application Servers affected are : %Servers% .

goto RestartApp1

)

)

goto FinishOff

)

@echo. >> %OutputLog%
@echo FOUND: BOS.EAR file. >> %OutputLog%
@echo %InstDir%\bos.ear >> %OutputLog%
@echo. >> %OutputLog%

@echo.
@echo FOUND: BOS.EAR file.
@echo %InstDir%\bos.ear
@echo.

:RestartApp1[/size]
I'm at a LOSS to understand why it will not execute the "goto RestartApp1" when 'y' is entered at the prompt.

Any help really appreciated.A very common problem with the bat code is that The variables within IF and FOR are replaced like macros in C/C++ (you know #define x 25 ?) just before to execute the FOR/IF structure. With a slight diference: if you modify the variable within the IF/FOR, you only appreciated the difference when leaving the IF/FOR.

I understand that you don't understand my explication, it will be is 'cause my English isn't very good.
Here you have a very simply example:

set SQLR=Y
if /I "%SQLR%" EQU "Y" ( set SQLR="NOT !" & echo in: %SQLR% )
echo out: %SQLR%

The result of the execution is:

in: Y <-- but ... :-? if I change the value of SQLR !!!
out: NOT !

if you want that the substitution is made just before executing the sentence within the IF/FOR, you must:

1) Open a subshell with the "delayed environment variable expansion":
cmd /v: on
2) The variables where you need "delayed substitution" must be enclosed like !var! (not %var%)

Below you have a posible solution for your problem.
The code in red color, guarantee that your code is always EXECUTED in a subshell cmd /v: on,


@IF .%_cmdv_%==.YES goto _program_
@set _cmdv_=YES
@cmd /v: on /k %0
@set _cmdv_=
@goto :eof
:_program_

REM ------------- Top of your code -------------


@echo. >> %OutputLog%
@echo Checking for BOS file .. >> %OutputLog%
@echo.
@echo Checking for BOS file ..

set SQLRestart=

sleep 2

if not exist %InstDir%\bos.ear (

@echo. >> %OutputLog%
@echo NOT FOUND: BOS.EAR file. >> %OutputLog%
@echo %InstDir%\bos.ear >> %OutputLog%
@echo. >> %OutputLog%

@echo.
@echo NOT FOUND: BOS.EAR file.
@echo %InstDir%\bos.ear
@echo.

rem --------------------------------------------------------------------------------
rem -- Ask user if a restart is required at all.
rem -- Some SQL updates require the Application to be restarted.
rem --------------------------------------------------------------------------------

if "%SQLfiles%" EQU "TRUE" (

@echo.
@echo Do any of the SQL runs performed require a RESTART of the `%Instance%` instance?
set /P SQLRestart=Is a RESTART required ? [y/N]:

@echo.
@echo. >> %OutputLog%

sleep 1

[highlight]if /I "!SQLRestart!" EQU "Y" ( [/highlight]
@echo Proceeding to RESTART the `%Instance%` instance of the `%Product%` Application. >> %OutputLog%
@echo Application Servers affected are : %Servers% . >> %OutputLog%

@echo Proceeding to RESTART the `%Instance%` instance of the `%Product%` Application.
@echo Application Servers affected are : %Servers% .

goto RestartApp1

)

)

goto FinishOff

)

@echo. >> %OutputLog%
@echo FOUND: BOS.EAR file. >> %OutputLog%
@echo %InstDir%\bos.ear >> %OutputLog%
@echo. >> %OutputLog%

@echo.
@echo FOUND: BOS.EAR file.
@echo %InstDir%\bos.ear
@echo.

:RestartApp1

[smiley=beer.gif]Carlos,

Not for the first time, you have provided great feedback and workable solutions - many thanks.

If I could, I'd buy you a beer in appreciation. [smiley=beer.gif]

And thanks too for adding to my endless LIST of things to read-up & learn (not that I'm complaining really). After I finish this task, I'll take a step back and get a better understanding of how this "delayed substitution" works.

Again, many thanks.I accept your "virtual beer" [smiley=beer.gif] - cheersMany thanks Carlos, many thanks. Made a slight alteration to the startng code...

@IF .%_cmdv_%==.YES goto _program_
@set _cmdv_=YES
@cmd /v: on /k %0
@set _cmdv_=
@EXIT
@goto :eof
:_program_

Just to ensure that after the script ends, it returns to the original DOS session.Good, every day something new is learned here, the top code

@IF .%_cmdv_%==.YES goto _program_
@set _cmdv_=YES
@cmd /v: on /k %0
@set _cmdv_=
@exit
@goto :eof
:_program_

can be repaleced by the sentence:

SETLOCAL ENABLEDELAYEDEXPANSION

Too true Carlos.

Found references to the same SETLOCAL statement whilst reading this morning ... neat stuff.

4216.

Solve : How to get back into 98 SE from DOS?

Answer»

I defrag my computer in Dos and now it STARTS up in DOS. How do I get it to open in 98SE?cd\WINDOWS
winYou are trying to defrag with a DOS you had installed before Win98?WHOOA!!! dangerous what you are doing..

First of all, never defrag any Windows installation with DOS. It will KILL your LONG file name links and tables.

Second, to my best KNOWLEDGE, when isntalling Windows 95/98 it automatically deletes the DOS defrag tool.

Third, Windows 95/98 would always attempt to load if previously installed.

4217.

Solve : Using DIR to provide files you want to copy.?

Answer»

Ok, here's the story. I work in a spot where I need to find, and COPY the PST files. Doing search for *.pst is useful, I can find them... etc. Copying them can be a pain in the a$$. Especially when users stick them in the root of C.

I've already created a batch file for the profile, based on our backup structure, but need ONE for the PST.

Now, I KNOW I can use dir *.pst /s to FIND all the files. The ISSUE is then telling the computer (without input from me) to BACK those up. Preferabbly with the same directory structure (even less input from me)

Thanks
RadekModifying one off the examples shown at [highlight]http://dostips.cmdtips.com/DtTipsCopy.php[/highlight] should work:

Code: [Select]set sourcedir=C:\*.pst
set backupdir=D:\pstbackup
for /f "tokens=*" %%a in ('dir "%sourcedir%" /s/b') do (
xcopy "%%a" "%backupdir%.%%~pa" /Y/U
)Hope this helps

4218.

Solve : eliminating a useless hierarchy in my folder?

Answer»

Hi

I have saved data from a formatted disk, and the program I used has put all the files in 1334 subfolders in a folder named "lostfiles"
I would LIKE to be able to sort these files usefully by type in order to do a clean recovery.
The first step is to eliminate the subfolders.
Basically, I'd like to copy the files in E:\savedDisk\lostfiles\DIRx with x INCLUDED in [0, 1334] into a folder such as E:\myFiles
I could then simply use windows to sort by type and cut paste my files.

I am no good at DOS

but would have started SMTHG like this
FOR %%F IN ("./*") DO
COPY ...

ok, who's good at this, thanks for your kind help

Assuming none of the file names in any of the directories would be duplicates of each other, you could try pasting the following into a batch file:
for /l %%a in (0,1,1334) do echo xcopy E:\savedDisk\lostfiles\DIR%%a\*.* E:\myFiles\ /SHEY GuruGAry

Great Job ! Thanks for your help !
Except of course, I removed "echo" whenI actually executed.
An I added /Y, beacause the overwrite confirmations were getting boring...

The command I used

for /l %%a in (0,1,1334) do xcopy E:\savedDisk\lostfiles\DIR%%a\*.* E:\myFiles\ /s /Y

cheers Ah, YES - the echo. Sorry, I forgot to remove that from my test.

4219.

Solve : Starting MS-DOS from laptop?

Answer»

Hello everyone :-/

I have a laptop, and want to format my C and D drive and install Windows XP again. However, a year ago some Russian friends of MINE installed a different version of XP, so the version I have on cd is not the same.

Firstly I need to whipe this present version from my drives...how do I even get to DOS? Im not the brightest person with laptops but I can figure out how to reinstall XP from cd. When I tried to boot from cd I was able to install xp on my C/D drives BUT it didnt give the option of formatting the drives first ...only by installing another version on a drive...which it then suggested not to do (ofc).

So Im kinda stuck and I think the only way I can do it now is to format everything first and install from scratch.
I couldnt find any instructions on google so any help would be appreciated
thnxBoot with a DOS - BootCD (if you don´t have a Floppy.)

type fdisk/mbr
start fdisk and DELETE the partitions.
create a new partition with fdisk.
restart and type:
format c: /u

Now you should have a clean HD. (data will be lost, so MAKE sure to make a backup)

HOPE that helps
uli
A standrd XP Can delete partitions. If the CD is customized, then it might not as it might follow an answer file inbedded in it.

4220.

Solve : problem reinstal Win98 on recetly formatted comp.?

Answer»

Hi, I really hope someone can help me and I'm sure it's something so easy that i just totally forgot about.

Problem!!![/u]

I just purchased an older computer from School, They are ex-lease Acer Power4100
Off hand its a celron (pent 3 equv.)
Processor speed : 466mhz
about 3 yrs old

It has been networked in it's previous life at school. Because of this a DOS message stating "omega jazz host adaptor not found" flashes up, followed by the Win98 logo. Then it starts a cycle of messages in dos. the first "Boot From (N)etwork or (Q)uit?" almost instantly the screen fills up with "probing pci nic... (eepro100)Ethernet ADDR: {number} .... Valid link not established"

redisplays the boot from N)etwork or (Q)uit?" and so the cycle continues.
I was told i could just Format the c DRIVE and id be set...So i did.

I do have original win98 disks and auth cert so that i can reinstall win98 and start from scratch (this was the theory)

Now i have formatted the hard disk and restarted the comp. I inserted the Win98 CD and let it load...well attempt. Now i keep getting a message with the comp. hardware Stats at the top in blue and "invalid system disk...Replace the disk, and then press any key" at the bottom.

There is nothing wrong with the CD as it was still in the shrinkwrap from the late 90's

What should i do!!!
I really just want this comp as a dedicated Internet and basic word processing machine.

Thank you for you help, any assistance is appreciated.See if your BIOS allows to select the cdrom as the first boot device. If it does, select it and boot from the cd. If it does not, download or have a friend with w98 make a boot disk with cdrom support. You can use that to boot and then run setup from the dos prompt. You can download from bootdisk.comVery few Win98 CD releases were bootable.
Download [highlight]this archive[/highlight] and extract it to a folder. Run the resultant bootdisk.exe with a diskette in the floppy drive. It will create a bootable diskette.

Put the diskette in your new computer, enter the BIOS and set the boot order to boot from floppy first. Save it and exit. The computer will now boot from the diskette to an a:/> prompt.
The boot diskette loads real mode CD and mouse drivers plus some useful tools.

To install Windows98, type the following:

v:
setup /ie /im /is /nr
Quote

Very few Win98 CD releases were bootable.

Only upgrade disks were not bootable. Retail and OEM disks are bootable.I'll say it again - Very few Win98/Win98SE CDs were bootable!
There is a very good reason for this which I'll let you FIGURE out.
I've used more than I care to mention of all flavours.
4221.

Solve : Absolute path?

Answer»

Hi

Im modifying an application and I have created a batch file (setenv.bat) to set all the ENVIRONMENT variables the program needs. But the most important one is the location of the disk of the program : its absolute path.

Is there a way to determine the exact location of the setenv.bat ? I have tried %CD% but it changes if I launch the file from another DIRECTORY.

Thanks
%CD% will always return the directory that you're logged into. I don't really understand your question (Sunday mornings are never my best moments ). SINCE you created setenv.bat, presumably you know where you saved it.

Maybe, if you re-worded your question, we could help you.

Let US know. The setenv.bat file will be installed at the location of the program during installation.

I have tried %CD% but if you cal setenv.bat since another directory %CD% will have this other directory, so it's useless.

I tried to see if truename can be the solution but behind it its a search on the disk : not very efficient to start a program.

Right now, I fall back to use NSIS to install the program at the location the user want and to set directly in the file setenv.bat the location by rewriting the file.

If the user wants to move the application he will have to modify the file.mind posting PART that you're talking about, u kinda lost me on what you're wanting...using the FOR command, you can reveal your "ABSOLUTE PATH" with the " %~fI " - expands %I to a fully qualified path name.

type HELP FOR in a dos box for details...

4222.

Solve : Telnet Command in batch files?

Answer»

Hello All,

I am trying excute a a UNIX script in a regular intervals for this i have used telnet command in a batch file to connect to remote server. But i was unable to do that.

Could some one in the group share your thoughts on how to use a telnet commands in a batch file so that with out any manual intervention in can execute the script.

Thanks
VishHave you tried the Unix crontab?I use HP-UX at work ... below is the man page of the crontab.
It should be of some help to you.

crontab(1) crontab(1)

NAME
crontab - user job file scheduler

SYNOPSIS
crontab [file]

crontab -e [username]

crontab -l [username]

crontab -r [username]

DESCRIPTION
The crontab command manages a crontab file for the user. You can use
a crontab file to schedule jobs that are executed automatically by
cron (see cron(1M)) on a regular basis. The command has four forms:

crontab [file] Create or replace your crontab file by
copying the specified file, or standard
input if file is omitted or - is
specified as file , into the crontab
directory, /var/spool/cron/crontabs. The
name of your crontab file in the crontab
directory is the same as your effective
user name.

crontab -e [username] Edit a copy of the user's crontab file,
or create an empty file to edit if the
crontab file does not exist. When editing
is complete, the file will be copied into
the crontab directory as the user's
crontab file.

crontab -l [username] Lists the user's crontab file.

crontab -r [username] Remove the user's crontab file from the
crontab directory.

Only a privileged user can use username following the -e, -l, or -r
options, to edit, list, or remove the crontab file of the specified
user.

The entries in a crontab file are lines of six fields each. The
fields are separated by spaces or tabs. The lines have the following
format:

minute hour monthday month weekday command

The first five are integer patterns that specify when the sixth field,
command, should be executed. They can have the following ranges of
values:

minute The minute of the hour, 0-59

hour The hour of the day, 0-23

monthday The day of the month, 1-31

month The month of the year, 1-12

weekday The day of the week, 0-6, 0=Sunday

Each pattern can be either an asterisk (*), meaning all legal values,
or a list of elements separated by commas. An element is either a
number in the ranges shown above, or two numbers in the range
separated by a hyphen (meaning an inclusive range). Note that the
specification of days can be made in two fields: monthday and weekday.
If both are specified in an entry, they are cumulative. For example,

0 0 1,15 * 1 command

runs command at midnight on the first and fifteenth of each month, as
well as every Monday. To specify days in only one field, set the
other field to asterisk (*). For example,

0 0 * * 1 command

runs command only on Mondays.

The sixth field, command (the balance of a line including blanks in a
crontab file), is a string that is executed by the shell at the
specified times. A percent character (%) in this field (unless
escaped by a backslash (\)) is translated to a newline character,
dividing the field into "lines". Only the first "line" (up to a % or
end-of-line) of the command field is executed by the shell. Any other
"lines" are made available to the command as standard input.

Blank lines and those whose first non-blank character is # will be
ignored.

cron invokes the command from the user's HOME directory with the POSIX
shell, (/usr/bin/sh). It runs in the c queue (see queuedefs(4)).

cron supplies a default environment for every shell, defining:

HOME=user's-home-directory
LOGNAME=user's-login-id
PATH=/usr/bin:/usr/sbin:.
SHELL=/usr/bin/sh

Users who desire to have their .profile executed must explicitly do so
in the crontab entry or in a script called by the entry.

You can execute crontab if your name appears in the file
/usr/lib/cron/cron.allow. If that file does not exist, you can use
crontab if your name does not appear in the file
/usr/lib/cron/cron.deny. If only cron.deny exists and is empty, all
users can use crontab. If neither file exists, only the root user can
use crontab. The allow/deny files consist of one user name per line.

WARNINGS
Be sure to redirect the standard output and standard error from
commands. If this is not done, any generated standard output or
standard error is mailed to the user.

FILES
/var/adm/cron Main cron directory
/var/adm/cron/cron.allow List of allowed users
/var/adm/cron/cron..deny List of denied users
/var/adm/cron/log Accounting information
/var/spool/cron/crontabs Dir containing crontab filesQuote

Hello All,

I am trying excute a a unix script in a regular intervals for this i have used telnet command in a batch file to connect to remote server. But i was unable to do that.

Could some one in the group share your thoughts on how to use a telnet commands in a batch file so that with out any manual intervention in can execute the script.

Thanks
Vish

i assume you want to execute telnet commands from a Windows machine to a unix machine to execute a Unix script.
You can use PERL's Net::Telnet module to do it. Look at http://www.perlfect.com/articles/telnet.shtml
for pointers. Or you can download a third parth telnet client to do that.
Hello All,

Many thanks for your postings. My requirment is i am trying to connect remote unix server using Telnet command in a batch file

test.bat

telnet -f C:\telnet_logfile.log brussels.bbx.com < C:\TelnetCommand.txt

I have created the above command in a batch file and i have used TelnetCommand.txt as a input which stores the User id and password of the remote server and the commands to execute the unix script.

TelnetCommand.txt
userid
password
cd /home/pidurpi/srcfiles
sample.sh

Could some one please tell me is there other way to connect to unix from a batch file and RUN the unix scripts?


Thanks, Vish

4223.

Solve : application problems?

Answer»

ms dos stuffed up my applications. i can't get into any of them, it goes to word pad with unreadable script. how do i turn ms dos off. This problem occured when i chose a program to open a certain application and now every application opens with wordpad. HELP.You cannot have MS-DOS and wordpad. So do you have a version of Windows? If so what one? Are you stuck in DOS prompt? It doesn't sound like it.

So beside Windows version, do you have any spyware/adware/antivirus SOFTWARE in place? What computer make/model? What processor? How much RAM? How much experience with computers? What were you doing prior to this? What do you think could have happened?

Once we know this we can start to help.all i know is i opened an application with wordpad by right clicking then open with then wordpad. now i can only get into them by right clicking them and choosing run as. The computer isn't the problem, it's the open with thing it applies it to everything and you can't undo it. it pisses me off. The computer runs on XP and these problems are only for one user name. when i double click on an application it comes up in wordpad with squares and other symbols i can't read. But it says this "this program cannot be run in ms dos" or something close to it. how can i undo it. I know it probably isn't ms dos's fault but it says it is.http://www.dougknox.com/xp/tips/xp_easy_file.htm

Repairing wonked file associations in XP.
Hope This Helps...

patio. I can't access CMD in 'run' because it also opens in wordpad. Thats the problem. all of my applications open up in wordpad and i can only access them properly by right clicking them and selecting run as. Or i can go on someone elses user name because it isn't stuffed up in other peoples user names. When i access the applications in wordpad it comes up in a code except for a part that appears in the first line, not at the start though. it reads exactly: This program cannot be run in DOS mode. Maybe i could reset my user name in control panel or something i'll try that but i bet it won't work. More help please?!?!?! YES i found out what to do. It said DOS but it was wrong. all exe files opened with wordpad, i knew that was the problem already i STRESSED that.

So i found a website and the last thing it told me to do was go to any folder even my computer or any other 'explorer.' click on 'tools' in toolbar, then 'folder options,' then 'file types.' Then click on 'new' and type the extension you are looking for '(EXE)' for me, and click on 'advanced' and there is a drop down menu, click on the type of program that extension is supposed to signify then click 'ok' the SELECT it from the list and instead of 'advanced' or 'browse' (I can't remember which) it should say 'RESTORE.' If you click on restore then it will restore it back to DEFAULT.

For me it was wordpad, now it's back to EXE (application). thank um someone (I'm an atheist) um, er, thank god anyway. And the website i found this help from i think i got to it from the browse menu after you right-click on a file and select open with. Thanks for the suggestions and help: GX1_Man and patio.just rename the existing problem profile, login again, it will pick up the default settings again.

PS, only administrators can rename profiles..

4224.

Solve : Login Script Logic?

Answer»

Does anybody know what the correct syntax is for an OR condition in an IF STATMENT for a login script? What I want to do is something like this:

IF "%HOST%"=="TS01" OR "%HOST%"=="TS02" GOTO NEWTS

ThanksIf you're talking about a BATCH login file then there is no OR condition for an IF. Better to break it up into two statements.

Code: [Select]
IF "%HOST%"=="TS01" goto newts
if "%host%"=="TS02" goto newts


Under XP, you could use a ELSE statement with IF


Example:

IF NOT string1==string2 (
ECHO STRING 1
) ELSE (
ECHO STRING 2
)

You could use
IF EXIST filename.txt (
ECHO DOES EXIST
) ELSE (
ECHO DOES NOT EXIST
)

You must adhere to the open brackets schema . This can be used successfully in a FOR LOOP.

4225.

Solve : Batch File Continuation?

Answer»

I want to create a batch FILE that copies some files, then starts a windows program. Once the windows program starts, I would like for the cmd.exe window to close.

The last command in my batch file is the executable to the windows program and it doesn't go any further than that.

Any help would be appreciated.

Thanks.Code: [Select]
@echo off
copy %0 "C:\"
start calc
exit
Code: [Select]

this copys this file into c drive then starts calculator then exits there is the basic thing just change the stuff you need to doI don't understand the %0 command. Can some explain.

P.s. I am new to Batch (i am a noob) :-/Hi Gabby Ab,

Please do a little homework about Batchprogramming:
This is a very good Website:

http://www.robvanderwoude.com/index.html

%0 is the name of the Batchfile you start
%1 is the FIRST PARAMETER if you TYPE one
%2 the second and so on

hope this helps
uliThanks Uli, I shall do some good READING now. I was only introduced to batch through this website and have since been very interested in its capabilities.To answer your first question.

You have to open a child process for the executable in mind. This can be done in DOS.

using CMD /C options...

CMD.EXE /c START CMD.EXE /c "PROGRAM.EXE"

This causes the program to run separetly from the parent. AKA=child process.

The command prompt will return to the parent program whilst the child is doing its on thing. Here is where you add your exit command.
using windows xp professional, this is the command line that i use

start c:\progra~1\jascso~1\paints~1\psp.exe
exit


it works great, you can have it copy what file you wish to above those lines, and then start and the destination of the file, and it automatically goes back to the batch file to finish what it was doing....

4226.

Solve : links in email?

Answer»

if I click a link in the email or LOG ONTO yahoo and my email notification pops up and I click it, it tells me that I haven't associated any extensions with the file. How do I make my IE open my links from email etc?
Thanks,
kltpctazhi, this is the MS-DOS forum. I gues you posted your e-mail question here by accident.

How to use links in email:

1) Make sure your email is HTML format.
2) to make links to websites: begin with HTTP://
3) to make links with e-mail: mailto:
4) to make links to files: FILE://C:\....

for any PROGRAMS and other STUFF. Outlook or Outlook express will make use of the default FILE associations for Explorer.

I recommend NOT opening any attachments or links in any email. If possible, be most secure, and setup your email to TEXT only and give any virsus NO chance of running by itsef! -side effect is that your emails are HARDER to read.

4227.

Solve : Incrementing numbers inside the batch file?

Answer» HI,
I need to create a folder automatically in a DIRECTORY. Like the home directory will CONTAIN folders like week-36 week-37. So for next week I need to create a folder week-38 automatically thru BATCH files. Please help me out http://www.robvanderwoude.com/index.html
go to BATCH FILES.
go to TIME&Date

good luck!
4228.

Solve : weird dos message?

Answer»

Here is my problem.For some reason whenever I try to net send a message at command PROMPT it gives me the message that "net" is not recognized as an external command or sumthing.
Ive used net send before and it worked fine but now for som reason its ACTING up.Whats wrong?What OS are you using? Commands seem to come and go on various flavors of Windows. Some XP commands do not exist on earlier Windows versions, Some Win98 commands no longer exist in XP, and MANY commands have new switches and syntax increasing functionality. If you are using xp, the MESSENGER service has to be running for net send to work.
If you want to turn messenger on permanently go to start>run and type services.msc scroll down to messenger right click to open properties and change start up type to automaticmake sure you also click start which becomes enabled AFTERWARDS... if i'm not mistaken, you do need to have start clicked before it decides to work for ya NET.EXE is a standalone DOS executable for Windows.
It may have been easily deleted.

Just look for the file from a similair version OS.sorry guys i wasnt clear ALL of the commands dont work now it cant recognise netsat,net user,net send or anything else! why is it doing this?Reinstalling the network adapter under Windows 98 will trigger a reinstall of the network tools like NETSTAT etc.

Under XP, you could opt to removing the network adapter. But remove the "Client for Microsoft Networks" first. Then remove the adapter under Device Manager.

Reboot PC. XP will re-detect the NIC and reinstall the Microsoft Netswork support itself. If no, you can do this.

This too will re-install the DOS tools for networks..

PS, not adviced for PC's that are members of a domain.

4229.

Solve : My computer stopped running MS-DOS programs?

Answer»

I have a few MS-DOS programs that I use FREQUENTLY (a Bricks game and a lottery program). Until last week, I never had any trouble with them. Then last week I started getting an error message labeled "16 bit MS-DOS subsystem" It states "C:\Windows\System32\Autoexec.NT is not suitable for running MS-DOS or Windows programs". As far as I know, I haven't done anything recently that would change the way my computer handles MS-DOS programs. Nothing new downloaded or installed. Can you help me straighten this out?

My computer in a Compaq Presarion running Windows XP.http://www.microsoft.com/windowsxp/using/games/expert/durham_og.mspxWhy would it work for years, and suddenly stop working?Updates maybe........have you tried retro64 for brick games??demos??

or have a look here someone may have the FIX>http://www.iamnotageek.com/a/413-p1.php

Maybe another fix>http://www.softpedia.com/get/Tweak/System-Tweak/16-bit-MS-DOS-Subsystem-Error-Quick-Fix.shtml

I would advise anybody upgrading to winxp from win9x should buy the winxp full install disk and dual boot there system........sidewinder had a fix also for this by changing the attributes .....i think....This could be caused by an installation that ran amok. In any case, the file has been corrupted.

To fix run the following from the command prompt:

copy c:\windows\repair\autoexec.nt c:\windows\system32

After you copy the file, find it in Windows EXPLORER, click properties and lock it down by giving it a read-only attribute.

Hope this helps. Thanks ever so much!We aim to please......dont vanish....... you may no something we dont?......awaits sidewinder comments?I have the exact same problem.See reply #4 for the exact same solution.

Quote

http://www.microsoft.com/windowsxp/using/games/expert/durham_og.mspx

i did everything you suggested,the game installed but when i try to run it,it says cd rom must be in to run this game,the cd is in.can you help.Quote
i did everything you suggested,the game installed but when i try to run it,it says cd rom must be in to run this game,the cd is in.can you help.


perhaps the cd is in the wrong drive, try to put it in another drive (if you have two drives)i only have the one drive.i already installed it from the cd,it just wont playIs it a DOS game?

If yes, then the programs is trying to access the old MSCDEX.EXE cd-rom driver extensions.

You could overcome this with your personal CUSTOMIZED AUTOEXEC.NT & CONFIG.NT placed in the same fodler as the game. Add DOS SUPPORT cd-rom there.

Create a shortcut, and modify the advanced properties, point it to the alternate location of config.nt and autoexec.nt

Also, XP has a Compatibilty mode for older games. You will find this under the short-cut properties as well.
4230.

Solve : FTP Batch Script?

Answer»

I have batch script for simple FTP (import/export) with out any error handling.

I would like write error checking so that i can catch the server time out, down. or any other reason batch file fail.

Any example of how to TAKE care of this task ?

Here is my sample code:

Code: [Select]C:
cd\some file destination
call format
del UpdateLog16.txt
ren UpdateLog15.txt UpdateLog16.txt
ren UpdateLog.txt UpdateLog1.txt
ftp -n -i -s:c:2ndbatch.txt > UpdateLog.txt

Here is the 2nd batch file:

open some FTP Site
user
password
cd /some dir...
bin
mput *.jpg
close


Thanks In Advance
are you SAYING like a way to trouble shoot what is going on??? If thats what you're refering too, i would suggest putting pauses in there to watch what each line does specifically.... and see where it goes wrong that way... The batch script that i runs twice a day. And sometimes it failes and i would just like to figure out why and when it failes.

Maybe out put the result to log file or something .

if it fails everytime??? the only suggestion i have is that when i'm building batch files for some stuff that i work on, i put pauses in a bunch of areas, and see if it tells me

"error blah blah has occured" then i can go off of that. Try to put pauses in there, other than that i have no idea how to input error messages into files or anything...Singleton06,

Thanks for the suggestion. But i'm very new to batch files. Can you give me example of how to put pauses in batch file.
Quote

Singleton06,

Thanks for the suggestion. But i'm very new to batch files. Can you give me example of how to put pauses in batch file.


normaly, just use the command "pause" and it says: press any key to continue Perhaps this might help.

@ECHO off

rem ################################################################################
rem # Created by: Gustaaf Von Pickartz
rem # Date: November 20th, 2005
rem #
rem ################################################################################

set FTPUSER=username
set FTPPWD=password
set FTPDIR=C:\TEMP\FTP
set ANYFILE=C:\DIR\FILE.ZIP

echo open ftp.server.com > send.ftp
echo user %FTPUSER% %FTPPWD% >> send.ftp
echo binary >> send.ftp
echo cd incoming >> send.ftp
echo put %FTPDIR%\%ANYFILE% >> send.ftp
echo bye >> send.ftp
ftp -i -n -s:send.ftp

del /f send.ftp
exit

what i was refering to as a pause is to literally put the word "pause" on a completely different line

such as

@echo off
echo Hello How are you doing?
pause
ehco I'm good...
pause
end

now, i spelled the word echo wrong on the second line and if you were to RUN through this as a batch file, it iwll tell you that "ehco is not an internal or external command" I will also have to hit a key to continue, so i will have time to watch what happens, and be able to tell that i have spelled the word wrong
This is just a quick suggestion, which you may be able to tell what you did wrong by the exmaple provided above....Okay, I'm confussed about the thread now.

did you want to know how to automate an FTP script or Errorcheck your batch files?

You can can do error checking in a batch.

Using Errorlevel as checking tool:

COPY C:\TEMP\*.TMP D:\TEMP
IF ERRORLEVEL 0 ECHO THE COPY WAS GOOD!
IF ERRORLEVEL 1 ECHO ERROR IN COPY

That is the basics of errorlevel checking. Valid numbers are 1-255. You can always errorcheck any application you have just started or network you connected to.

You can Use the GOTO command instead of ECHO to make your batch jump to a particular section to further process the error

example:

RD /S RECYCLER >NUL
IF ERRORLEVEL 1 goto :error
ECHO The delete was okay.
GOTO END

:ERROR
echo Warning, I was unable to delete!
GOTO END

:END
echo BYE!


may i know how to do the auto run?
4231.

Solve : use batch file to transfer text file?

Answer»

I'm a fresh grad, recently i'm assigned a new task

usually I use AS400 to run some queries, then FTP the DATA as text file (this must be done every 30min).

now, i would like to make it to be auto. I should create a batch file which can run the query at AS400 SERVER , then FTP as text file every 5min automatically to ANOTHER database server(Win 2000 based)

the problem is, how to write such batch file?

I'm really new to this , please help...

Thanks in advance

4232.

Solve : Not enough maximum conventional memory.?

Answer»

I only have Windows 98. Sometimes I just use C:\command and sometimes I restart and then boot up with the step by step configuration (because some background FILES try to load even though there not in autoexec.bat) and just dont choose the windows shell to be booted.He is using Windows 98.

Your right, you can drop EMM386.EXE from config.sys.

What is puzzling thought is the EMM386.EXE ON in the autoexec.bat. As far as I can recall, that wont run from there.

You may also edit msdos.sys under windows 98, and further optimize settings there. Its a flat text file.

That EMM386 ON thing is there because I put it there and youre right it doesnt work. Itll work if I run it in windows but when it boots up it says the file is missing or corrupt.

ILL have a look at that msdos.sys too see what I can do. I find it odd however that 56K is missing from memory but it is also 56K that is being used so im basically losing 112K of memory.
I cannot really think of anything that may be causing that, if I had the full amount of BASE memory and the 56K used up I would have plenty to play pretty much anything, Ive always had memory troubles but I had never before realised that DOS didnt recognise that I was abe to have a full 640K of base memory.DOSX and expanded memory are taking up some space. Look at those two. I don't know what DOSX is, and do you need expanded memory?I have NEEDED it on occasion. And I never once said DOSX, if I did it must have been a typo. But the real issue here is why DOS is seeing my maximum memory as 584K instead of 640K not how to free up memory.I agree Rippa, you should start with the 640K then it gets used up after that.
Could you have a faulty cpu I wonder?Why would the CPU affect it? I just thought it might be a line of code in some DOS file gone wrong.Is the 640K conventional memory limitation a hardware of software thing?
I've always thought it was hardware (cpu).
Live & learn, I must do some research on this. Quote

Conventional Memory

Conventional memory is contiguous memory directly used by applications running on any Intel 80x86 microprocessor that is running in real mode under unaugmented MS-DOS. Addressed from 0 to 640KB (up to 736KB with special device drivers and hardware). The original 8088 processor could address up to 1MB (220, 20 being the number of address lines which come out of the CPU) of memory directly; however, IBM chose to reserve the upper 384KB for ROM and other uses.



Another interesting read....
http://aroundcny.com/technofile/texts/pcmemdesign.htmThere is a sound manager out there called VDMSound.
http://vogons.zetafleet.com/viewtopic.php?t=2071

This sound manager also manages DOS 640K memmory issues.

By the way. Did you ever try to adjust the properties of the shortcut running the DOS game under Windows?
Experiment with the memmory setting of the short-cut in question.That's odd, I changed the memory settings in that right click properties menu and they all changed except conventional memory. I changed it to 640K but it went BACK to auto, that's interesting.
4233.

Solve : Batch with copy from Internet?

Answer»

ey I like to make a batch with a code that copy's file(s) from a ftp or http server on the INTERNET
can i do that ?Using HTML may be tricky. With FTP it is doable.

The example shown below will download all *.xml files from the FTP server's sub directory public_html into the directory where the batch file is LOCATED. The batch file extracts the FTP script embedded at the end of the file and executed it in FTP.EXE context.

This and more sophisticated examples that let you configure the connection and directory settings at run-time are available at [highlight]http://dostips.cmdtips.com/DtCodeBatchFiles.php[/highlight].


Code: [Select]@ECHO OFF
REM.-- Prepare the Command Processor
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION


rem --build the FTP script as <ThisFileName>.txt
set FtpScript=%~dpn0+.ftp
type nul>"%FtpScript%"
call:extractFromFile ##FtpScript##>>"%FtpScript%"


rem --Execute the FTP script
ftp -i -s:"%FtpScript%"
set title=Done


REM.-- End of application
FOR /l %%a in (5,-1,1) do (TITLE %title% -- closing in %%as&ping -n 2 -w 1 127.0.0.1>NUL)
TITLE PRESS any key to close the application&ECHO.&GOTO:EOF


::------------------------------------------------------------------
::-- functions start below here
::------------------------------------------------------------------


:extractFromFile - extract lines from a file between begin and end mark
:: - %~1: begin mark, use '...$' mark to allow variable substitution
:: - %~2: optional end mark, default is end of file
:: - %~3: optional source file, default is THIS file
SETLOCAL
set bmk=%~1
set emk=%~2
set src=%~3
set /a b=-1
set /a e=-1
if "%src%"=="" set src=%~f0& ::- if no source file then assume THIS file
for /f "tokens=1,* delims=:" %%a in ('"findstr /n /b /c:"%bmk%" "%~f0""') do (
set b=%%a
set bmk=%%b
)
if /i %b%==-1 echo.ERROR: begin mark '%bmk%' not found in '%src%'&GOTO:EOF
if "%emk%"=="" (set /a e=2000000000) ELSE (
for /f "delims=:" %%a in ('"findstr /n /b /c:"%emk%" "%~f0""') do (
if /i %b% LSS %%a if /i !e!==-1 set e=%%a& rem -- find only the first one after b
)
)
if /i %e%==-1 echo.ERROR: end mark '%emk%' missing in '%src%'&GOTO:EOF
if /i %b% GEQ %e% echo.ERROR: end mark '%emk%' detected before begin mark '%bmk%' in '%src%'&GOTO:EOF
for /f "delims=: tokens=1,*" %%a in ('"findstr /v /n /b /c:"#$*ReturnAll*$#" "%src%""') do (
if /i %b% LSS %%a if /i %%a LSS %e% (
if "%bmk:~-1%"=="$" (
rem --substitution variables within %%b
call echo.%%b
) ELSE (
rem --no variable substitution
echo.%%b
)
)
)
GOTO:EOF


::------------------------------------------------------------------
::-- ftp script starts below here
::------------------------------------------------------------------


##FtpScript##$
open example.com
anonymous
[emailprotected]
^!: THIS IS A COMMENT
^!: Put your FTP script below here, e.g.:
^!: change the local directory to be the location of the batch file
lcd %~dp0.
^!: set the target directory
cd public_html
^!: upload all xml files
mget *.xml
^!: end of FTP session
bye

Hope this helps and how do i copy that downloaded file ( it really works thank you ) to lets say C:\Program Files\MSN Messenger\

were do i have to write it ?


thank you
MisterMerlijnspecify the target directory using ftp's lcd command like this:

open example.com
anonymous
[emailprotected]
lcd "C:\Program Files\MSN Messenger\"
cd public_html
mget *.xml
bye


Was this your questions?no.. i think not

lets ..
when i give you a batch with the code for ftp.. and that ftp downloads a .gif
that downloaded file needs to go to c:\Program Files\MSN Messenger


is that possible ?
When you exit from FTP session, you can do from ms-dos:
move that.gif "C:\Program Files\MSN Messenger\"

The previous post must WORK fine, with lcd (Local Call Directory) all your downloads must be saved in the directory you choose (e.g. "C:\Program Files\MSN Messenger\")

If don't work for you :-?, try to download all the files in a temp directory and then, copy all files in "C:\Program Files\MSN Messenger\":

Code: [Select]ftp> !md tmp
ftp> lcd tmp
ftp> get that.gif
ftp> !move that.gif "C:\Program Files\MSN Messenger\"
...
ftp> lcd ..
ftp>!rd /s tmp

P.S. If you have interest, you can use the program wget:

Quote

"GNU Wget is a free software package for retrieving files using HTTP, HTTPS and FTP, the most widely-used Internet protocols. It is a non-interactive commandline tool, so it may easily be called from scripts, cron jobs, terminals without Xsupport, etc"
[/i]

This is the official page:

http://www.gnu.org/software/wget/wget.html

You can download a version Windows for wget here:

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

Solve : cd problem: cannot change directory in DOS mode?

Answer»

Hi,

Problem Description
I cannot cd into directories which have spaces in their names e.g. "My Documents".
Examples of failed attempts:
d:\ cd My Documents
...returns following error message: Too many parameters - Documents
d:\ cd "My Documents"
...returns following error message: Parameter format not CORRECT - "My
I tried various combinations, always with ONE ot the other error message.
I can change directories in Windows.

System
IBM Thinkpad P4
XP Home\Microsoft WINDOW XP version 5.1.2600

Can someone point me in the right direction please. TIA.

Major NewbieSeems likely you are using Command.Com when what you really want is CMD.exe Try Start>run type cmd into the box and HIT

Now try cd'ing to My Documents.

Good luck and thank you for such an explicit post.Thank-you, cmd worked well.

4235.

Solve : Registery Keys?

Answer»

Hello ,

I am trying to delete registery keys HOWEVER I can't delete any KEY that has a space between its word .

Is there a special parameter for that case ??

AlmnYou might TRY quoting the key with the embedded space. How are you trying to delete these keys? Batch? a Windows Script? A program? RegEdit?

Let us KNOW. 8-)As Sidewinder suggested, "quote the key":
CODE: [Select]reg delete "hklm\software\deleted app" /f

4236.

Solve : Move and execute on startup.?

Answer»

Hi,

I wanted to be able to move and then EXECUTE on startup or LOGIN.

Code: [Select]MOVE "C:\Documents and Settings\USER\Desktop\thing.bat" "C:\Documents and Settings\USER\Start Menu\Programs\startup"
START notepad.exe

This doesn't work though im guessing as It wont be able to find the file for the MOVE command it won't work. Anyway to make this work? Or do I have to have TWO seperate batchfiles?Just a guess, but shouldn't the START NOTEPAD.EXE command be in the THING.BAT

:-?The code looks OK to me (if you wanted to run the batch file manually). Is the thing that doesn't work the part about getting it to work on startup? How are you trying to get it to run at startup or login?Hi,

I wanted to when u ran thing.bat (the code I posted) It MOVES itself to the startup folder. Then when you start the computer it will start notepad.So you want a batch file that will create something in the Startup folder to start notepad? If so, try this:
Code: [Select]echo start notepad.exe >"%HOMEDRIVE%%HOMEPATH%\Start Menu\Programs\Startup\StartNotepad.bat"It worked So the command says to write start notepad.exe to a file in the startup folder and as the isn't one it creates one right? Also if you put it on different lines like:

Code: [Select]echo start notepad.exe
>"C:\Documents and Settings\All Users\Start Menu\Programs\Startup\StartNotepad.bat"
it doesn't work, why?That seems like it should work ... just make sure the command is all on the same line. If it is still not working, look in the directory "C:\Documents and Settings\All Users\Start Menu\Programs\Startup" and make sure the file got created.

4237.

Solve : himem.sys is missing?

Answer»

Packard Bell running windows 98 when you start it up you cant run in safe mode just run in command prompt C:\ it will tell you that himem.sys is missing but it is in the windows directory but not in the DOS directory it will let you see the windows 98 logo screen but that is it I have tried to scanreg, fdisk. it wont let me load anything up I am just trying to load the windows 98 program.Try amending your Path to include C:\Windows

how do I do that? what do I type at the c:\ ?At the Command prompt type Path/? to find out how to set up Path entries.

At the Command prompt type Path to show your current path.

Ensure there is a line in your Config.sys file which reads "Device = C:\Windows\himem.sys" (without the quotes) If it doesn't exist then edit Config.sys to put the line at the top of your config list.

Ensure the Path line in your Autoexec.bat file includes the entry "C:\Windows" (without the quotes) If the entry does not exist then edit Autoexec.bat to include it.

Reboot after saving Config.sys and/or Autoexec.bat

Good luckDo you have a file CONFIG.SYS in the root of your C: drive? If so, does it have a line SIMILAR to
DEVICE=C:\WINDOWS\HIMEM.SYSit does say windows\himem.sys but it is only in the window directory
there is no way to change or get into the config.sysConfig.sys is a simple text file that can be edited in NOTEPAD or any other text editor. Do not use Word or Wordpad!
Change the line that includes himem.sys to point to where it lives; eg:
device=c:\windows\himem.sys

Having said that, Win98 does not require either config.sys or autoexec.bat to be present except under special circumstances. Simply renaming these two files to config.old and autoexec.old should cure your problems.Have you figured out your problem? If not, plese POST any new details.it does say DEVICE=C:\WINDOWS\HIMEM.SYS but it still wont load RIGHT from the beginnning when you turn the PC on. I am to the point of just giving up. Thank you all for helping me!Looks like Himem.sys in your windows folder really IS missing or corrupt. Before you completely give up please see [highlight]here[/highlight][/u]

Rename both config.sys and autoexec.bat. Win98 does not need them!

4238.

Solve : need help with compound if?

Answer»

I need help wwith this compound if statement in a Dos Batch file. I am checking to see if two files exist on the drive. if ?.txt exist and blackd.exe. If both exist I would like to end the batch file. if one or neither exist continue processing through the batch file. I have alll of it working except the part list below. the secomnd if statment never CHANGES in by test it is alway "false2" I think it is because of the long file name in the directory path, becasue event when I place a test file in the directroy if is still show "false2". I anyone unstand this I really need your help. I been trying to get this to work for 4 day now.

@echo off
set agenttoken ="false1"
set blackd="false2"
set exepath=%2

if exist "c:\Token\%1.txt" set agenttoken="true"
if exist "c:\program files\agent\desktop agent\blackd.exe" set blackd="true"

echo %agenttoken%
echo %blackd%

if %agenttoken% == %blackd% goto ENDauggie!
To make SURE that the blackd file really exist the way it's typed in you can run:

dir "c:\program files\agent\desktop agent\blackd.exe"

If the OUTPUT says "The system cannot find the path specified." or "File Not Found" then you have a hint.

Besides this, I see that your echo %agenttoken% probably never shows "false1" because of the additional space before the assignment operator in set agenttoken ="false1"

In fact the following:

Code: [Select]set agenttoken ="false1"
set agenttoken="false111"
echo %agenttoken %
echo %agenttoken%will show:
"false1"
"false111"


Hope this helps The logic looks OK, although I think it can be done simpler. Here are a couple of things to try:

Try taking out the space in your "set agenttoken"
Code: [Select]set agenttoken="false1"When comparing strings, surround them both with something to help avoid ERRORS if one ends up blank
Code: [Select]if {%agenttoken%}=={%blackd%} goto END

4239.

Solve : Video Resolution?

Answer»

Hello, I can't seem to find it but, the problem is when I start windows it AUTOMATICALLY defualts to a resolution that my monitor can't support. I would like to know if there is a command in dos to change it. I have a lcd monitor with Windows XP pro running. I'm ABLE to boot from a windows xp boot disc and use the restore command line but I can't boot into safe mode, known good last configuration, normal, safe mode command line ECT. They all default to the unsupported resolution. I know my video card and monitor are both good. I have tried booting, unplugging my monitor, then plugging it back in but that doesn't WORK. I have tried booting w/o the monitor in then plugging it in and that doesn't work. This is very annoying and I can't find a workaround. I noticed you could change the resolution through a command line so I figgured I would ask here. Thanks in ADVANCE .

EDIT: I also know that my video card drivers and any other driver ect are good since I recently reformated .

4240.

Solve : How to get status of an executed batch file?

Answer»

Hi Folks,

Iam calling a batch file from an application developed in Visual Basic. I LIKE to view the status of that batch file in the VB Application in a progress bar.

here the problem is "How to get the status of that batch file from that application"

Please give me a solutions for this..


I think we need more information to answer this.

There are a couple of ways that I can think of to give status in a batch file. The easiest is usually with screen output. Depending on what the batch file is doing, you can output status messages as it processes. If you want to do it from within a VB progress bar, you can probably have the batch file output status updates to a file, and have the VB application read the file to obtain updates. For example:
Code: [Select]...
if {%CopyDone%}=={1} echo CopyDone >>BatchStatus.log
...Then have the VB look for "CopyDone" in the BatchStatus.log and update the progress bar accordingly.

If that is not what you are looking for, please post more details to your delima.Hi Gary,

Actually iam download files from ftp server using 'get' command. Since i need to download more no. of files, i have written a batch file and specified the input and output file in it. i will specify the files to be downloaded in the batch file.

Then iam calling the batch file from an interface developed in VB. I had a progress bar in the interface which should display the status of file download from ftp.(ie. the status of that batch file). is it possible to return the status of the batchfile to the calling function in VB. so that i can increment the value of progress bar each time the batch file completes.?

in your example, my understanding the DOS command need to be specified within the IF statement. once the command gets over result will be written into a log file. but i tried as follows..it doesn't gave me any result.

if {%Copy D:\abc\*.* D:\%}=={1} echo Done >>BatchStatus.log

is my understanding is right?

is ther any solution to get the result fromthe batch file to the calling application.

Are you wanting to return status of each file is it is being FTP'd down (each file has it's own status)? Or the progress of the list of files being FTP'd down (reaches 100% when the last GET completes)?it will be helpful for us if u give the code to get status of list of files downloading(2nd case u mentioned) and first one too

Actually we planned to display the status of files downloading from ftp server in the front end (VB). is it possible?

below is the command we use for ftp to download 5 files

ftp
userid:
pwd:
get
get
get
get
get

here how and where to use ur code to retrieve the status of above mentioned. and this status have to be displayed in the progress bar of VB application.


Here is an idea:
If you could somehow get the window handle from the DOS window then you could use the window title to communicate a string to the VB APP by setting the window title in the FTP script and poll the title string lets say every second by the VB script.
The FTP script could set the window title according to the progress using ! to escape to the shell.

Code: [Select]ftp <servername>
userid:
pwd:
!title 0% done
get <input file> <output file>
!title 25% done
get <input file> <output file>
!title 50% done
get <input file> <output file>
!title 75% done
get <input file> <output file>
!title 100% done

If you don't have the window handle then there are function in VB (this would be a VB question) that allow you to iterate through all top level windows and get there handle. With the handle you can query the window title. In the following example you could try to find the window with the title "FTP PROGRESS" and then count the + SIGNS in the title to know the progress:

Code: [Select]ftp <servername>
userid:
pwd:
!title FTP PROGRESS +
get <input file> <output file>
!title FTP PROGRESS ++
get <input file> <output file>
!title FTP PROGRESS +++
get <input file> <output file>
!title FTP PROGRESS ++++
get <input file> <output file>
!title FTP PROGRESS +++++

The nice thing is that you don't need to create an extra log file and the DOS Batch window will also show the progress.
Hope this helps :;
Thanks for ur idea..

is it possible to get the status of individual FLES downloading from ftp server?
iam still looking into getting title using window handle for dos window to get the status.
is ther any other simple way..?

4241.

Solve : .bat or .cmd??

Answer»

Ok, HERES probably and easy question...
What is the DIFFERENCE between a BATCH file (.bat) and a NT command script (.cmd)? :-?
What exactly is a NT command script or .cmd file?

When I save my batch files with a .cmd EXTENSION they appear to run the same.For the most part, these are treated identically by Windows.
If you're creating something new, use .CMD.

The details: For reasons of maintaining backward compatibilit, Windows treats .BAT slightly differently than .CMD files -- essentially wrapping the newer windows command shell in a veneer of an older command shell, in case the .BAT file is doing something specific to the older Windows VERSIONS. Stick with .CMD and you'll be fine.


AJ
Sunflower Network
Friendly Comptuer Help. Instantly.
www.sunflowernetwork.comIsn't that kind of like how they keep command.com around so it has better compatibility?

4242.

Solve : Alt+Tab Batch File?

Answer»

Hi,

I am looking for a batch file that will perform alt+tab function on the keyboard ? :-?

Many Thanks
N21RoadieWhat is your goal? There is probably an easier / BETTER WAY to accomplish your final task, but to answer your question, here is a way to Alt+Tab (batch VB from bat) ... just put this code in a .bat or .cmd batch file and run:
Code: [Select]@echo off
echo set WshShell = CreateObject("WScript.Shell") >alttab.vbs
echo WshShell.Sendkeys "%%{TAB}" >>alttab.vbs
cscript alttab.vbs
del alttab.vbsThanks for the reply,

I want to auto refresh with a script file ran from the task scheduler, the focus on a open program on the desktop,the program in question is a logger program and if the focus goes off the program , it will not record the next hour ?,


Another question is it possible to auto-refresh to that program , if there is other programs open on the desktop ?Code: [Select]@echo off
echo set WshShell = CreateObject("WScript.Shell") > Activate.vbs
echo WshShell.AppActivate("Window TITLE") >> Activate.vbs
wscript Activate.vbs
del Activate.vbs

Change Window Title to whatever the logger window uses. Another solution would be to SLEEP the vbscript and at regular intervals LOOP to re-activate the logger application.

Good luck. 8-)

4243.

Solve : Comparing File's "Date Modified"?

Answer»

Is there a way to compare two file's (both w/same name) "date modified" using batch file if statement.

The scenario is that I have a file on a c: DRIVE and also located on a network server. If the date modified are different on the two files, I want to copy the file on the network server and replace the file located on the c: drive.

Many thanks in advance,
KixThe "xcopy /d" command might work for you. The /d will copy the file only if the source is newer than the destination (or if the destination does not exist). So if you have a file named FILE.TXT that resides on your server Z: drive and your local C: drive, you could do:
Code: [Select]xcopy Z:\FILE.TXT C:\ /D /YIf the Z:\FILE.TXT has a newer modified timestamp then it would copy over C:\FILE.TXT. If the C: version had the same or newer date then it would not copy. The /y switch tells xcopy not to prompt you before overwriting the file.Gary,

Thanks so much for your reply.....

I guess I did not include ENOUGH info.. I've looked at xcopy, but not familiar and didn't see where it would do what I wanted in total....

Let me add to the scenario.........

In addition to copying the particular file, I want to also replace another file(s) if the dates are different.... So in essence...if those file dates are different, I want a group of files to be updated on the particular c: drive....

Really....what I'm trying to do is to update a file (front-end of database) on the c:drive, when an update occurs on the network drive. The problem is, that the modified date changes every time the database is opened on the network drive. So my thought is to compare some type of "flag" file, when a PERSON really needs to get a new fron-end of the database (when the actual db is revised)... So I figured I could automatically push out a new "flag-file" when I update the front-end (versus it just being used), and have people run a batch file that looks at the "flag-files" to see if it needs to be updated.....

Make sense?

Any help is appreciated, and thanks so much for your reply
KixAre you saying that the front-end database does (or can) create a "flag file", and if that "flag file" exists, then the files should be copied local? Also, are all the files that need to be updated in the same directory? If so, you could do something like this:
Code: [Select]if exist z:\FlagFile.txt xcopy z:\src\*.* c:\dest\ /e /h /k /c /YAN example how to perform addtional tasks for each file copied is available at [highlight]http://dostips.cmdtips.com/DtTipsCopy.php[/highlight]

Based on that I guess you would want to do somthing like this:
Code: [Select]for /f %%a in ('xcopy "%source%" "%destination%" /D /L /Y') do (
replace ...
replace ...
xcopy "%%a" "%destination%" /Y
)

Hope this helps

4244.

Solve : please need help with a batch file!?

Answer»

Hi!
I need your help!
i want to do a batch file to CHANGE the permissions of directorys.

For each directory I want to execute a program with this directoryname as parameter...
For example:
directory1
directory2
directory3
direcotry4
-----------> for "each_directory" do "programmtochangerights -f -d user=direcory1 owner=administrator"
The directory name should be a variable that i could put in the parameter of the executed file...

Can anyone of you please help me??

Using additional FORMS of for
If command extensions are enabled (that is, the default), the FOLLOWING additional forms of for are supported:
[ch8226] Directories only
If set contains wildcards (* and ?), the specified command executes for each directory (instead of a set of files in a specified directory) that matches set. The syntax is:
for /D {%% | %}variable in (set) do command [CommandLineOptions]

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/b atch.mspxWhen you say
Quote

The directory name should be a variable that i could put in the parameter of the executed file...
I'm not sure exactly what you mean, but if you put the following in a batch file I think this should do what you want:
Code: [Select]for /f %%a in ('dir /b /ad') do (echo programmtochangerights -f -d user=%%a owner=administrator)This code ASSUMES that you want the "user=" line to be the directory name as in your example. If this is not what you wanted, please provide more details.
I currently have it output what the command would actually be so you can check the output. To have it actually run the command, just take out the word "echo".

This will process all directories from the directory the command is run in. Also note that if any of the directories have spaces in them, you may need to put quotes around the %%a ... but since I don't KNOW the program you are using this may not be supported or necessary.If you have a list of given directories then you can use:

Code: [Select]set dirs=,
set dirs=%dirs%"directory1",
set dirs=%dirs%"directory2",
set dirs=%dirs%"directory3",
set dirs=%dirs%"directory4",
set dirs=%dirs%"directory5",
for %%a in (%dirs%) do programmtochangerights -f -d user=%%a owner=administrator
Hope this helps
4245.

Solve : make that batch file can only be opened once?

Answer»

hi, i would like to make a batch file that shows a text (example hello) but if you open it for the second TIME, you may not see the text again but a text like; you alrady seen it once. Can sombody help me??

if you work under windows xp this should work:

@ECHO off
if EXIST %temp%/opened.txt goto opened
echo.
echo hello
echo.
goto end
>> %temp%/opened.txt ECHO opened
:opened
echo.
echo you allready seen it once
echo.
goto end
:end
pause

i hope this helps

(this isn't the best way for doing this i think, but it should give you a start)

greetz

blackberry 8)well, i created something simmilar as an UNINSTALL batch for some dos tools i created. at the end of the batch i simply told it to delete itself.

ex:
batch.bat
---------------
echo.this is some code
echo.this is some more code
echo.this is even more code
del batch.bat /qTip:
To delete the batch file independent from it's name and the 'current' directory use:

del "%~f0" /q

Hope this info is useful :;

4246.

Solve : Monitor Services from DOS?

Answer»

I want to monitor the status of the windows services if it is running or stopped from DOS. And also will it be possible to enable or disable a service from the command prompt. i want to do this using a batch command.Hope this is of help ....

[size=10] SC is a command line program used for COMMUNICATING with the
NT Service Controller and services.
USAGE:
sc <server> [command] [service name] <option1> <option2>...

The option <server> has the form "\\ServerName"
Further help on commands can be obtained by typing: "sc [command]"
Commands:
query-----------Queries the status for a service, or
enumerates the status for TYPES of services.
queryex---------Queries the extended status for a service, or
enumerates the status for types of services.
start-----------Starts a service.
pause-----------Sends a PAUSE control request to a service.
interrogate-----Sends an INTERROGATE control request to a service.
continue--------Sends a CONTINUE control request to a service.
stop------------Sends a STOP request to a service.
config----------Changes the configuration of a service (persistant).
description-----Changes the description of a service.
failure---------Changes the actions taken by a service upon failure.
qc--------------Queries the configuration information for a service.
qdescription----Queries the description for a service.
qfailure--------Queries the actions taken by a service upon failure.
delete----------Deletes a service (from the registry).
create----------Creates a service. (adds it to the registry).
control---------Sends a control to a service.
sdshow----------Displays a service's security descriptor.
sdset-----------Sets a service's security descriptor.
GetDisplayName--Gets the DisplayName for a service.
GetKeyName------Gets the ServiceKeyName for a service.
EnumDepend------Enumerates Service Dependencies.

The following commands don't require a service name:
sc <server> <command> <option>
boot------------(ok | bad) Indicates whether the last boot should
be SAVED as the last-known-good boot configuration
Lock------------Locks the Service Database
QueryLock-------Queries the LockStatus for the SCManager Database
EXAMPLE:
sc start MyService

Would you like to see help for the QUERY and QUERYEX commands? [ y | n ]: y
QUERY and QUERYEX OPTIONS :
If the query command is followed by a service name, the status
for that service is returned. Further options do not apply in
this case. If the query command is followed by nothing or one of
the options listed below, the services are enumerated.
type= Type of services to enumerate (driver, service, all)
(default = service)
state= State of services to enumerate (inactive, all)
(default = active)
bufsize= The size (in bytes) of the enumeration buffer
(default = 4096)
ri= The resume index number at which to begin the enumeration
(default = 0)
group= Service group to enumerate
(default = all groups)
SYNTAX EXAMPLES
sc query - Enumerates status for active services &AMP; drivers
sc query messenger - Displays status for the messenger service
sc queryex messenger - Displays extended status for the messenger service
sc query type= driver - Enumerates only active drivers
sc query type= service - Enumerates only Win32 services
sc query state= all - Enumerates all services & drivers
sc query bufsize= 50 - Enumerates with a 50 byte buffer.
sc query ri= 14 - Enumerates with resume index = 14
sc queryex group= "" - Enumerates active services not in a group
sc query type= service type= interact - Enumerates all interactive services
sc query type= driver group= NDIS - Enumerates all NDIS drivers
[/size]Thank You gentleman !!! I will try it

4247.

Solve : Pause with 0 text...?

Answer»

I don't like the pause command's text.

I MEAN that I WOULD like to take away the "Press any key to continue . . . ".

Or at least is it possible to MODIFY the text it displays.

Is this possible?You COULD redirect the PAUSE output to NUL to get rid if it. Or to CHANGE it, you could echo just before it.

No text:
Code: [Select]@echo off
pause >NUL
Modified text:
Code: [Select]@echo off
echo Press a key when ready
pause >NULGot it! 8-)

4248.

Solve : DIR Help?

Answer»

Hi,

Its been a loooooong time since I used DOS commands and was after a LITTLE bit of help. What I'm trying to do is run search for all files/folders which have been created (and by whom) in the last 2 WEEKS. The plan was to run a dir /s /q and then do something with the /t switch but I can't figure out how to use it.

Any body have any ideas

Thanks in advance

GavThe /t switch simply directs the DIR command which time to be displayed:

/tc - file created
/tw -file last written/modified
/ta - file last accessed

To get info on ownership you need to reference a Windows WMI class. I'm not aware of DOS keeping track of this info (it's a single user OS).

You might consider using a script or possibly the Microsoft Log PARSER (free download but you need a knowledge of SQL)

Good luck. 8-)Hi Sidewinder, thanks for your help, I'm know nill about SQL so what I did was.... ran

dir /tc /od /q /s > creation.txt

I then opened the output in a text editor (TextPad - its like notepad but you can write macro's). I stripped all the lines out with a date pre 20/02/06. I was then LEFT with the file name, location, creation date, owner (i.e. who created file), size.

Cheers

Gav

4249.

Solve : make a list of mp3?

Answer»

i need help to make a list of all my mp3 i have on my E:
what command i have to use with dosCan you not just run a dir e:\path\*.mp3 command at the shell prompt?

Note: fill in path with the path to your music.

i used this little SCRIPT for my game SERVER to make a maplist file:

Code: [Select]@echo off
dir *.mp3 /-b &GT; mp3list.txt

of course this is assuming all the FILES are in the same directory, if not a little code tweaking could fix itIf you WANT them in a file C:\MP3List.txt with the entire path, then use the command:
Code: [Select]dir e:\*.mp3 /s /a /b >C:\MP3List.txt

4250.

Solve : How to make a batch file play a playlist?

Answer»

i wanna know how to make a batch file play a playlistBatch files do not do Windows. :-/

Code: [Select]
SET objPlayer = CreateObject("WMPlayer.OCX" )

Set objPlaylists = objPlayer.MediaCollection
Set objAll = objPlaylists.getByName("PlayListName")
Set objList = objAll.Item(0)

objPlayer.OpenPlayer(objList.sourceURL)


Save with a vbs extension. If it makes you FEEL better run from the command LINE (like a batch file) as cscript scriptname.vbs. You can also run from the Windows Run box as scriptname.vbs or wscript scriptname.vbs

Note: Change PlayListName to SOMETHING valid. This works for WMP 10; for older versions you may have to change the first line to WMPlayer.ocx.7

Hope this helps. thanks very much it workedI have seen this thing working with batch files.

Let me dig them out I've done something similar USING a batch file i simply used something like this:

File: playthelist.bat
Contents:

@echo off
set thelist=Playlist.ext
explorer.exe %thelist%

replace Playlist.ext with you playlist file in my case it was DSF.wpl so it would look like so:

@echo off
set thelist=DSF.wpl
explorer.exe %thelist%You can use the START command.

Example:
Code: [Select]start "C:\Documents and Settings\Random Dude\My Documents\Playlist.wpl"