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.

8501.

Solve : Comparing time as a string?

Answer»

Hello Experts,

I'm tring to check if a file arrives before midnight. However the "if time equals" does not work. Here is the relavant section, any suggestions? Thanks in advance!

:BEGINWAIT
FOR /F "TOKENS=*" %%A IN ('TIME/T') DO SET TIME=%%A
IF EXIST %PathInbox%\NewFile.DAT GOTO FILEEXIST
IF "%TIME%" == "12:00 AM" GOTO ENDTIMEWAIT

GOTO BEGINWAITYou are going to hit a problem of name collision because %TIME% is already a system variable, (guess what it contains?). Choose a DIFFERENT name eg %mytime%. That should do it.

On my system, right now, %time% reads 20:40:07.47

(I am a euro weenie who uses the 24 hr clock, so time /t produces 20:40)


If you STILL need help I'd need to know between what times you'd want it to check. Because it's ALWAYS before Midnight.Quote from: DeltaSlaya on August 28, 2007, 03:12:11 PM

If you still need help I'd need to know between what times you'd want it to check. Because it's always before Midnight.

Good point Delta. That code must be started manually every day I guess.

Well if you're starting it manually it doesn't even need to check the time then, just the existence of the file.Quote from: DeltaSlaya on August 28, 2007, 03:36:21 PM
Well if you're starting it manually it doesn't even need to check the time then, just the existence of the file.

Yes it does, it has to wait around until the next midnight. Did you read the batch code at all?
Oh, I see, so it's SUPPOSED to loop until the file arrives or the time is midnight? Thats easy enough.if that's the case, it would be simpler to just schedule a job at or after 12 midnight to query the existence of the file, instead of looping everytime.As it stands the code decides whether midnight has arrived by looking for "time /t" giving "12:00 AM" as an output. So strictly speaking it is not checking whether midnight has passed, it is checking if it is midnight "now". To be sure of not missing it the code needs to run continuously, which seems a bit inefficient to me. Although once every 30 seconds would still hit the window. More efficient and more elegant to check every once in a while whether midnight has gone past. A challenge might be the time format which depends on locale. (Americans like their AM / PM etc whereas we Euro weenies have our 24 hour format). So I'd store %date% as a string (e.g. set startdate=%date%) and just check every once in a while if it has changed yet (as it does at midnight every day). IF NOT "%startdate%"=="%date%" it's the next day.




Quote from: ghostdog74 on August 29, 2007, 12:44:05 AM
if that's the case, it would be simpler to just schedule a job at or after 12 midnight to query the existence of the file, instead of looping everytime.

Simpler and more logical.
8502.

Solve : Check for document name 1 in %1?

Answer»

Hi!

I have a file that stores a document name in %1. How do I compare what is stored in %1 to a specific document name?

I WANT to CHECK if the document name stored in %1 is "document name NR 1", and if it is I will do ONE thing, but if it's not I will do something else.

Sorry, but I'm not good at this at all.

Thanks,
KarenUse IF with quotes and double equals signs, and goto a label.

Quote

IF "%1"=="document name nr 1" goto same

goto notsame

:same

...commands to execute if %1 is document name nr 1

goto next

:notsame

...commands to execute if %1 is NOT document name nr 1

:next


Thank you! I will try that right away.

/Karen
8503.

Solve : Open and Reading the file?

Answer» HI,
I just tried the second line in the batch file. Find the output below:

C:\TEMP>sample.bat

C:\TEMP>for /F "usebackq tokens=4 delims='" %I in (`findstr /i "reportSearchPath
" "test.xml"`) do (set output=%I )

C:\TEMP>echo *actual name found:* %%I
*actual name found:* %%I

C:\TEMP>pause
Press any key to continue . . .

C:\TEMP>

...

Sorry to confuse you but could you run that batch file with the example xml you supplied in the same folder...I ran the batch file with only the second statement in the same folder as the XML file.With the xml file called test.txt? See I don't know why that's not working sorry, logically it should and it does for me.The xml file is test.xml and not test.txt. It has to be saved as ".xml" Am trying with the same, but no result I meant test.xml, sorry. Looks like you'll have to go with the VBS for now, unless someone more expert than me in Batch can figure it out?

Ghostdog, have you tried my script? Does it work for you?Quote from: DeltaSlaya on August 21, 2007, 10:51:46 PM
Ghostdog, have you tried my script? Does it work for you?
no, have not. can u post your latest version of the batch, and the format of the xml you have.Heres the latest code, I believe:

Quote
@echo off

:: Change "C:\OUTPUT" to output directory with NO "\" at end.
set outdir=C:\OUTPUT
if not exist "%outdir%" (
echo Output folder not exist.
pause >nul
exit
)

:: Change "C:\" to input directory with "\" at end.
cd C:\


set input=

:: Check for xmls
if not exist "*.xml" (
echo No .xml FILES.
pause >nul
exit
)

:: Set input to last modified .xml in dir
for /f "usebackq delims=" %%I in (`dir /b /a:-d /o:-d "*.xml"`) do (
set input=%%~nI
goto out
)

:out

:: Grab 'actual' name of pdf from xml
set output=

for /f "usebackq tokens=4 delims='" %%I in (`findstr /i "reportSearchPath" "%input%.xml"`) do (
set output=%%I
goto copy
)

:copy
set output=%output::=-%
copy "%input%.pdf" "%outdir%\%output%.pdf"
pause

And the .xml file

Quote
<?xml version="1.0" encoding="utf-8" ?>
- <!-- Copyright (C) 2006 Cognos Incorporated. All Rights Reserved.
Cognos (R) is a trademark of Cognos Incorporated.

-->
- <!-- Experimental.
Product features described in this file may not be supported in future releases.

-->
- <outputDescriptor xmlns="http://developer.cognos.com/schema/OutputDescriptor/1.0" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<asOfTime>2007-08-12T13:38:08.093Z</asOfTime>
<burstKey />
<contact />
<defaultDescription />
<defaultName>2007-08-12T13:38:09.078Z</defaultName>
<fileName>1376_1186940289078.pdf</fileName>
<locale>en-us</locale>
<owner>rgajendra</owner>
<ownerNamespace>COGNOS-DEV Team</ownerNamespace>
<parameterValues />
<reportSearchPath>/content/package[@name='Provider']/report[@name='PRV-INT-001:Provider NCPDP Interface Error Report']</reportSearchPath>
<reportViewSearchPath>/content/folder[@name='COGNOS-DEV Team']/reportView[@name='Report View of PRV-INT-001:Provider NCPDP Interface Error Report']</reportViewSearchPath>
</outputDescriptor>

You will also need a .pdf file of the same name in the xml's directory. The variables to set are clearly defined.
Also could the OP please try that again, I noticed that it wasn't working because it was looking in extension not the file name?well, i think it does work.
Code: [Select]C:\temp>dir /B
test.pdf
test.xml
test1.pdf
test1.xml

C:\temp>cd ..

C:\>test.bat
1 file(s) copied.
Press any key to continue . . .
C:\temp>dir /B
PRV-INT-001-Provider NCPDP Interface Error Report 2.pdf
test.pdf
test.xml
test1.pdf
test1.xml

however, only for 1 file. Needs extra for loops to iterate multiple xml files(or maybe not, by OP's requirements)..however that's another story.Well he said the most recent, thats what it does, yet for some reason does not do anything for them. I still believe on their end they entered something wrong or changed something. They should try the above, by itself with the right things changed and all the correct files and dirs present.Honestly, if the OP hasn't got my code working then there's no real point anyway. They said it would be run after each time the files have been created.

Anyway, how I would have done it, using skip=. I'm just wondering why does skip=0 not work? It just skips the 0, I guess if skip is defined then you can't perform a command on the first line..Ghostdog,

I ran the script with two files in the src folder. But, its moving only the 1st file and not the second one. Below is the output:

C:\vbscript>vb_batch.bat

C:\vbscript>CD C:\vbscript

C:\vbscript>cscript /nologo vb_script.vbs
found PRV-INT-001 PRV-INT-001
The string to replace is PRV-INT-001-Provider NCPDP Interface Error Report
PRV-INT-001-Provider NCPDP Interface Error Report.pdf
Renaming pdf ...
found PRV-INT-002 PRV-INT-002
C:\vbscript>

here's a modification
Code: [Select]Dim objFSO,objFile,objRE,colMatches,oMatches
Dim myFiles, srcFolder, dstFolder,dstFile,line,strToFind,strFileName
Dim pdfBase,xmlBase,i,strContents
Dim pdfStore(),pdfFullStore() 'define some array to store paths
Set objFSO = CreateObject("Scripting.FileSystemObject")
srcFolder="c:\temp" 'Server source folder location
dstFolder="c:\temp" 'Destination Folder as desired
i=0 'array counter
For Each myFiles In objFSO.GetFolder(srcFolder).Files
If objFSO.GetExtensionName(myFiles) = "pdf" Then
pdfBase = objFSO.GetBaseName(myFiles)
ReDim Preserve pdfStore(i)
ReDim Preserve pdfFullStore(i)
pdfStore(i)=pdfBase
pdfFullStore(i)=myFiles
i=i+1
End If
Next
For Each myFiles In objFSO.GetFolder(srcFolder).Files
If objFSO.GetExtensionName(myFiles) = "xml" Then
xmlBase = objFSO.GetBaseName(myFiles)
For i=LBound(pdfStore) To UBound(pdfStore)
If pdfStore(i) = xmlBase Then
WScript.Echo "found " , xmlBase, pdfStore(i)
strToFind = getString(myFiles)
dstFile = strToFind&".pdf"
objFSO.MoveFile pdfFullStore(i),dstFolder&"\"&dstFile
End If
Next
End If
Next

Function getString(theFile)
Set objRE = New RegExp
objRE.Global = True
objRE.IgnoreCase = False
objRE.Pattern = "<reportSearchPath>.*/report\[@name='(.*?)'\]</reportSearchPath>"
Set objFile=objFSO.OpenTextFile(theFile,1)
strContents=objFile.ReadAll
Set Matches = objRE.Execute(strContents)
For Each match In Matches
For Each smatch In match.Submatches
result=Replace(smatch,":"," ")
Next
Next
getString = result
End Function

output:
Code: [Select]C:\vbscript>dir c:\temp /B
test.pdf
test.xml
test1.pdf
test1.xml

C:\vbscript>cscript /nologo MoveCogNosReports2.vbs
found test test
found test1 test1

C:\vbscript>dir c:\temp /B
PRV-INT-001 Provider NCPDP Interface Error Report.pdf
PRV-INT-002 Provider NCPDP Interface Error Report.pdf
test.xml
test1.xml

Hey! Tx... but am able to use the previous script. Vl run this script and let u know in case of NE issues
8504.

Solve : Command Prompt Doesn't Work?

Answer»

Quote from: smlh89450 on August 28, 2007, 09:25:33 AM

PATH=C:\Program Files\Java\jdk1.6.0_01\bin;C:\Program Files\Java\jdk1.6.0_01\bin

I thought as much! I was right!

That is why shutdown.exe (and every other external command!!!!) won't work from the command prompt. Somehow your PATH variable has got seriously corrupted! This is a standard PATH as found on a new XP install

Quote
C:\Windows\System32\;C:\Windows\;C:\Windows\System32\Wbem

Additions are SUPPOSED to be tacked on at the end, it looks like yours got nuked by whatever put that Java stuff there.

Here's how to put things right

1. Right click My Computer, CHOOSE properties.
2. Choose Advanced tab.
3. Click on Environment Variables button.
4. in the SYSTEM Variables (lower part) Highlight PATH. (You have to scroll down)
5. Click the Edit button.
6. The "Edit System variable" dialog comes up.
7. The whole PATH string will be highlighted. Hit the END key to unhighlight it and position the typing cursor at the end.
8. Type a semicolon ( ; ) at the end so it reads like this

C:\Program Files\Java\jdk1.6.0_01\bin;C:\Program Files\Java\jdk1.6.0_01\bin;

9. Copy this whole line to the clipboard

C:\Windows\System32\;C:\Windows\;C:\Windows\System32\Wbem

10. Paste it at the end of your PATH so it looks like this

C:\Program Files\Java\jdk1.6.0_01\bin;C:\Program Files\Java\jdk1.6.0_01\bin;C:\Windows\System32\;C:\Windows\;C:\Windows\System32\Wbem

11. OK three times to come right out.

12. Reboot

13. CHECK PATH looks like above.








Thank you so much. Command Prompt works perfectly now!Nice piece of work contrex ! !

Thank you.

8505.

Solve : accessing properties from dos command line?

Answer»

1. I need to FIGURE out how to access the properties tab from the command line.

Basically, I am trying to use some of the info in properties (specifically, the width and height of a video file) for inclusion in a script (python, calling os.system to use the command line). So, instead of right-CLICKING, selecting properties, clicking on summary, and looking at width and height under "IMAGE" to get the dimensions, I like to see if I can get the width and height (or all properties, whatever) printed out to the screen (to be redirected to a text file and read in to the script.)

I know you can use "dir" and the filename to find the size, but I absolutely cannot figure out how to display any other properties.

2. A less important question, and possibly something better answered for python than for dos, but something else I'm trying to figure out: what's the best way to distinguish between directories and files in a folder? I'm looking for something like an "isDirectory()" kind of function.

Thanks.Quote from: thecottonginny

1. I need to figure out how to access the properties tab from the command line.
you can use vbscript:
Code: [Select]Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace("C:\temp")
For Each strFileName in objFolder.Items
If strFileName = "myVideo.avi" Then
For i = 0 to 34
WScript.Echo i, objFolder.GetDetailsOf(strFileName,i)
Next
Exit For
End If
Next
save as myscript.vbs and on command prompt, type cscript /nologo myscript.vbs
output:
Code: [Select]Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

0 myVideo.avi
1 418 KB
2 Video Clip
3 3/19/2002 5:26 AM
4 8/11/2007 11:06 AM
5 8/11/2007 11:06 AM
6 RA
7 Online
8 MYNEWNAME\Administrator
9
10
11
12
13
14
15
16
17
18
19
20
21 0:00:00
22
23
24
25
26 1024 x 768
27 1024 pixels
28 768 pixels
29
30
31
32
33
34
you can see that index 26-28 contains the video information

Quote
2. A less important question, and possibly something better answered for python than for dos, but something else I'm trying to figure out: what's the best way to distinguish between directories and files in a folder? I'm looking for something like an "isDirectory()" kind of function.

check out the Python docs for os.path module.
Basically, to check if its a file, use os.path.isfile(), or directory use os.path.isdir()
Thank you! This REPLY is ages late, but it took awhile before it was necessary for me to implement this code.

Also, there's one change to make here, at least on my COMPUTER:

"myVideo.avi" should be changed to "myVideo" - for whatever reason, you don't include the extension. This wasn't a problem for me (once I figured it out!) but may be a problem for others if they have multiple files with the same name but different extensions. On files with the same name it will pick the avi file though, I guess because it's earlier in the alphabet.
8506.

Solve : writing multiline .txt?

Answer»

no,i'm not crazy, i'm just a noobQuote from: Fantini on August 24, 2007, 03:15:50 PM

I have this .bat:

...
and I want to make it LOOK like this:

Code: [Select]ECHO off
title TarreWoW Launcher V0.1 by Fantini
cls
:START
ECHO.
ECHO 1. TarreWoW
ECHO 2. Servidor numero 2: %opcion%
ECHO 3. Salir
set /p choice=Elige el Servidor Porfavor:
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto tarrewow
if '%choice%'=='2' goto servidor 2
if '%choice%'=='3' goto end
ECHO "%choice%" No ES una opcion valida, intentalo denuevo porfavor
ECHO.
pause
cls
goto start
:tarrewow
ECHO SET realmlist tarrewow.getmyip.com > realmlist.*censored*
goto end
:servidor 2
ECHO SET realmlist %opcion% > realmlist.*censored*
goto end
:end
cls
ECHO.
ECHO TarreWoW Launcher V0.1 by Fantini
ECHO Gracias por preferirnos...
ECHO.
pause
but when I edit my TarreWoW.bat I see '' instead of '%choice%'

Open notepad or any editor you like, key in the code above save it as some name you like, and you are ready to go.you can go like this echo %%hello%%>file.txt
or
echo if '%%choice%%'=='3' goto terrewow >>tarrewow.batHi Fantini!

I request you to please TRY to use the COPY CON filename.txt command for storing text in multilines.

For e.g. C:\>COPY CON filename.txt
write some text here with multilines. When writing of files is over press CTRL+Z button to save the contents of file.

You may also press F6 button instead of CTRL+Z.
8507.

Solve : Formating Win 95 PC?

Answer»

I am discarding an old PC and TRYING to format the partitioned C and D hardrives. When I put in the DOS command "C: format", I get an error message : "Drive C: is currently in USE by another process aborting format" I don't know what is BLOCKING the format, nor how to clear it. TRAVEL to bootdisk.com and DLoad a Win98 bootdisk with CDRom support.
Unzip the files to a clean floppy.
Put the floppy in and re-boot.
At the A: prompt type in format C: /U and hit Enter
That should work.
Do the same for D:

p.s. Why not just pull the HDD out ? ?

8508.

Solve : .bat that opens all .bat files in the subfolders of its folder?

Answer»

The subject pretty much tells it all

I am WORKING on Windows XP, I would prefer not to download any thing and it would be nice for you to explain how it works if you can.

I am Working on a bat which will hide files within the folder it is in. I want a master bat to open all of them at once.

It would also be nice if it could do this with the bats being hidden.what have you got so FAR...I dont have any thing so far, i have been working on the hider, (the program it is opening)

The program is such.. (a neater VERSION then before)

@ ECHO OFF
title Image Concealer
:: A Sir.Laggalot Creation

IF EXIST *.jpg. GOTO HIDE
IF EXIST *.gif. GOTO HIDE
IF EXIST *.png. GOTO HIDE
IF EXIST *.mp3. GOTO FIX
IF EXIST *.mp4. GOTO FIX
IF EXIST *.avi. GOTO FIX
ECHO.
ECHO ERROR-
ECHO There are no .jpg, .gif, .png, .mp3, .mp4, or .avi files to effect.
ECHO.
ECHO.
PAUSE
GOTO END
:HIDE
REN *.jpg *.mp3
ATTRIB "./*.mp3" +h
REN *.gif *.mp4
ATTRIB "./*.mp4" +h
REN *.png *.avi
ATTRIB "./*.avi" +h
GOTO END
:FIX
ATTRIB "./*.mp3" -h
REN *.mp3 *.jpg
ATTRIB "./*.mp4" -h
REN *.mp4 *.gif
ATTRIB "./*.avi" -h
REN *.avi *.png
GOTO END
:ENDAND you want to....open all those files at once?

Quote

I want a master bat to open all of them at once.
I got a rough way to do it now but i want a bat file which will find all bat files of a certain name or not in the subfolders of a folder and execute them.Hi, I hope this will help you out.

You can USE the ATTRIB command to protect as well as hide all the files inside any directory.

you can use this command to hide.

ATTRIB +s +r +h *.*

In order to run each .bat file you can use CALL batchfilename.bat command in master batch file to run individual batch files.

In fact you can also use START batchfilename.bat command to start a new window for running batch files.

8509.

Solve : 20 sec refresh error?

Answer»

I have the below code which assists me in running a PLASMA display screen.

@ECHO OFF
Start C:\Plasma\ACD_Refresh.acsauto
ping -n 2 127.0.0.1 > nul
Start C:\Plasma\Test_ACD_Report.xls
:start
Start C:\Plasma\ACD_Refresh.acsauto
ping -n 21 127.0.0.1 > nul
goto start

basically the code will the file ACD_Refresh.acsauto every 20 seconds which outputs real time data to a csv file.

Every now and then i seem to get the following error which causes a error messagge to appear over the top of my excel workbook which gets in the way of the display data.

Is there anyway to skip the refresh if it has a problem and then wait another 20 seconds it to loop round? mabe you have another suggestion?

sorry the error msg was 'The application failed to initalise properly (0xc0000142). Click on OK to terminate the application.The problem appears to be having ACD_Refresh.acsauto in one window, the spreadsheet in another window and the batch file itself in a third window. Does ACD_Refresh.acsauto return an errorlevel? A Windows Script solution is probably better than batch.

8-)im not sure, i dont pretend to know much about this at all and im not sure the answer to your question. How can i best go about this as i have the display screen working with exception to this error.Batch code does not do Windows; sad but true. This snippet may help:

Code: [Select]Set WshShell = CreateObject("WScript.Shell")
WshShell.Run "C:\Plasma\ACD_Refresh.acsauto",,True
Wscript.Sleep 2000
WshShell.Run "C:\Plasma\Test_ACD_Report.xls",,False
Refresh

Sub Refresh()
rc = WshShell.Run("C:\Plasma\ACD_Refresh.acsauto",,False)
If rc <> 0 Then
WshShell.AppActivate "[highlight]error box windows title goes here[/highlight]"
WScript.Sleep 1000
WshShell.SendKeys "~"
End if
WScript.Sleep 20000
Refresh
End Sub

Replace the highlighted text with the real title of the error box. Save the script with a vbs extension and run from the command prompt as wscript scriptname.vbs

Good luck 8-)

PS. I couldn't test this obviously so be prepared for the script to have errors. I assumed acsauto returned a non-zero return code when it failed. We all know what HAPPENS to people who assume.thats great thank you very much. Is there anyway to stop the script without rebooting?A reboot does seem RATHER harsh. Bring up the task manager (ctl-alt-del) and end the task wscript.

Try running the script as cscript scriptname.vbs. You should be able to use ctl-C to end the script. The spreadsheet may still have to manually shutdown.

8-)I got the following error when i checked the screen this morning and had to reboot the PC.

I THINK it may be because its trying to obtain data when the host system is going through its end of day run. Is there anyway to apply a time gate to it so it only runs between the hours of 7am and 11pm ?

windows script host
script c:\plasma\
line 8
char 2
error out of memory: wshshell.run
code 800a0007
source microsoft runtime vb errorThis morning i experianced the error again

sorry the error msg was 'The application failed to initalise properly (0xc0000142). Click on OK to terminate the application.

Im wondering if this error occurs vecause the ACD_refresh file the is run is trying to create the csv whilst my excel spreadsheet is importing from the existing one.

Is there a way to get the prog to CHECK if the file is in use before running the ACD_refresh script first, if its in use it could skip and reloop until its free.

thank you for your help this is really apppreciated,In your original post you had all the jobs being started into separate windows; it's amazing the jobs were ever able to get in sync. Now it beginning to appear this run unit should run each job in-line as the spreadsheet is dependent on the refresh program to create a csv file.

Questions: Are you using Excel for the spreadsheet? In your original post, the spreadsheet is loaded outside the loop. Is there a macro controlling the spreadsheet, in other words what triggers the spreadsheet to import the newest csv file from the refresh program?

8-)

Please post the title of the error box, not the error message. Thanks.Yes im using Excel to display sheets in a particular order through use of a macro.

To simplify

The ACD_refresh when run creates an csv
The excel spreadsheet pulls in via code the csv file approx every 20 secs
The excel spreadsheet also connects and download data from a server once an hour
This allows me to display the data and through use of a macro i rotate the sheets every 20 seconds in this code the csv file is pulledNormally I would suggest writing a VBScript for the entire run unit since Excel can be scripted very easily. Since you've already written most of the code as an Excel macro, it should be a simple matter to run the refresh program from within the macro using the shell function. You will need to get the spreadsheet kickstarted (batch file?) and then all the components (refresh, import data, connect to server) will be under control of a single macro.

Good luck. 8-)

8510.

Solve : Edit colon separated text file??

Answer»

You did the slashy thing the wrong way round. / is not the same as \.You know what? You ROCK!!! I got both versions to work now, yay!

Thank you so much!!Great!

Just REMEMBER all that INFO about how to CHANGE what line, what string to search for and the location on the line and you'll be sweet.

If you need anymore help we're always avaliable ! !

8511.

Solve : Mapping drives with a startup batch - Wi-Fi network...?

Answer»

Hi,

This is driving me crazy.

I have a home network with 2 desktop PCs (Ethernet, WInXP Home) and a laptop PC (Wi-Fi, WInXP Home), all connected through a Linksys WRT54G router, and a small Synology file SERVER.

5 shares are specified on this server. I want all PCs to automatically map these shares as network drives on WinXP startup. I created a batch file containing 5 lines like this one :

net use Z: \\DiskStation\shared_folder password /user:username /PERSISTENT:yes

(Even with "persisent", I have to execute the batch after each startup, as OTHERWISE the drives are just mapped but not connected -- they appear as "disconnected network drives")

I've put the .bat in Documents And Settings\All Users\Menu Démarrer\Programmes\Démarrage (sorry this is in French, it's the startup FOLDER of the Start menu). This works absolutely fine on the Ethernet PCs.

Now, on my laptop, the booting of the computer is a bit longer, and unfortunately the .bat file is executed before the wi-fi connection is established, so the drives do not connect.

Therefore, I needed a way to delay the execution of the .bat file. I've tried several solutions :
-Using Wait.exe
-Inserting this line at the beginning of the .bat file : ping 1.1.1.1 -n 1 -w 60000 &GT;NUL
-Doing the same as above, but with two batches : the 1st lauching the 2nd one after a delay

All these solutions do not work : it seems that the wi-fi driver waits until the startup batch is fully executed before establishing the wifi connection. Normally, my computer only needs 3 or 4 minutes to complete startup. I even tried delaying the execution by 10 minutes, and it's the same : the wifi connection is established only after 10 minutes. This is not quite what I wanted to do!

Any idea?

8512.

Solve : ERASED HARD DRIVE?

Answer»

I erased by hard drive due to some problems I was having. I have a boot disk and am trying to get my pc to boot windows so I can go in and restore my machine with the restore cds. I do not know what commands to type. Any and all info is greatly appreciated. Thanks.
I am reinstalling win 98se on my sons computer that he uses for his games.Quote

I erased by hard drive due to some problems I was having. I have a boot disk and am trying to get my pc to boot windows so I can go in and restore my machine with the restore cds. I do not know what commands to type. Any and all info is greatly appreciated. Thanks.
I am reinstalling win 98se on my sons computer that he uses for his games.

By "boot disk", you mean a boot floppy disk - right? (as opposed to a boot CD disc)

Not sure about "restore" cds. I've always used a generic, full install, Windows98 CD. 'Restore' sort of implies an OEM disc from a computer manufacturer. It might work the same though....

Boot from the floppy.
Assuming it boots all ok, you will be at the command line.
It will LOOK like: A:\>

Put your Windows98 install CD disc in the CD drive.

You need to navigate to that drive at the command line.
The CD drive is most likely either D: drive or E: drive.
(When I boot with my Win98 boot disk, my CD drive becomes E: )

To navigate to it, type the drive letter followed by a COLON, then HIT the enter key. As in: D:
or E:

If you chose a letter that is non-existant - i.e. no drive has that letter - you'll get an error message. No harm done, it is just telling you.

Try D:

If you get no error message, you've successfully changed to the D: drive.
To find out if you are on the CD drive, use the dir command.
Type dir
Look for setup.exe .
If you don't see it, try E: drive.
Again, use the dir command to view the files.

Once you find the setup program, execute it.
Type setup followed by the enter key.
That should launch the beginning of the install for you.

I hope this helps.



Thanks, but I am an idot because i still can not get to work. I have a boot floppy that lets me boot up ms dos. Then I have a HP Recovery CD and a Win 98SE boot cd. I can not get out of dos and get windows to load. Any more info would be greatly appreciated. Thanks. There is no setup in the dir.http://www.bootdisk.com/bootdisk.htm

copy the OEM disk for Windows 98 and than boot your machine from this disk....

It will get you started.
THANK YOU!THANK YOU!THANK YOU!THANK YOU!THANK YOU!THANK YOU!

I APPRECIATE THE INFO IT DID THE TRICK, AND NOW I CAN FINISH SETTING UP MY NETWORK.

THANKS SPOILER.

MARK
8513.

Solve : Math in a batch?

Answer»

I havent been able to figure this out, nor have i been able to find anything about it. I was wondering about doing math in a batch. What operations can be done and how do I use the codes?Math in a batch file is very limited. Here are some examples.

Quote from: gamerx365 on August 14, 2007, 04:59:21 PM

I havent been able to figure this out, nor have i been able to find anything about it. I was wondering about doing math in a batch. What operations can be done and how do I use the codes?

http://www.google.co.uk/search?source=ig&hl=en&q=batch+file+arithmetic&btnG=Google+Search&meta=&aq=t&oq=batch+file+arithm

Jesus, I thought you were the top programmer in your grade.

Quote from: gamerx365 on 10 July 2007, 11:20:14
i hate my school but i wouldnt wreck the computers. I am in 10th grade now and I am the best programmer in the grade. I WANT to keep learning to keep my STATUS and so people can fear (and nerds to respect) my power and gift. Sure my creations are not the best or the most useful, but I have basically only been experimenting. I have created MANY websites and made games as well. You can see what I have done by going to some- http://freewebs.com/cloneshotel piczo.com/sethfilmfest. I do not want to hurt any computer at all. You have got all things wrong. I want to be a software engineer and someday own a software company. I do NOT want to be a nerd sitting at my computer in my underwear and hacking people or sending viruses. So far my topics are based on tricking my friends or trying to defeat my school computer security system because the moron IT department thinks they need to block everything including my harmless sites.

If you were, surely you could simply use Google or type:

Code: [Select]SET /?
In a command prompt...

In a Batch file:
Code: [Select]set /a a=1+2
echo %a%
pause
Or in Command Prompt:
Code: [Select]set /a 1+2
Both will give the answer 3 because 1+2=3

+ = add
- = subtract
* = multiply
/ = divide

I think there is more but those are the ones I know...at least all I can remember....Quote from: DeltaSlaya on August 15, 2007, 01:24:38 AM
Jesus, I thought you were the top programmer in your grade.

Quote from: gamerx365 on 10 July 2007, 11:20:14
i hate my school but i wouldnt wreck the computers. I am in 10th grade now and I am the best programmer in the grade. I want to keep learning to keep my status and so people can fear (and nerds to respect) my power and gift. Sure my creations are not the best or the most useful, but I have basically only been experimenting. I have created many websites and made games as well. You can see what I have done by going to some- http://freewebs.com/cloneshotel piczo.com/sethfilmfest. I do not want to hurt any computer at all. You have got all things wrong. I want to be a software engineer and someday own a software company. I do NOT want to be a nerd sitting at my computer in my underwear and hacking people or sending viruses. So far my topics are based on tricking my friends or trying to defeat my school computer security system because the moron IT department thinks they need to block everything including my harmless sites.

If you were, surely you could simply use Google or type:

Code: [Select]SET /?
In a command prompt...



you are annoying as *censored* bringing all this back and make me feel like a queer. and I am because nobody in my school does stuff like this. and besides, even if I were a great programmer that doesnt mean I know everything. And how were I to know that set /? would tell me anything about math? I did do that to right before reading your post. No math in there. So why dont you shut up.Quote from: gamerx365 on August 15, 2007, 08:14:56 AM
you are annoying as h**l bringing all this back and make me feel like a queer.

I don't normally use language like that, but nobody can make you feel like a q***r unless you already are a q***r.

If you feel that way, Gamer365, maybe it's nature's way of trying to tell you something? I guess they don't do PC in your trailer park?

Quote
So why dont you shut up.

Or manners either.

---- leave me the h**l alone. ur probably the queer one. thats nasty BRO, nasty.Quote from: gamerx365 on August 15, 2007, 08:21:23 AM
---- leave me the h**l alone. ur probably the queer one. thats nasty bro, nasty.

Maybe you should find a forum where people like you are welcome? (Ie not this one)

This has degenerated into non-productive banter.
Topic Closed.Hmm, I see gamerx365 still isn't making any friends...Oh great. I leave for a couple of months and we have turned into this?
8514.

Solve : starting second batch from 1st not working...?

Answer»

hello everyone,

I'm still plugging away in batchland, and am confused about another issue. I realized that the reason I couldn't get a folder to delete at the end of my batch file was because the folder is the one that contains the batch...and the machine isn't going to allow me to delete a folder it is currently USING...

therefore, my idea was to make a second batch file that is accessed from a different directory. I read about the 'call' command, but that seemed like it would access another batch but return to the first, so that wouldn't really help me.

I also read that you could execute a batch from a batch by just putting in the path and name of the second batch. Using this method, I am getting the "the process cannot access the file because it is being used by another process" error.

So, I guess the first batch has not "ended" in the eyes of the machine. I can understand that, I suppose, as it doesn't get to SEE any "exit" command in the first batch file. I've got one in there, of course, but it's after the call to the second batch. I've even tried having the second batch file and folder pre-exist on my harddrive, but still get the error.

any ideas? Thanks in advance for any assistance.
is this what you WANT?

Code: [Select]:: %folder% should be the name of the folder you are deleting

cd..
echo ping -w 1 1.1.1.1>>secondbatch.bat
echo del %folder%>>secondbatch.bat
start secondbatch.bat
exit

thanks for the response! I appreciate it.

I HATE to show my ignorance, but I'm not sure if that's what I want, lol. I am pretty basic in my dos understanding and don't really understand what the ping part of the code or the ">>" means.

Sorry

Would that work for a situation where i've got an exe that creats a temp folder and then extracts a local website (OFFLINE content) as well as a shortcut to the site, and the batch into it? After extraction, the batch runs.

The batch moves the offline website folder to the root of c, and then moves the shortcut to the site to the desktop. The last thing I need to happen is to delete the tmp folder that the stuff originally extracted to.

As i said in my earlier post, I couldn't get the tmp folder to delete and i figured it was because the batch is running from the same folder, so I created the 2nd batch which exists solely to delete the temp folder.

again, I appreciate the response and apologize for my ignorance.what the code does is it can be added into your first batch that inside of the folder and it will make a second batch outside of the folder, close the first one and delete the folder. The ping will make it wait to make sure that the first batch is closed before the second one deletes it.thank you for the explanation!

I will give this a try.

8515.

Solve : cannot format disk?

Answer»

while booting up i get the following messages:
Save to disk partition not found
Save to disk feature disabled

i cannot do a scandisk or a format. i have installed a physicaly different HD and
still get the same message but it will boot to windows in the 2nd HD.
I can't do anything with the 1st HD. i run a fdisk and it sees the HD but thats all its a toughbook cf-27 :-?GaryWhat type of backup software did this machine ship with ? ?

Did you re-install the ORIGINAL software when you replaced HDD's ? ?there was no softwear in it.If i'm not mistaken a toughbook is a notebook/laptop machine...i can't remember the last one i saw that shipped without software installed.this drive is not the one that CAME with it. i purchased it used without a drive, but it's not any different that any other laptop and should run with a blank HD. this seems to be a bios or boot errorA laptop especially will need at least an OS and drivers installed for it to run...Disk may never have had a low level format. You can read about it here and decide if this may help you.

Good luck. 8-)Quote

this drive is not the one that came with it. i purchased it used without a drive, but it's not any different that any other laptop[highlight] and should run with a blank HD[/highlight]. this seems to be a bios or boot error


Huh?i GUESS i'm wrong. it will boot and GIVE me an a prompt, anywayGood. You're 1/2 way there...what OS do you plan on installing on this machine ? ?i plan on copying my desktop with ghost. it has xp in it. will that work?Nope.how about i purchase a new HD this one is only 4GB anyway?It doesn't matter which HDD you try this on...you cannot simply copy an operating system from one machine to another and expect it to run...aside from the drivers all being different there are legal ISSUES as well.

You need to purchase a Windows OS and go from there or explore the World of Linux free distros...

patio. 8-)
8516.

Solve : Changing IP on a new processor.?

Answer»

I work on light rail trains and they have an intranet system for the signs, pa etc. Part of the IP address is the actual train number. If we swap out the passenger information processor, we MUST update the IP to match the train number. We had a train wrecked and was being worked on for weeks and it got parts taken. It's number is 116 and the one off the shelf is for 205 so needs to be changed to 116. Can anybody help?
The TOUGHBOOK laptops we use have XP PRO with IE and dos shell.
Thanks Bunches,
DonnyIf you need to change your IP address in windows XP follow this guide: http://www.hotcomm.com/FAQ/FAQ_staticIPXP.asp.

Basically, you need to get in to your local connection's properties window. Select 'Internet Protocol TCP/IP', select properties and then check the 'Use the Following IP address' RADIO button. You can fill in other values such as gateway or subnet by typing 'ipconfig /all' in a COMMAND prompt window before these steps. This is all covered in that link. Subnet is usually 255.255.255.0 and the gateway, if you use a router COULD be 192.168.0.1 or 192.168.1.1.THANK YOU SOOOO MUCH!
The city of Denver Colorado and I are grateful
DonnyboyI'll give you my bank no. and you can wire me some moolah lol.

No just jokes, I'm happy with doing peoples paying jobs for them, free of charge..

8517.

Solve : batch file to run an application through all files in a folder?

Answer» HI,

I am starting my first batch file and I am stuck with the for loop. I am trying to write a batch file to run an audio application that does some statistical analysis through all wave FILES in a folder . I have the syntax of FOR loop but I am not ABLE to figure out how to run an executable through all files in a folder.. Can somebody please help me out ...

Thanksfor %a in (*.*) do MyApplicationName %a

if you do this in a batch file, you need to double-up the % symbols, thus:
for %%a in (*.*) do MyApplicationName %%a

Graham
Yes or:

Quote
@echo off
cd FOLDER NAME HERE ! !
for /F "usebackq delims=" %%I in ("*.wav") do APPNAME other app commands... %%~nxI

That will only work of course if the executable supports being passed a file like that.

I used "" incase the filenames have spaces, I THINK that is required?
8518.

Solve : stopping a process?

Answer»

hey all,

does anyone know the command to stop processes???

services i can do but i require stopping winword via ods.

any ideas??

cheers in advanceYou need to understand TASKLIST and TASKKILL.

Quote


C:\>tasklist

Image Name PID SESSION Name Session# Mem Usage
========================= ====== ================ ======== ============
System Idle Process 0 Console 0 16 K
System 4 Console 0 228 K
smss.exe 336 Console 0 372 K
csrss.exe 384 Console 0 6,272 K
winlogon.exe 408 Console 0 4,216 K
services.exe 452 Console 0 4,092 K
lsass.exe 464 Console 0 1,184 K
svchost.exe 628 Console 0 4,712 K
svchost.exe 676 Console 0 4,448 K
svchost.exe 720 Console 0 16,028 K
svchost.exe 856 Console 0 3,240 K
spoolsv.exe 920 Console 0 5,188 K
svchost.exe 1000 Console 0 4,320 K
avgamsvr.exe 1032 Console 0 292 K
avgupsvc.exe 1056 Console 0 588 K
MemeoService.exe 1100 Console 0 26,056 K
locator.exe 1220 Console 0 2,568 K
wdfmgr.exe 1252 Console 0 1,684 K
Fast.exe 1444 Console 0 1,736 K
PDSched.exe 1496 Console 0 3,912 K
alg.exe 1664 Console 0 3,436 K
wscntfy.exe 1240 Console 0 2,088 K
explorer.exe 1352 Console 0 8,148 K
PSTrayFactory.exe 1704 Console 0 4,220 K
TaskSwitch.exe 1712 Console 0 1,848 K
StartupMonitor.exe 1488 Console 0 140 K
Fast.exe 1588 Console 0 2,348 K
StxMenuMgr.exe 904 Console 0 4,904 K
TC.exe 1732 Console 0 4,072 K
Bandwidth Monitor Pro.exe 604 Console 0 2,968 K
ctfmon.exe 1756 Console 0 3,760 K
ClockTraySkins.exe 648 Console 0 3,964 K
speedfan.exe 1880 Console 0 5,908 K
taskmgr.exe 1560 Console 0 4,784 K
ExtraDNS.dll 2020 Console 0 24,812 K
MemeoBackup.exe 288 Console 0 25,244 K
Azureus.exe 1888 Console 0 54,612 K
firefox.exe 2964 Console 0 43,080 K
NOPDB.EXE 3944 Console 0 3,660 K
IEXPLORE.EXE 3256 Console 0 3,088 K
IEXPLORE.EXE 2700 Console 0 15,036 K
explorer.exe 3124 Console 0 4,080 K
wmiprvse.exe 2752 Console 0 5,952 K
WINWORD.EXE 2828 Console 0 11,288 K
agentsvr.exe 2732 Console 0 1,764 K
cmd.exe 2880 Console 0 1,476 K
cmd.exe 840 Console 0 2,628 K
tasklist.exe 3068 Console 0 4,476 K



Quote

C:\>taskkill /F /IM WINWORD.EXE
SUCCESS: The process "WINWORD.EXE" with PID 2828 has been terminated.

type taskkill /? and tasklist /? at the prompt for full details


You could also hit and hold down "control, alt, delete" in that order. You will see the Windows Task Manager. Click on the tab "Processes," select the process that you wish to stop, and click the button "End Process" at the bottom right of the window.Quote from: smlh89450 on August 27, 2007, 08:32:00 AM
You could also hit and hold down "control, alt, delete" in that order.

Very good, except he SPECIFICALLY asked for a command line method.

Have you found your shutdown.exe yet?
8519.

Solve : FOR /F in DOS 7.10?

Answer»

I have a hard drive setup which is divided into 3 partitions.
The first is NTFS and has windows XP,
the second is NTFS and has got all the data saved on it,
the THIRD is a small FAT32 partition stored at the end which has DOS7.10 installed

I USE a boot loader to set the first partition active if I want to boot xp or set the third partition active if I want to boot into DOS7.10. The DOS7.10 has got full NTFS support through an app called NTFS4DOS.EXE which automatically loads on the autoexec.bat

I have GHOST.exe sitting on the 2nd partition which shows up as D: so I use a batch file called alive.bat which makes allows me to ghost image my windows partition very simply.

The only problem is that alive.bat is too simple and I want it to be a bit more powerful and be able to scan my ghost images folder so I can then simply press a button and load the all the *.gho files in my ghost images folder. The only thing is though DOS7.10 is not powerful? and I don't think it can even support the FOR /F command or even (more than 1 line enclosed in brackets).

I unfortunately don't even know where to get FOR.exe ? for dos. Maybe its impossible to scan files and create pseudo arrays in DOS 7.10, but I am hoping that some intellectual person will be able to help on this issue!!

The scripts are below for you to see what I mean

Thanks for your time!

Alive.bat (works fine in DOS7.10)
Code: [Select]@echo off
cls
echo --------== Alive.bat - Ghosting Options ==--------
echo .
echo Press a number to choose your option
echo .
echo .
echo 1 - Ressurection (Restore Windows to original Image)
echo 2 - Norton Ghost (Work in Norton Ghost)
echo 3 - DOS Prompt
echo .
echo .

choice /c:123

if errorlevel 3 goto THREE
if errorlevel 2 goto TWO
if errorlevel 1 goto ONE

:ONE
ghost.exe @c:\restore.txt
goto end

:TWO
d:
cd image\ghost
call c:\ghost.exe
c:
goto end

:THREE
goto end

:END

NPGS.bat (Concept script file works in windows XP, not in DOS7.10) and I want this to work in DOS7.10!!!!!!
Code: [Select]@echo on
setlocal enabledelayedexpansion

set windrive=e:
set ghostdrive=d:
set ghostdir=Image\Ghost
set ghostexe=c:\tools\ghost.exe

cls
echo --------== Nathan Ghost System - Ghosting Options ==--------
echo.
echo Press a number to choose your option
echo.
echo.
echo 1 - Restore Image (Restore a Ghost Image)
echo 2 - Update Image (Update existing Ghost Image)
echo 3 - Norton Ghost (Work in Norton Ghost)
echo 4 - DOS Prompt
echo.
echo.

choice /c:1234
if errorlevel 4 (
goto :END
)
if errorlevel 3 (
set JUMP=MANUAL
goto :PREGHOST
)
if errorlevel 2 (
set jump=AUTO
set option=Update
goto :PREGHOST
)
if errorlevel 1 (
set jump=AUTO
set option=Restore
goto :PREGHOST
)

:PREGHOST
REM Deletes unneccesary system files and runs a scandisk/chkdsk
%windrive%
cd\
if exist pagefile.sys (
attrib -r -a -s -h pagefile.sys
del pagefile.sys
)
if exist hiberfil.sys(
attrib -r -a -s -h hiberfil.sys
del hiberfil.sys
)
deltree /y temp
scandisk /all /autofix /nosave /nosummary
del scandisk.log
CHKDSKG.EXE

%ghostdrive%
cd\
cd "%ghostdir%"

goto :%jump%

:AUTO
REM Scans the folder for *.gho files and creates a pseduo-array
set count=0
for /f "tokens=*" %%g in ('dir /b "*.gho"') do (
set ghost=%%~g
set /a count+=1
set _ghost/!ghost!=!count!
)

:menu/top
REM Creates a menu to choose which file you want to load
call :menu/dis
set _filechoice=
echo.
set /p "_filechoice=Choose a number: "
call :menu/chk
if not defined ghostfile goto :menu/top
goto :LOADGHOSTFILE
:menu/dis
echo --------== Nathan Ghost System - Ghosting Options ==--------
echo.
echo Please select a Ghost file to %option%
echo.
:menu/chk

set ghostfile=
for /f "tokens=2* delims=/=" %%a in ('set _ghost/') do (
if /i "%0" EQU ":menu/dis" echo:^(%%~b^) %%~a
if /i "%0" EQU ":menu/chk" (
if /i "%_filechoice%" EQU "%%~b" (
set ghostfile=%%a
)
)
)
goto :EOF


:LOADGHOSTFILE
REM Loads the specified ghost image file
echo.
if "%option%" EQU "Restore" goto :RESTOREIMAGE
if "%option%" EQU "Update" goto :UPDATEIMAGE

:RESTOREIMAGE
echo Warning: You are about to overwrite windows system partition with ghost image file %ghostfile%
echo Please make sure you have backed up all important data on the windows partition to an alternative location before continuing this operation
pause
%ghostexe% -clone,MODE=pload,SRC=%ghostdrive%\%ghostdir%\%ghostfile%:1,DST=1:1,-rb

goto :END

:UPDATEIMAGE
echo Warning: You are about to overwrite ghost image file %ghostfile%.
echo Please ensure you are creating a clean image and have run a virus-scan & spyware scan before continuing this operation
pause
%ghostexe% -dump,MODE=pload,SRC=%ghostdrive%\%ghostdir%\%ghostfile%:1,DST=1:1,-rb
goto :END


:MANUAL
%ghostexe%
goto :END


:END
As Todd Vargo told you in alt.msdos.batch, "the whole idea
of creating a dynamic menu of .gho image files is basically reinventing the
wheel. Ghost already provides its own menu system for selecting from
existing image files."

8520.

Solve : Help with getting batch to a txt file?

Answer»

Hi I want to use a batch script to copy my IP address and SAVE it in a txt file. Is there anyway I could do that through dos? It would really help if somebody could help me. Thank you.Easy here ya go !

Code: [Select]ipconfig>> ipaddress.txtOh my gosh thank you so much you are a life saver! Your welcome, ALWAYS happy to help. But may I ask why you needed that, just asking?

8-)fffreakjust GET IP addresses
Code: [Select]@echo off
::
:: get all IP addresses and assign to IPaddr1, IPaddr2, etc.
::
SET CTR=0
for /f "tokens=2 delims=:" %%a in (
'ipconfig ^|find "IP Address"'
) do call :saveIP %%a
for /l %%a in (1,1,%ctr%) do call :showIP %%a
goto :EOF

:showIP
call :exec echo IP Address %1 is %%IPaddr%1%%%
goto :EOF

:saveIP
set /a ctr+=1
set IPaddr%ctr%=%1
goto :EOF
:exec
%*
goto :EOF
EOF

8521.

Solve : Capture the file name as a parameter?

Answer»

Thanks
but would you mind explain the logic to me ?
SURE, no problem.

Quote

:: This line turns echo off, which means only the output of commands is displayed.
@echo off

:: As below
for /f "usebackq delims=" %%I in (`dir/b c:\*.txt`) do (
set name=%%~nI
)

:: Sets the variable %m% to the fifth and SIXTH characters in %name%, offset 4 is same as 5th character, 2 after that inclusive.
set m=%name:~4,2%

:: Echos the %m% variable
echo %m%

pause


FOR STATEMENT DESCRIPTION:
For /f "usebackq delims=" means that for will use backwards quotes, just a habit ` instead of '.

The delims part means that the output should be treated a a whole phrase and not split into sections when a character is reached, not really necessary either.

"%%I" defines a temporary variable to use in the for statement body.

"in (`dir/b c:\a\*.txt`) do" For each line that the command "dir/b c:\*.txt" returns the following will be performed.

"(" indicates start of body.

"set name=%%~nI" Sets the variable %name% with the file name only (~N) in the variable %%I, ie no extension.

")" END body



NOTE: You didn't mention the file was in a folder called "a".
8522.

Solve : Simple batch file?

Answer»

I am a REAL newbie to all this so forgive me if my question is very basic.
I have a folder NAMED "Fun & Games". How do I write this so that it will be recognized by DOS. I tried "fun&ga~1' but it doesn't work. Also what is the switch I must use so the my command will execute automatically (without having to indicate Yes or No?) What is your OS?

Windows XP-command.com
Code: [Select]cd Fun&Ga~1
Windows XP-cmd.exe
Code: [Select]cd Fun & Games
8-)fffreakIf you type

dir /x

then you will get the listing of the folder alongwith their respective DOS names.
MSDOS version 6 lets you type in their actual name with spaces as WELL, so you can do it either WAYS.

8523.

Solve : Weird Batch File Behaviour.?

Answer»

Ok, this is an extract of some code I have been writing. It's purpose is to check if there are characters ENTERED, ie not blank or any number of spaces. I tried using `findstr /r "[^a-z,0-9]"` for characters and using || if no characters were found but I couldn't get it to work. Anyway, this really has me CONFUSED...

Quote

@echo off

SET /a c=1

:1
rem Below line shows status of echo.
echo
echo LOOP: %c%
set string=
set /p string=

echo %string% | findstr /I /c:"ECHO is on." >nul && echo ECHO IS ON WAS FOUND
rem BELOW LINE FOR COMPARISON, NOT IN MY CODE
echo %string% | findstr /I /c:"ECHO is off." >nul && echo ECHO IS OFF WAS FOUND

pause >nul
echo.

set /a c+=1

goto 1

Now as you can see, the echoed string variable, (which if blank or spaces should return "ECHO is off."), is piped to the findstr command. Which with case-insensitivity and searching for the phrase "ECHO is on." (Does not work with off). Now you'd assume that entering no or only blank characters would make this return nothing, as the string "ECHO is off." should have been found as 'echo' is the same as 'echo '.

Quote
ECHO is off.
LOOP: 1
STRING=test

ECHO is off.
LOOP: 2
STRING=next line blank ""

ECHO is off.
LOOP: 3
STRING=
ECHO IS ON WAS FOUND

ECHO is off.
LOOP: 4
STRING=next line spaces " "

ECHO is off.
LOOP: 5
STRING=
ECHO IS ON WAS FOUND

Of course if you type "ECHO is on." as the input it is found. Though why is findstr finding echo is on, on blank entries when echo is clearly off?
8524.

Solve : Help with batch file - reg query and errorlevel?

Answer»

Hello,

I am trying to have this batch file check the presence of registry entries. I do not want it to print anything to the screen. If the value is present I want it to print to a text file.

reg query hkcu\software\sample
if errorlevel=0 echo "hkcu\software\sample">>list.txt

That is what I have so far.

Any advice would be greatly appreciated.If all you want in your output file is "hkcu\software\sample" then you're all SET and you don't EVEN need the reg utility!

I suspect you want the result of the query in your output file:

Code: [Select]reg query "hkcu\software\sample" >> list.txt

Hope this helps. 8-)

Not even sure the reg utility assigns errorlevels.

I do not want the results printed. errorlevel 0 MEANS that it FOUND the reg key and errorlevel 1 means the key is missing. It the key exists, I want the name of the key printed in the text file.

Right now what I listed gives me what I want but TOO MUCH - is there a way I can have the result of the query not printed to the screen or a file but still ACCESS the errorlevel? The results of the query are printed to the screen but that clutters the screen.Code: [Select]reg query hkcu\software\sample > nul
if errorlevel 0 echo "hkcu\software\sample">>list.txt

8-)YES that works!!! I knew I was missing something small.

Thanks!!!!!!!!!

8525.

Solve : Capture a part of the file name, how can i do it ??

Answer»

eg . I have a file call "200907.txt" , I need to CAPTURE a part of the file NAME "07" to the other file.
How can I do it??

Many Many Thanks~dont understand what ur askingit has a file call '200907.txt'. then i want only capture the 5th and 6th letter (07) of thr file name as parameter ? How can i capture it ?
Really thanks TYPE set /? on your command prompt, read on and you will find the solution..
thanks for your reply
but i require to capture the part of the file name as a VARIABLE.
such as a file name call 200708.txt and i only need the 5th and the 6th letter

but anyway thanks a lot i have already told you where to look...just takes a few minutes to read through set /?
QUOTE

...
The /P switch allows you to set the value of a variable to a line of input
entered by the user. Displays the specified promptString before reading
the line of input. The promptString can be empty.
.....
.....
....

May also specify substrings for an expansion.

%PATH:~10,5%
.......
Yes, cityjack, ghostdog74 already told you where to look.

8526.

Solve : ad 7 days to a current date?

Answer»

Does anyone know how to do, under winxp, add 7 days to a current date. For example:
Code: [Select]>>c:/windows/WHsced.bat ECHO AT 20:30 /EVERY:[b]10[/b],31 c:/windows/WHmain.batI'd like that the 10 (see bald) in the code would be replaced by a week later then the current date. For example, now DOS would look the date, in my country we're the 2nd of the month on the MOMENT of writing, so then DOS would say:

Code: [Select]>>c:/windows/WHsced.bat ECHO AT 20:30 /EVERY:[b]9[/b],31 c:/windows/WHmain.bat
Because 2+7=9


And if we are the tirth tomorrow, etc

Does anyone has an idea?Quote


Does anyone know how to do, under winxp,

- - -

Does anyone has an idea?


Since I don't have XP, I can't experiment with its scripting. So I can't tell you how to do it with only the COMMAND line of XP.

You'll probably get an answer here soon from someone that can. I've seen a few members post here that appear to be very good with it.

If however you don't get an answer soon, let me know. I can do it, under XP, but using a FREE utility program to manipulate the date, do the MATH, and set an environment variable(s), that you can then do with whatever you want. The method and batch files should work under XP just the same as they do under 98, etc.



blackberry,

Try this:
[edit]@echo off
CALL:jdate jd "%date%"
SET /a jd+=10
CALL:jdate2date jd y m d
echo.file.%m%/%d%/%y%
pause
GOTO:EOF

:jdate
...
:jdate2date
...[/edit]

Get the :jdate function from here http://www.dostips.com/DtCodeCmdLib.php#jdate
Get the :jdate2date function from here http://www.dostips.com/DtCodeCmdLib.php#jdate2date

DOS IT HELP?
8527.

Solve : Set parameter?

Answer»

I would like to set a parameter into a bath FILE
the case is :
i NEED capture the username and password and then ECHO those INFORMATION into a TXT file. It is because different user has different password and username, so it should be a variable.
but how can i input the username and password ?

Thanksim not sure if this is what ur asking but here it goes:

Code: [Select]@echo off
set /p username=Username :
set /p password=Password :
echo Username : %username%>>file.txt
echo Password : %password%>>file.txt
Is it means that i can input the username and password each time i run this batch file ?
Thanks yesI already try those command, these is exactly what i wanted, really really thz

8528.

Solve : File size limit !??

Answer»

Hello

I'm managed to finalize a batch file that checks the filesize of a database and when it reaches more than 4 GB the batch program moves the database elsewhere. (I'm doing this periodic check with Windows Scheduler)

This is my code:
---------------------------------------
@echo off
for %%a in (dir "c:\Data\database.mdf") do if %%~za GEQ 4000000000 start /max move.bat else exit

--------------------------------------

THE PROBLEM:
Instead of moving the database when it reaches 4GB or more the program moves it when database has only 2GB or 2.1, 2.2GB.
I don't know why. I tried also with GTR instead of GEQ and also I changed the 4GB limit to 3.9GB(3900000000) but no change. I've got no CLUE why is doing this.
Oh ... and I checked also to have a NTFS partition and I have it.

Anybody know what I'm doing wrong? Is there a limitation in DOS for reading 4GB?
How can I solve this. It's a very INTERESTING program that I'm developing, I will provide it to you when it's fully opperational.

Thank you in advance
NT batch arithmetic has maximum precision of 32 bits, so the greatest number it can hold is + or - 2,147,483,648. That number of bytes is 2 gigabytes. The condition in your IF test is "satisfied" because of arithmetic overflow. You will have to think of another solution using a different programming language.

PS It's not "DOS".



Thank you "contrex"

Is there a way to get file size in SQL and start a program when it has 4GB?

Can I do something like this (a trick)

@echo off
for %%a in (dir "c:\Data\database.mdf") do if %%~za ***** GEQ 4000000000 start /max move.bat else exit

instead of ***** ... can I divide that value like %%za / 1024[size in kB] and then compare GEQ 3906250kb ?

Is that posible? ... I don't know with command is for that (i read about SET)
Anybody knows how to solve this problem in any way?

Thank you!You cannot do that because the very act of trying to perform the arithmetic operation (%%~za / 1024) will cause overflow if %%za EVALUATES to more than 2 147 483 648.
What you could do is divide by 1000, by stripping off the right-hand 3 digits using string manipulation, then do your numerical calculation on the result

GrahamContrex, you're so leet...

Quote

contrex
Leet
******
Online Online

Posts: leet


View Profile
Quote from: DeltaSlaya on August 13, 2007, 03:03:23 AM
Contrex, you're so leet...

[edit] Duh - I see now! What happened to "mentor"

Anyway, it's 2337 anyway, not ell ee ee tee. (I mean, come on GUYS!)




Yea lol your rank is literally 'leet' and your post count was too. Not your advice lol. I wasn't aware you could do logical comparisons like that in strings.I have seen both "1" and "2" used for "L" in 1337 speak... which to use maybe I should start a thread.

As for the strings I found a mistake, it doesn't work properly.

Thank you "contrex"

The code was very helpfull ... I developed a sql statement that does the same thing like your code and I put them to test ... in a couple of days I will see the results.

Thank you very much

PS : What means "leet" ... it comes from "elitte"? I didn't understand last 3-4 posts
Quote from: victor.marincus on August 13, 2007, 04:00:06 AM
PS : What means "leet" ... it comes from "elitte"?

yeah.
http://en.wikipedia.org/wiki/LeetHere's one way to do the number-as-string thing

Quote


@echo off
setlocal enabledelayedexpansion

Set /P filesize=Filesize? %

set sizelimit=4000000000

set v1=%filesize%
set v2=%sizelimit%

REM find string lengths
REM echo string to temp file
REM escape 1st char with a caret in case it's a 1 or 2
REM which mucks up echo redirection, then
REM read file bytes & subtract 2 for CR & LF

echo ^%v1%> "%temp%\v1.txt" & for %%A in (%temp%\v1.txt) do set len1=%%~zA & set /a len1 -=2
echo ^%v2%> "%temp%\v2.txt" & for %%A in (%temp%\v2.txt) do set len2=%%~zA & set /a len2 -=2

REM compare string lengths and if they differ,
REM add leading zeroes to the shorter one
REM until it equals the other in length

if %len1% GTR %len2% (
set ss=%v2%
set /a padlen=%len1% & set /a padlen-=%len2%
FOR /L %%z IN (1,1,%padlen%) DO set ss=0!ss!
set v2=%ss% & goto end
)

if %len1% EQU %len2% goto end

if %len1% LSS %len2% (
set ss=%v1%
set /a padlen=%len2% & set /a padlen-=%len1%
FOR /L %%z IN (1,1,%padlen%) DO set ss=0!ss!
set v1=%ss% & goto end
)

:end

REM do string comparison

if "%v1%" GEQ "%v2%" echo %filesize% is ^>= limit
if "%v1%" LSS "%v2%" echo %filesize% is ^< limit
Thank you contrex for the code ... I made few adjustments hope others need this ...

@echo off
setlocal enabledelayedexpansion
for %%a in (dir "c:\Data\Data.mdf") do set filesize=%%~za

set sizelimit=4000000000

set v1=%filesize%
set v2=%sizelimit%

REM find string lengths
REM echo string to temp file
REM escape 1st char with a caret in case it's a 1 or 2
REM which mucks up echo redirection, then
REM read file bytes & subtract 2 for CR & LF

echo ^%v1%> "%temp%\v1.txt" & for %%A in (%temp%\v1.txt) do set len1=%%~zA & set /a len1 -=2
echo ^%v2%> "%temp%\v2.txt" & for %%A in (%temp%\v2.txt) do set len2=%%~zA & set /a len2 -=2

REM compare string lengths and if they differ,
REM add leading zeroes to the shorter one
REM until it equals the other in length

if %len1% GTR %len2% (
set ss=%v2%
set /a padlen=%len1% & set /a padlen-=%len2%
FOR /L %%z IN (1,1,%padlen%) DO set ss=0!ss!
set v2=%ss% & goto end
)

if %len1% EQU %len2% goto end

if %len1% LSS %len2% (
set ss=%v1%
set /a padlen=%len2% & set /a padlen-=%len1%
FOR /L %%z IN (1,1,%padlen%) DO set ss=0!ss!
set v1=%ss% & goto end
)
:end

REM do string comparison

if "%v1%" GEQ "%v2%" (
echo %filesize% is ^>= limit %sizelimit%
start /max backup.bat
)

if "%v1%" LSS "%v2%" (
echo %filesize% is ^< limit %sizelimit%
exit
)
-------------------------------
Make sure, in line 3 ---for %%a in (dir "c:\Data\Data.mdf") do set filesize=%%~za---
NOT TO leave any spaces after ---=%%~za--- it will ruin the test. It took me a wile to figure it out. I forgot one space after and the comparison was always wrong(4Gb v.s. 40G in length). Now it's working well. Be carefull not to make mistakes like me.

Thank you again contrex, you are the best...

P.S. SQL sucks ... never managed to run a batch file from within .sql script file.

8529.

Solve : *Solved* (CD Rules) Changing the file type of files in subfolders?

Answer»

Quote from: Dusty on August 26, 2007, 05:18:11 PM

A reason I have all .BAT files in one folder and have that folder in my Path is so that I can Call the files from anywhere in my file system. But that's just the way I prefer to do it, whether it's the most efficient method or would have the approval of the scripting gurus is open to argument

Well, it's what I do as well (always have). I have a folder called c:\BATCH which is on my PATH and it has existed since my MS-DOS 3.30 days back in the early 1990s, I have copied it from computer to computer. The oldest file is dated 3rd March 1993.



Quote from: DeltaSlaya on August 26, 2007, 02:47:26 AM
Using batch in this way to hide files is just stupid. If you really must hide the files then here is a batch that may help:

http://www.lytebyte.com/2007/06/25/how-to-lock-and-hide-folders-in-windows-without-additional-software/

Quote from: NDog on August 26, 2007, 05:21:39 AM
I just love it how people say don't do that its stupid, just do something else. It never fails to amaze me. Anyway I see you are writing a batch file because its fun and something you can be proud of thats why you call it a pet project which is just that.

Sorry for any confusion, I don't mean to start a flame war here. I was not meaning to imply that the OPS desire to USE a batch script to perform this task was stupid. I meant that the methods they were employing to do so are not necessarily the most practical or effective.

The LINK I suggested was simply to showcase other methods that could be used. They could try and figure out how that works, it's a far more effective method of achieving the task at hand. Feel free to use your own methods if you deem them more appropriate, or would like to experiment. It's always YOUR choice, not ours.
8530.

Solve : Another question =) About viewing text files from batch?

Answer»

In my batch program I want to be able to view a text file. Is there a way to do that besides edit? (I want to view the file inside the batch file while its RUNNING)Code: [Select]type /?
Code: [Select]type "filename"
If you want to read it screen by screen try:

Code: [Select]type "filename" | moreThanks! Type is the last command I would've looked at for this lol. using this code, can I make a batch that creates setup.inf and it will set variables in it, and then use type to read them. I want like this:

Code: [Select]@echo off
echo set a=The Letter A>Text.inf
type Text.inf
echo %a%
pause
I want it to make the external variables in the .inf file and then read themwhy don't you try it and see?
yeah i did try it and it didnt workCould you explain a bit more clearly what it is that you want to do. As FAR as I can see, this is what you have...

1. You made a batch that creates a file called Text.inf.

This file, Text.inf, contains a line:

set a=The Letter A

2. You TYPE the file. That is, you get the file listed on screen. So far so good.

3. What are you expecting to happen? Are you expecting the variable %a% to be set to some value? Would that value be a string, "The Letter A"? Why do you think showing the file on screen will set the variable?





Well if I think I know what he's trying to do it can be achieved like this:

Quote


@echo off

::write something to file
>"testfile.txt" echo testvar

::set var to contents of text file
set /p var=&LT;"testfile.txt"

::echo output of new var
echo %var%
pause
yeah its like this but i need to be able to make more than one variable in the testfileQuote from: gamerx365 on August 22, 2007, 07:17:57 AM
yeah its like this but i need to be able to make more than one variable in the testfile

type FOR /? at the prompt, and surf through all the many many posts on this forum about processing text files.

[sarcasm]
Or did you want a batch file written for you?
[/sarcasm]

YEA use for and a couple of temporary variables, I'll give you a hint, but I'm not WRITING this it's easy enough to do what contrex said and figure it out yourself:

Quote

... do (set %%A=%%B)

8531.

Solve : Find and Replace certain text in a REG File..????

Answer»

is there anyway to find CERTAIN text in a reg file and then replace all of them with a variable..??

like search for the text %DRIVE% in the file XP.REG and REPLACE all INSTANCES of it with the variable of %SYSTEMDRIVE%

is this possible at all.??No wonder your Tasklist doesn't work, if this is what you get up to!
Quote from: gumbaz on August 29, 2007, 09:36:29 AM

is there anyway to find certain text in a reg file and then replace all of them with a variable..??

like search for the text %DRIVE% in the file XP.REG and REPLACE all instances of it with the variable of %SYSTEMDRIVE%

is this possible at all.??
yes...search the forum for things like "search and replace". Why not LOAD it into Notepad and do the replacing there?

gumbaz, I don't think you should be FOOLING around with your registry. You don't know enough to get out of any trouble you LAND in, and you'll hose your machine. We'll spend from now till Doomsday dealing with your "HELP PLZZZZZZZZZ!!!!!!!!!!" posts.
8532.

Solve : TASKLIST ERROR: Class not registered.???

Answer»

where is the help at..
arnt you GUYS my help.. *censored*...

http://www.google.co.uk/search?source=ig&hl=en&q=xp+repair+install&btnG=Google+Search&meta=


Quote from: gumbaz on August 29, 2007, 08:39:12 AM

where is the help at..
arnt you guys my help.. *censored*...
watch your language. also, we do not have to spoonfeed you every time. you should LEARN how to be more self reliant. As for your problem, i have another QNS to ask, maybe i have missed it or maybe it may sound stupid, but have you updated your virus scanner whatever brand of AV it is?AHH dont get so emo ghostdog74 ... its just letters MAN..
i applicate all your guys help though..
i will probably do a xp repair install soon to see if that fixes it..
yes my AV auto updates every 1 Hr..Quote
its just letters man..

This is part of the problem...if you didn't notice we don't really do txspk her...

It get's old.
8533.

Solve : any way to auto change the " SET DRIVE= " variable in this code?

Answer»

Is there any way to auto change the " SET DRIVE= " VARIABLE in this code to the next DRIVE LETTER in sequential order like: A, B, C, D Ect.. each time the code recycles, and when it reaches Z it starts back at A again..

---------------------------------------------------------------

Code: [Select]:TOP

SET DRIVE=A

DIR /B %DRIVE%:\ && XCOPY %DRIVE%: %systemdrive%\COPIED DRIVES\%DRIVE% /S

PING 127.0.0.1 -n 6
CLS
GOTO TOPANYBODY HELP PLEASE..?? @ECHO OFF
FOR /F "skip=1 tokens=2,1* " %%a in ('wmic os get systemdrive') do echo %%a >>%temp%\a1.txt
FOR /F "tokens=1*" %%a in ('findstr : %temp%\a1.txt') do @set DRIVE=%%a
CLS & DEL /F a1.txt


^ that will work in a batch file nevermind.. heres a quicker way..

@set DRIVE=%cd:~0,1%

that will tell you drive letter onlyOK, SO HOW SHOULD THE CODE BE WRITTEN NOW..??
LIKE THIS:

Code: [Select]:TOP
SET DRIVE=A
@set DRIVE=%cd:~0,1%

DIR /B %DRIVE%:\ && XCOPY %DRIVE%: %systemdrive%\COPIED" "DRIVES\%DRIVE% /S

PING 127.0.0.1 -n 6
CLS
GOTO TOP
dont you mean "& XCOPY" not && .. you could also USE @set drive=%systemdrive:~0,1%
DIR /B %DRIVE%:\ && XCOPY %DRIVE%: %systemdrive%\COPIED" "DRIVES\%DRIVE% /S --> WORKS FOR ME..

SORRY BUT @set DRIVE=%cd:~0,1% IS NOT WORKING FOR ME IT JUST KEEPS SETTING THE DRIVE AS C:\

DO I HAVE THE BATCH SCRIPT WRITTEN WRONG OR SOMETHING..??

WHAT IS @set DRIVE=%cd:~0,1% SUPPOSE TO DO ANYWAY..??sorry i dident understand at first..

you want to copy all files off a bunch of drives with the variable changing automatically to avoid more code?









YUPPERS... :TOP
@echo off
:A01
ECHO A >>%temp%\tmp.txt
ECHO B >>%temp%\tmp.txt
ECHO C >>%temp%\tmp.txt
ECHO D >>%temp%\tmp.txt
ECHO E >>%temp%\tmp.txt
ECHO F >>%temp%\tmp.txt
ECHO G >>%temp%\tmp.txt
ECHO H >>%temp%\tmp.txt
ECHO I >>%temp%\tmp.txt
ECHO J >>%temp%\tmp.txt
ECHO K >>%temp%\tmp.txt
ECHO L >>%temp%\tmp.txt
ECHO M >>%temp%\tmp.txt
ECHO N >>%temp%\tmp.txt
ECHO O >>%temp%\tmp.txt
ECHO P >>%temp%\tmp.txt
ECHO Q >>%temp%\tmp.txt
ECHO R >>%temp%\tmp.txt
ECHO S >>%temp%\tmp.txt
ECHO T >>%temp%\tmp.txt
ECHO U >>%temp%\tmp.txt
ECHO V >>%temp%\tmp.txt
ECHO W >>%temp%\tmp.txt
ECHO X >>%temp%\tmp.txt
ECHO Z >>%temp%\tmp.txt
GOTO A02

:A02
FOR /F "tokens=1,5*" %%a in (%temp%\tmp.txt) do %%a:
@SET A=%CD:~0,1%
XCOPY %A%: %systemdrive%\COPIED" "DRIVES\%DRIVE% /S
GOTO A02


the above should workQuote from: Diablo416 on August 17, 2007, 01:53:46 PM

:TOP
@echo off
ECHO A >>%temp%\tmp.txt
ECHO B >>%temp%\tmp.txt
ECHO C >>%temp%\tmp.txt
ECHO D >>%temp%\tmp.txt
ECHO E >>%temp%\tmp.txt
ECHO F >>%temp%\tmp.txt
ECHO G >>%temp%\tmp.txt
ECHO H >>%temp%\tmp.txt
ECHO I >>%temp%\tmp.txt
ECHO J >>%temp%\tmp.txt
ECHO K >>%temp%\tmp.txt
ECHO L >>%temp%\tmp.txt
ECHO M >>%temp%\tmp.txt
ECHO N >>%temp%\tmp.txt
ECHO O >>%temp%\tmp.txt
ECHO P >>%temp%\tmp.txt
ECHO Q >>%temp%\tmp.txt
ECHO R >>%temp%\tmp.txt
ECHO S >>%temp%\tmp.txt
ECHO T >>%temp%\tmp.txt
ECHO U >>%temp%\tmp.txt
ECHO V >>%temp%\tmp.txt
ECHO W >>%temp%\tmp.txt
ECHO X >>%temp%\tmp.txt
ECHO Z >>%temp%\tmp.txt
FOR /F "tokens=1,5*" %%a in (%temp%\*censored*.txt) do %%a:
@SET A=%CD:~0,1%
XCOPY %A%: %systemdrive%\COPIED" "DRIVES\%DRIVE% /S

GOTO TOP

the above should work

Why does it need to keep creating the temp file over and over again? It only needs to make it once, and where is '*censored*.txt' coming from?Here I'll take a shot at making ONE.

Quote from: BATCH SCRIPT
@echo off

:start
>"%temp%\letters.txt" echo A
>>"%temp%\letters.txt" echo B
>>"%temp%\letters.txt" echo C
>>"%temp%\letters.txt" echo D
>>"%temp%\letters.txt" echo E
>>"%temp%\letters.txt" echo F
>>"%temp%\letters.txt" echo G
>>"%temp%\letters.txt" echo H
>>"%temp%\letters.txt" echo I
>>"%temp%\letters.txt" echo J
>>"%temp%\letters.txt" echo K
>>"%temp%\letters.txt" echo L
>>"%temp%\letters.txt" echo M
>>"%temp%\letters.txt" echo N
>>"%temp%\letters.txt" echo O
>>"%temp%\letters.txt" echo P
>>"%temp%\letters.txt" echo Q
>>"%temp%\letters.txt" echo R
>>"%temp%\letters.txt" echo S
>>"%temp%\letters.txt" echo T
>>"%temp%\letters.txt" echo U
>>"%temp%\letters.txt" echo V
>>"%temp%\letters.txt" echo W
>>"%temp%\letters.txt" echo X
>>"%temp%\letters.txt" echo Y
>>"%temp%\letters.txt" echo Z

:run
for /f "usebackq delims=" %%I in ("%temp%\letters.txt") do (
XCOPY "%%I:" "%systemdrive%\COPIED DRIVES\%%I" /S

:: Don't know if you want to wait after each drive so i commented it out.
:: ping -n 5 localhost >nul
)

:: Here's another ping before it loops back to the start.
:: ping -n 5 localhost >nul

goto run
my mistake , typos I need to have more code instructions inside the " Do ( ) brackets " ... but i keep getting error syntaxes n stuff...
example code:
Code: [Select]:TOP

>>"%temp%\letters.txt" echo A
>>"%temp%\letters.txt" echo B
>>"%temp%\letters.txt" echo C
>>"%temp%\letters.txt" echo D
>>"%temp%\letters.txt" echo E
>>"%temp%\letters.txt" echo F
>>"%temp%\letters.txt" echo G
>>"%temp%\letters.txt" echo H
>>"%temp%\letters.txt" echo I
>>"%temp%\letters.txt" echo J
>>"%temp%\letters.txt" echo K
>>"%temp%\letters.txt" echo L
>>"%temp%\letters.txt" echo M
>>"%temp%\letters.txt" echo N
>>"%temp%\letters.txt" echo O
>>"%temp%\letters.txt" echo P
>>"%temp%\letters.txt" echo Q
>>"%temp%\letters.txt" echo R
>>"%temp%\letters.txt" echo S
>>"%temp%\letters.txt" echo T
>>"%temp%\letters.txt" echo U
>>"%temp%\letters.txt" echo V
>>"%temp%\letters.txt" echo W
>>"%temp%\letters.txt" echo X
>>"%temp%\letters.txt" echo Y
>>"%temp%\letters.txt" echo Z


for /f "usebackq delims=" %%I in ("%temp%\letters.txt") DO (

DIR /B %%I: && GOTO OPEN-DRIVE

START CALC && GOTO SKIP

:OPEN-DRIVE

START %%I:

:SKIP
)

PING 127.0.0.1 -n 10

GOTO TOP

it doesn't seem to see or use the :OPEN-DRIVE or :SKIP Markers...??
what else could i do so i can use :markers inside the " Do ( ) brackets " ..??Well I don't THINK you can do that in a for statement, you can get out of it but to my knowledge you can't jump AROUND inside it.

And what the *censored* are you trying to do here? Firstly if you're using '&&' there has to be a 'boolean' output, yes / no question sort of thing. I guess you meant & which is the same as a line-return.

What are you trying to check that's true / false and what do you want to happen on each one? It needs to be like this:

Quote
for /f "usebackq delims=" %%I in ("%temp%\letters.txt") DO (
if exist "%%I:\" && (start %%I:) || (start calc)
)

That should check if the letter drive exists (which I assume is what you are trying to do), then if it does it will open it in explorer and if not it will start Calculator.
8534.

Solve : store a file in a variable?

Answer»

I WANT to store a file that has just ONE number in it, in a variable. How can I do that.

This is what I have:

set var = &LT; changelist.txt
echo The variable is "%var%"


if you mean you want to store the number inside it as a variable , TRY this

FOR /F "tokens=1*" %%a in (yourfile.txt) do set var=%%a

^the above works in a batch file

FOR /F "tokens=1*" %a in (yourfile.txt) do set var=%a/b]

^the above works at the line
thank YOUOR,

Quote

set /p var=<"filename.txt"
8535.

Solve : Hiding info in a batch file?

Answer»

Ok, I am trying to make a Batch file to enter my website.

I havent started coding yet but I would like a way to make the username and password not able to be seen.

I am fine with changing the type of file to like exe or com but so far every thing i try changing it to a com it errors.

what do you want to do when you manage to CONTACT your website? do you want to browse it? do some TRANSFERRING of files to your web server?? pls be more detailed.The person i am working with to create my website is the better person to ask, and i will ask him asap.

I believe i am going to be using (i cant remember exactly) it is a .HTACCESS and i want the batch file to enter the password and username and then continue to the SITE, so that they do not see the password.I get what you mean...I THINK...

You need an encrypting/converting software to change .bat to .exe.

As for your question, are you trying to make it so you can see what you type, for example here:

set /p password= :

I don't think it is possible to hide what you type there.Ok thank you.

8536.

Solve : Need batch file to look in correct user folder?

Answer»

Hi! I have a batch file that uses an input file located in the user's Documents and SETTINGS directory (C:\Documents and Settings\username\...file.txt).

How do I get the batch file to look in the correct user's Documents and Settings folder? That is, if person A is logged in, the batch file should look in C:\Documents and Settings\person_a\...file.txt and if person B i logged in it should look in C:\Documents and Settings\person_b\...file.txt etc.

Can anyone help me on this?

Thank you!
/Karenhey
if you use %username% in place of person_A , that will work..

C:\docume~1\%username%\..file.txtA better variable might be "%userprofile%" which displays the current user's PROFILE folder regardless of OS. For example VISTA uses 'Users'.

Quote

C:\&GT;echo %userprofile%
C:\Users\DeltaSlaya

C:\>
Perfect! Thank you both!!
8537.

Solve : Print out value in %1?

Answer»

Hi!

I have a file that STORES a VALUE in %1 and I want to SEE what value that accually GETS stored.

How can I do this?

Thank you,
KarenPerhaps,

Quote

echo %1
8538.

Solve : need help from expert?

Answer»

hey

I have a batch file that at first creates 50 text files with info inside of them,
the next part is it takes a random number.. and sets it into 30 different variables

these variables i use in the for /f skip= , commands .. it works, the idea .. is to take combinations
of these variables.. according to a string, witch is the random number.. or a manual number i enter
and every time it loops it re sets this string to another number.. so the next combination of information is differnt then the beginning..

and then re ECHO them into a new file with the additional information required.. but the problem is
everytime even though i no its re setting the variables, its producing the same information.. and the second problem is it wont loop properly.. it takes about 4 loops to produce the first set of information , and still leaves some out?! i no its not a error in that specific code, what else could be causing this?

this is a long code so ive POSTED the section of it thats giving me the problems here http://odn.t35.com/DOS/highlite.txt

any help is appreciated

From what i see, you are just telling us how you are trying to solve the problem. What exactly are you trying to do.? sorry.. well i play this game thats similar to diablo , ANYWAYS monsters items and stuff like that can be added easily threw the .dat files it has , im just trying to take all the different options for a monster.. and pull them from MULTIPLE textfiles ive created, to create a new file .. so bascially like a generator , im trying to GENERATE 100 random enemys , it saves time..

8539.

Solve : Check if a program exists?

Answer»

Does anyone know how to check if a progress exists witch DOS? I'd like to do the following
if a certain progress doesn't exist, then call a batch file that creates it.

Can anyone help me with the command if a progress exists and an if-not-statement?

I run winxp btw, and I have googled yet but I didn't find anything usefullFirstly, I assume you don't mean DOS, you mean a Batch file that the command line will interpret COMMANDS from.

Secondly, Is there a difference between a program and a progress? How is the program installed? Is it just one file or a directory? How would it be created from just a batch file??

Yes it can be done but you haven't given us much to go on.

Quote


@echo off
set check=file/directory to check exist

if exist "%check%" (goto end) else (
:: Create a file here
>"%check%" echo Make file?
)

:end
echo File exists
pause >nul
exit
Quote from: DeltaSlaya on August 22, 2007, 04:03:55 AM
Firstly, I assume you don't mean DOS, you mean a Batch file that the command line will interpret commands from.

Secondly, Is there a difference between a program and a progress? How is the program installed? Is it just one file or a directory? How would it be created from just a batch file??

Yes it can be done but you haven't given us much to go on.

I mean a batch file, correct.
The programm is installed like a normal program with a lot of files and directories. Afcourse there is a difference between a program and a progress. You have for instance notepad, and you can only check if notepad is LAUNCHED if the process notepad.exe exists. The progress itself wouldn't be created by the batch file, it would just LAUNCH the programm by doing "c:/program.exe".

Thanks for your help so far

OH I see, you mean process...

Yea that's easy ENOUGH:

Quote

@echo off
tasklist | findstr /I /c:"program.exe" || (start "" "program to start" & goto end)
echo Program was running
pause >nul
exit

:end
echo Program Started
pause >nul
exit
How do you get a lists of taskes 'cause tasklist doesn't work here..
Thanks so far for your helpTasklist doesn't do anything at all?

What OS?Quote from: DeltaSlaya on August 22, 2007, 04:22:31 PM
Tasklist doesn't do anything at all?

What OS?

winxp homeAre you sure tasklist doesn't do anything? It should, shouldn't it ? ?

Try the CODE again and tell me the exact output.tasklist doesn't come with XP home. you can download from this site. Here .
you can also use pslist and pskill . Otherwise
here's a vbscript.
Code: [Select]status = 0
Set Processes = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2").ExecQuery("select * from Win32_Process")
For each Process in Processes
If Process.Description = "the_process_you_want_to_check.exe" Then
status=1
End If
Next
If status = 0 Then
Set WshShell = CreateObject("WScript.Shell")
WshShell.Exec("program_2")
End If
8540.

Solve : make batch go to next line?

Answer»

I have a batch file that does a whole lot of file COPYING. Each line is to copy to another server.

I would like to call another batch file and then have my first batch proceed to the next line in the file, with out waiting for the call, to complete. How can I do this...

contents of replicate.bat

call replicate2.bat
robocopy C:\*.* \\server\a
robocopy c:\*.* \\server\b


contents of replicate2.bat

robocopy c:\*.* \\server\c
robocopy c:\*.* \\server\d


Any help would be GREAT.
Use the START command. See START /? for details.

If this is in the first batch file, replicate2.bat will start in a separate window and the first batch will continue without waiting.

start "" "replicate2.bat"

Or you could have these LINES in yet another batch or type them at the prompt

start "" "replicate1.bat"
start "" "replicate2.bat"
start "" "replicate3.bat"

and all 3 would run at the same time independently
awesome, start WORKED great, I guess sometimes its the simplest of things.

Thank you for your help,
GlennQuote from: gbrown on August 26, 2007, 01:50:32 PM

Thank you for your help,
Glenn

Glenn, you are more than welcome! Have a nice day. Don't forget to come back if you have any more questions.


8541.

Solve : batch script?

Answer»

how to hide batch script while RUNNING ?CMDOW

Basically the only commandline thing I know that can fully hide the window, taskbar and all:
cmdow @ /hid - Hides itself

But I hope you don't get yourself into trouble...C:\WINNT\system32>cmdow /?
'cmdow' is not recognized as an internal or external command,
operable program or batch file.

in windows 2000 Adv.Server
1. Have you DOWNLOADED CMDOW?
2. If you have, have you put it in system32? If not, either MOVE it there, or include the path to the file file typing it (i.e. C:\Docume~1\CMDOW.exe)Why do you want to hide a batch script??

Should of found his out his intentions first, Dark Blade. Any one by mistakenly close,while scripts are running on the machine.


my script is WORKING now,with CMDOW.

thanks..................all What does this script do Quote from: Carbon Dudeoxide on August 29, 2007, 05:26:37 AM

What does this script do
Sometimes, ignorance is bliss... frequently scripts are running on the server desktop, if any one access desktop and by mistakenly close the script window then problem, that is why i want hide the script windows.Oh, good. At least it's not something malicious like deleting files etc. WITHOUT the victim knowing.
8542.

Solve : Make BAT with colours and other language ... how ??

Answer»

I want to make bat with other colour for background , text and other THING , without set the colour every time when i start bat file .
And i want to ask (if this is possible) , can i change the language of single bat file like the colour .
For EXAMPLE i want to see the text in the BOX on Bulgarian .Well if you right click the title bar and GO &GT; defaults you can change colours and stuff, but I wouldn't know about language? Maybe it changes if you change the entire OS's language?Color /?

8543.

Solve : Error: Using "CD" Command to get to "Program Files"?

Answer»

I am having trouble getting to program files. I haven't got to them yet.
I TRY "CD Program Files", but it brings up an error message.


first : type cd /?
-------------------------------------------------------------
use doublequote (") to get path that have aspace character :
cd /d "C:\Program Files"

or more simply like this :
cd /d "%PROGRAMFILES%"
putting the "/d in front on "cd" MESSES up thing.

But the commands still not WORKING. I have windows XP Home EditionQuote from: Redlightpacket on August 23, 2007, 12:34:28 PM

But the commands still not working.

Please state exactly what you are typing and the messages that you see.

8544.

Solve : Quotes around Directory with Spaces not working?

Answer» I can't get my BATCH to work as needed:

rmdir E:\Backup /S/Q
MD E:\Backup
XCOPY "C:\Documents and Settings\Chris" "E:\Backup" /f/i/r/h/y/s
ECHO OFF
cls
ECHO * * * * * BACK-UP Complete * * * * *
ECHO %date% - %time%
PAUSE

This does work though

rmdir E:\Backup /S/Q
MD E:\Backup
XCOPY "C:\Icons" "E:\Backup" /f/i/r/h/y/s
ECHO OFF
cls
ECHO * * * * * BACK-UP Complete * * * * *
ECHO %date% - %time%
PAUSE


Any help would be great
What do you mean when you SAY "doesn't work"? What actually happens?
Quote from: contrex on August 26, 2007, 12:51:55 AM
What do you mean when you say "doesn't work"? What actually happens?

lol..was waiting for someone to ask that..Quote from: ghostdog74 on August 26, 2007, 02:49:22 AM
Quote from: contrex on August 26, 2007, 12:51:55 AM
What do you mean when you say "doesn't work"? What actually happens?

lol..was waiting for someone to ask that..

As you will see elsewhere, this is the current "bee in my bonnet".



Yes, it's difficult to diagnose a problem when there's not much else to go on besides, "I can't get my batch to work as needed". The more information and error information people give, the more high quality responses they'll get.Quote from: DeltaSlaya on August 26, 2007, 03:19:04 AM
Yes, it's difficult to diagnose a problem when there's not much else to go on besides, "I can't get my batch to work as needed".

You don't even get that in many cases. You just get "it doesn't work", which makes you wonder if cmd.exe has got corrupted in some weird and wonderful way that you never heard of before. I think many people suppose that computers should be able to do what they want them to do, rather than what they tell them to do.

if you are really desperate try use the short name "C:\Docume~1\Chris"Sorry, I've isolated the problem and also changed the syntax a bit

rmdir E:\Backup /S/Q
MD E:\Backup
MD E:\Backup\MyDocuments
MD E:\Backup\Desktop
XCOPY "C:\Documents and Settings\Chris\My Documents" E:\Backup\MyDocuments" /f/i/r/h/y/s
XCOPY "C:\Documents and Settings\Chris\Desktop" E:\Backup\Desktop" /f/i/r/h/y/s
ECHO OFF
cls
ECHO * * * * * BACK-UP Complete * * * * *
ECHO %date% - %time%
PAUSE

the copy function of MyDocuments works FINE the Problem is when i try to copy anything from the desktop folder I get a PARSE Error.


Quote from: contrex on August 26, 2007, 03:56:21 AM
Quote from: DeltaSlaya on August 26, 2007, 03:19:04 AM
Yes, it's difficult to diagnose a problem when there's not much else to go on besides, "I can't get my batch to work as needed".

You don't even get that in many cases. You just get "it doesn't work", which makes you wonder if cmd.exe has got corrupted in some weird and wonderful way that you never heard of before. I think many people suppose that computers should be able to do what they want them to do, rather than what they tell them to do.


i don't even bother thinking too much, after a while....Quote from: cfgcjm on August 26, 2007, 06:17:27 AM
XCOPY "C:\Documents and Settings\Chris\Desktop" E:\Backup\Desktop" /f/i/r/h/y/s

the copy function of MyDocuments works fine the Problem is when i try to copy anything from the desktop folder I get a Parse Error.

That's because Xvopy could not "parse" (i.e. interpret) the parameters that you gave it. The most common cause of this error is a missing quote, like in your posted command, at the beginning of the destination folder.





8545.

Solve : *.bat that rewrites a *.bat file?

Answer»

can i do that and how? I MEAN, rewrites the bat file with a UPDATED version.do it manually. There's no REASON you need to rewrite .bat files dynamically. if you need to, you have a CODE design problem.Read this thread

If rewriting the whole file is what you're after, then that might be the answer.

8546.

Solve : Writing BAT file to start execs?

Answer»

Ok so im trying to write a bacth file in notepad that starts .exe processes.... but I cant get past the spaces in folder names and such, im new to this but cant figure it out. and the "" parameters creates a title... so im lost.

For instance I want to run

C:\Program Files\McAfee\McAfee Shared Components\Instant Updater\RuLaunch.exe
-------
SO i open up notepad and:

start C:\Program Files\McAfee\McAfee Shared Components\Instant Updater\RuLaunch.exe <-- doesnt work
start "C:\Program Files\McAfee\McAfee Shared Components\Instant Updater\RuLaunch.exe" <-- doesnt work

and ive tried more but I just cant get it... thanks for your help.As so often happens on here, just saying "doesn't work" is not very informative. After all, batch files GENERALLY do what they are supposed to do. This is not always what you want them to do though. In what WAY does it "not work"? What actually happens? How are you saving and running the batch? What do you see at the prompt when you run the batch? Are you just double clicking the .bat or .cmd file? If you do that, the command window will open (very) BRIEFLY, any error messages will scroll by like lightning, the window will close, and you'll be none the wiser. Far better to either put a PAUSE command after the START command line, or open a command prompt window in the folder where the batch file is located, and run it by typing its name at the prompt.

You need a title string, even if you are not actually specifying one, in which case you would use a zero-length string (two quote marks with nothing in between them.)

Quote

@echo off
start "" "C:\Program Files\McAfee\McAfee Shared Components\Instant Updater\RuLaunch.exe"
pause

...should work. It should start the Rulaunch app (IF the path & name are right and IF you have sufficient permissions and IF the file isn't damaged) and wait for you to press a key.

After you are happy, you can delete the pause command.

If it doesn't, are you sure:

(1) you have typed the path and executable name correctly?

(2) it is not ALREADY running?



Quote from: contrex on August 25, 2007, 01:58:35 PM
As so often happens on here, just saying "doesn't work" is not very informative.
I think this should be added to the "Please read this" thread ...something like "Please do not say don't work...blah".... however, even so, no one seem to read that thread.You get these people who, after you've typed a 200 word guide to fix their problem, they just answer "Naw, doesn't work", and then expect you to guess what error messages they got. I am sure Coronadesign is not like that though.
8547.

Solve : Can't be KILLED?

Answer»

how to make a batchfile that can't be killed by another application or by taskkill /im cmd.exe ??


any help would be appreciated...
thanks b4..
Make it start as a service?How would he make it start as a service? I'd kind of like to know too.Start it by putting it in the [HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServices] key.Thanks.If you don't know how to do that.

Quote from: save as: "regme.reg"

REGEDIT4

[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\RunServices]
"Name of BAT."="Full path to BAT."

I don't know if you can kill services in normal WAYS, but I don't know if a command prompt window will be displayed either so this would be constantly running and if it's a loop could drain a lot of CPU time.you don't have to manually edit the registry. you can use the sc command.
type sc /? to see how it can be used.
btw, you can also kill a service. the question i want to ask is, why do you want to make something that can't be killed? Quote from: ghostdog74 on August 17, 2007, 09:01:39 PM
you don't have to manually edit the registry. you can use the sc command.
type sc /? to see how it can be used.
btw, you can also kill a service. the question i want to ask is, why do you want to make something that can't be killed?

I want to make something (batchfile/executablefile) that cannot killed by a virus..
coz, my computer have been infected with a virus that kill all application I'll Run (antivirus ,PROCESS EXPLORER & etc)..

i don't thing start as a service would solved my problem...
thanks so far for reply.....Quote from: Fen_Li on August 23, 2007, 11:01:25 AM
I want to make something (batchfile/executablefile) that cannot killed by a virus..
coz, my computer have been infected with a virus that kill all application I'll Run (antivirus ,process explorer & etc)..
why did you solve the problem the other way round. If you are infected with a virus, then clean the virus and make sure it doesn't happen again. Quote from: ghostdog74 on August 23, 2007, 03:15:46 PM
why did you solve the problem the other way round. If you are infected with a virus, then clean the virus and make sure it doesn't happen again.

I don't believe the explanation given. Like QUITE a number of "REASONS" given on here for wanting various kinds of help, I suspect the real reason is to make a virus, not fight one.

8548.

Solve : DOS COMMAND - NEED HELP?

Answer»

Hi

I was USED long back a dos command to create a txt File contains file names inside a folder. i forgot that command now.

for Exmple:

it is folder "Sept-4" contains 40 JPG files name from 1.jpg to 40.jpg

i gave a command in dos like "filename" "prn" and location to create the file which is i forgot, im not remmeber what is EXACTLY it is.

it will creat file.txt inside text like below

1.jpg
2.jpg
3.jpg to
40.jpg

Please help me
Ok there is probably an example of this that you could SEARCH the forums for, but I'll make one anyway.

Quote

@echo off

:: FILE TO OUTPUT
set file=filename.txt

:: FOLDER TO GO THROUGH
set folder=full path to folder

if exist "%file%" (
echo "%file%" already exists. It will be deleted if you continue.
pause >nul
del "%file%"
cls
)

for /f "usebackq delims=" %%I in (`dir /a:-d /b "%folder%\*.jpg"`) do (
>>"%file%" echo %%I
)

echo Done.
notepad %file%
8549.

Solve : Timed Launch?

Answer»

hi all
Its there a way to a BATCH cound down to PROCEED with the command?
or at lessed show progress. for ex 1% of download complete.For time to start:
Code: [Select]@echo off

ping -n 1 -w 1000 1.1.1.1 >nul
echo 3 seconds...
echo.
ping -n 2 -w 1000 1.1.1.1 >nul
echo 2 seconds...
echo.
ping -n 2 -w 1000 1.1.1.1 >nul
echo 1 second...
echo.
ping -n 2 -w 1000 1.1.1.1 >nul
echo.
echo STARTING PROGRAM now!
REM Add your code here.
pause
No 100% exact, but close enough. You could also try WAIT, which you can download somewhere (don't know the link, and can't upload because it's .exe)

8550.

Solve : adding a suffix to a file using batch?

Answer»

Quote from: DeltaSlaya on AUGUST 23, 2007, 04:44:49 PM

No PING is generally the easiest way, unless you download "Wait" or something, I don't have a link on me. Though I THINK that GIVES you full CPU unfortunately.

ftp://ftp.simtel.net/pub/simtelnet/msdos/batchutl/

ftp://ftp.simtel.net/pub/simtelnet/msdos/batchutl/wait.zip