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.

2701.

Solve : copy & rename?

Answer»

Hi EVERYONE,
I'm looking for some help with a copy/RENAME problem. I have a series of files (.shp,.shx,.dbf) that sit in a series of uniquely named folders
eg FPP_maps/LJS_Highlands/FPP_newroads.(shp).(shx).(dbf)
FPP_maps/LJS_East/FPP_newroads.(shp).(shx).(dbf)
FPP_maps/HJN_Porters/FPP_newroads.(shp).(shx).(dbf)

What I'd like to do is copy all the files to one location. My problem is that all the files are named the same and I can't rename them in their current location. I what I need the batch file ito do is copy and then rename the files in a sequential order. If it was the other way AROUND IE rename then copy I could do that.

Anyone got any ideas - any help would be greatly appreciated

Thanks
Helena


What is the current location here means ?
What is it referred to ? ie., the copied folder or copying folder ?

If it is the copying folder you can easily rename the files and then copy them into one location. There's no problem.

If it is the copied folder it hasn't permitt you to copy the file that has the same name. Bcoz the file names should be UNIQUE in the folder. You can copy the files with same name if they have different extension. The command will ask you to overwrite the previous file if you want to forcely copying.

2702.

Solve : Creating a batch file?

Answer»

I would like to create a batch FILE that would LOG off the current user and shut down by itself once its completely logged off. I think it's possible but i don't know how. And no, simply shutting down the computer without logging off isn't what I'm looking for. Could someone present a command/s that will do this for me?Shutdown -l -t 01

That should do it. So i tried the command "START C:\windows\system32\Shutdown.exe -l -t 10" and launched it, but doesn't do anything... Am I doing something wrong?Try without the start command. Just use shutdown with the switches. it doesn't WORK either, by REMOVING the "Start" command. when i use this "Shutdown -l -t 10" it's CAUSING a cmd prompt to come up,showing that the command is being used infinitly... i have to close the window because its just repeating the same command... hmmmWhat? Can you post a screenshot because I can't picture what you are talking about. Sure, heres a screenshot



As you can see on the side scroll, its down pretty far, hence the repeating command.Did you only run shutdown -l -t 10 from the command prompt?in the *.bat file all that's in there is "Shutdown -l -t 10", when i run the *.bat file, it brings up what you see in the posted screenshotThis is what happens when i do the command in cmd, it doesn't log off or anything.




p.s = i appreciate your quick replies!!!

2703.

Solve : XCOPY command in bat file doesn't run as scheduled task?

Answer»

Hi,

I have been testing the copying of files from a TEST directory on one SERVER (Windows 2008) to another server (Windows 2003).

I can SUCCESSFULLY execute the XCOPY command in a 'bat' file, but when I schedule the ‘bat’ file as a scheduled
task, the command doesn't work.

XCOPY "E:\backup test\test folder" "\\poweredge\Backups" /C /E /H /I /Y

What am I missing? Something related to PERMISSIONS?

THANKS!Did you schedule the script from the Scheduled Task Wizard or did you use the AT command?macdad,

Thanks for the response. I scheduled the script from the Scheduled Task Wizard.

I found the solution. A friend commented that dos xcopy won't let you use a URL
and that I would need to map a drive. Mapping the drive allowed the xcopy to work!

2704.

Solve : Filenames in Subdirectories?

Answer»

I'm trying to figure out a simple way to get a list of file names from a parent folder and all of its subfolders.

Currently, I’m using the command PROMPT with

dir /B /s /o:ng>Directory.txt

to print the filenames and pathways of all the files in the main folder and the subdirectories, but I also want to get a printout of just the names of the files. I can enter each subfolder and simply print a directory, but there has to be a more automated way.

I have tried using variations of the the command

(for /D /R %F in (*) do dir %F /b /o:ng) > mytextfile.txt

but it isn't working.

On a funny note, in my quest to figure this out I managed to write over the content of every file in one of my folders and its subfolders with the name of the file. My IT guys were impressed, but cautioned me to respect the power of the Command Prompt in the future They aren't sure how I did it (nor am I), and unfortunately they don't know how to do what I want. Thank goodness for backups!

Thanks in advance for any help. Fortunately that script doesn't delete anything

But if you want just the file names of a files in all SUBDIRS in a specific folder try this script:

Code: [Select]@echo off
echo. Files > DirectoryList.txt
set filecount=0
for /R "C:\Parent Folder" %%a in (.) do (
echo. File Found >> DirectoryList.txt
echo. %~dpa >> DirectoryList.txt
echo. %~nxa >> DirectoryList.txt
echo. >> DirectoryList.txt
set /a filecount+=1
)
echo. Total Files Found: %filecount% >> DirectoryList.txt
echo. Done
pause

You can drop whatever lines you want, but it should turn out like this in DirectoryList:

File Found
Filename.txt
C:\Folder\

Total Files Found: 1


Hope this helps
,Nick(macdad-)Thank you for the help.

I found that I had to put a double %% symbol in the lines where only a single was show to make the script work, though I don't know why. I also found that this gave me the names of all the subdirectories, but not the files in the subdirectory folders. I have hope though that I will figure it out though with your code. The double %% is exclusive to FOR, its basically a kind of local variable only assigned to the FOR command.

The FOR loop with the /R switch just makes FOR step thru all files in a folder and sub folders.

Code: [Select]echo. %~dpa >> DirectoryList.txtThis part of the code gets the current file's(That FOR has stepped to) Location in the folder.

Code: [Select]echo. %~nxa >> DirectoryList.txt
This one gets the actual file's name and extension.Macdad, you forgot something... You got it right in the FOR line but...

Code: [Select]echo. %~dpa >> DirectoryList.txt
echo. %~nxa >> DirectoryList.txt
...those single percent signs should be doubled: in a batch it's %%~dpa and %%~nxa

Fool me twice.OK, I'm putting this here for someone who might scour old posts like me in the future. One of the problems I was having was my program listing folder names as well as files names (which I didn't want), but also it climbing up the directory tree to include directories "." and ".."

After MUCH work and help from this forum and some smart friends, I finally came up with this which now counts the number of files and exports the names and then the file pathways of all files within a folder to text files (called "files" and "fullnames"). This includes all files stored within subfolders of the main folder.

Life is now GOOD.

@echo off
echo > files.txt
echo > fullnames.txt
set filecount=0
for /R %%f in (*) do ( echo %%~dpnxf >> fullnames.txt ) & (echo %%~nxf >> files.txt ) & (set /a filecount+=1)
echo. Total Files Found: %filecount%
echo. Done

2705.

Solve : Help with making a bat file for log filing?

Answer»

I'm looking to make a batch FILE that can create about 2000 very small logfiles (Just a simple netstat -N command) so I can do some IP address specific logging. Is there anyways to create a counting number, similar to c++ where the variable would just be similar to a++ would mean a would increase by 1 each time?

I'd rather not have to make a 2000 line batch file if I can do it in a few lines with a loop &GT;.<

I FIGURE the baseline to the batch file would be similar to this:

:loop
netstat -n >> IPlog1.txt
goto loop

However it needs to stop at IPlog2000.txt

Also would it be possible to insert (in milliseconds) the date?:loop
set /a num +=1
netstat -n > IPLOG%num%.log
if %num% equ 2000 goto eof
goto loop
:eof
exit

Time is not in the date command or the date variable. Use %time%. It already has milliseconds. For /l %%A in (1,1,2000) do (
netstat -n > IPlog%%A.txt
)

Welcome to the CH forums.Quote from: Dusty on October 12, 2009, 09:11:05 PM

For /l %%A in (1,1,2000) do (
netstat -n > IPlog%%A.txt
)

Welcome to the CH forums.
or use a for loop as dusty has given. Perfect - Thanks for the help fellas. Also thanks for the welcoming ^.^
2706.

Solve : Copy and Overwrite?

Answer» HI, all

Just to be curiosity that’s BAT. File”, I have very newly it and interesting wanted some one help to LEARNT me more, I have thing if I create the Bat.file that’s can COPY and overwrite, let say, just clicking the bat file, copy c:/my document/personal.xls than overwrite to the D:/my document/personal.xls.


Can it be do and how to present the statemnt.
First off, your slashes are backwards. It may bring up and error while programming.

You want to overwrite the file?
Code: [Select]DEL FILE-YOU-WANT-TO-OVERWRITE.EXT
COPY FILE-YOU-WANT-TO-REPLACE-IT-WITH.EXT D:\PATH-TO-FILE\FILE-YOU-WANT-TO-OVERWRITE.EXT

Thanks the advise..

can u help me the code , Was the code I gave you on 2 lines or 3?

I hate mobile browsers adding line breaks. I wish it would just format the page normally. Quote from: Helpmeh on October 12, 2009, 09:02:25 PM
Was the code I gave you on 2 lines or 3?


Dear Helpmeh

Thanks very much and i 'll try my self as I newly for this one.

Thank
2707.

Solve : Copying files with a .bat?

Answer»

Code: [Select]ECHO.
XCOPY a.* C:\Users\Lutcikaur\Desktop /-Y
GOTO END
thats what i have right now, and it will copy a file there. if i try and go onto my windows XP and use C:\Documents and Settings\Lutcikaur\Desktop instead if C:\Users\Lutcikaur\Desktop it will not work, and i am horridly unsure why.

Im trying to make a way to copy files quickly because i switch computers often and i just want to be able to plug in my flashdrive and dump my data to my XP LAPTOP from my vista desktop. i already have the working code (TOP) that goes to my vista.

My only thought would be because of the space in Documents and Settings, because i can dump the files into C:\ directly.Enclose the OUTPUT path in double quotes i.e. "C:\Documents and Settings\Lutcikaur\Desktop\"

& Welcome to the CH forums.thanks! i just realized that that would have been the PROBLEM right as i was checking for responses, its just like in html and im glad to be here. tryin to learn bat files and c++ at once, along with html for my site and im gettin tidbits at a time. Thanks again!you could also use "%userprofile%\Desktop\", if you have other users, or just want to make the batch file a few bytes shorter, heh

2708.

Solve : Printing to usb port from a program written in pascal?

Answer»

sorry to be a pain, but I have read forums and not FOUND answer, I have a similar problem. My work computers run Vista but my main ACCOUNTS program is a very old dos based program written in pascal. I need the speed of the modern computers to run the rest of my one person business, but I need the dos program for twenty years of records! I have to date , been able to install pci parallel cards to run the two printers used in the accounts program because I can't get the program to use usb printers. I can SEE a time when parallel cards will not be available (they are hard enough to find now), so how can I get the program to use usb PORTS, or is this not possible?

Apologies for using wrong THREAD!!

2709.

Solve : .bat to findstr and open file containing string?

Answer»

I am not so good at this at all but im sure trying...

I am trying to get a batch file that will...
1. read a line of TEXT from a text file
2. use that line as the string to search for in all the text files in another directory
3. then when it finds that line of text, i want it to then open that file

..... is that even possible?

anyway here is the code i have, and im sure the code is gonna be embarrassingly wrong but im hoping for help....

@echo
for /F "tokens=* delims= " %%a in ('findstr /G:%C:%\need\test2.txt %C:%\Need\1\*.txt') do set var=%%a do ( start notepad "%%~a" )



currently im getting .... WELL nothing happening, batch RUNS then closesQuote

i want it to then open that file

What if it finds the text in more than one file?I had thought about that, and it shouldn't happen in this case, these numbers are all specific to certain lots. (but you are right key word here is "shouldn't"

however... if there is way way to display the file(s) found containing that string in some wort of explorer type window so you can click and open one... that would be even betterGood Luck
2710.

Solve : Reading file properties?

Answer»

he requested the attributes and dates... however your solution isn't quite there yet, since it still has the bulky surounding text output from dir and attrib.

I imagine that some weird text manipulation could be achieved in batch though, to get the dates/attributes directly into environment variables.Quote from: billrich on October 08, 2009, 09:03:52 AM

Ghost,

Since Ghost imports commands from around the world to a Batch Board,
nowhere in the rules says this forum is just for cmd commands. so suck it up.

Quote
I suggest Ghost use Unix( Linux ) commands "Chmod: or "ls -last" for the attributes of the file.
chmod doesn't even come close to displaying file properties on linux. do you even understand what chmod does? Does OP want to change file permissions? I doubt so, since he doesn't SAY in his post. Which unix/linux platform are you on ? i don't recognise -last switch from ls. Also, the proper tools to use in *nix to list file properties are stat (or GNU find with printf ).


Quote
The Ghost VBS uses a separate line of code for each attribute.
look carefully again at the code. for each file listed, it display all the attributes of that file.

Quote
Batch only needs attrib.
bull.. show your batch code then...

Quote
By the way, Yogesh123 , the orginal poster, requested the properties of one file each time and not all the files in the directory or on the the C Drive.
if he just want a script to PASS a file name to it each time, its trivial to change. No big deal. just remove the loops....
I'm looking... but I see no batch board. I see a "Microsoft DOS" board, which has been already discussed to apply to both pure DOS AND windows-based DOS prompts. This includes the windows scripting host, which was designed to replace, at least in some capacity, Batch files.as we say here, shut up and have some pie.


Ok, actually I'm the only one that says it. but you cannot go wrong with pie.I don't like most kinds of pies i do like pumkin pie with alot of whipcream though there's alot of people who don't like pie

if america had to agree on one food to eat the rest of there lives in a vote i wonder what it would be i don't think it would be pieQuote from: billrich
BC_Programmer talks with great authority but has produced no Batch code or any other code
he has already said in his post he doesn't know a solution. And if he feels like it and wants to write that code, he will, and he certainly knows what he is talking about. The easiest solution is Ghostdog's VBScript where you can refer to each property by name and not some hieroglyphic token name.

However (sigh) if you insist on a batch solution, this is one way:

Code: [Select]@echo off
set /p fname=Enter file name:
dir /tc %fname% > dir.txt
for /f "skip=5 tokens=1" %%v in (dir.txt) do (
echo DATE Created: %%v
goto next
)

:next
dir /ta %fname% > dir.txt
for /f "skip=5 tokens=1" %%v in (dir.txt) do (
echo Date Accessed: %%v
goto next
)

:next
dir /tw %fname% > dir.txt
for /f "skip=5 tokens=1" %%v in (dir.txt) do (
echo Date Written: %%v
goto next
)

:next
dir %fname% > dir.txt
for /f "skip=5 tokens=5" %%v in (dir.txt) do (
echo Fully Qualified Name: %%~fv
echo Drive Specification: %%~dv
echo Path Specification: %%~pv
echo File Name: %%~nv
echo File Extension: %%~xv
echo Short Name: %%~sv
echo File Attributes: %%~av
echo File Date/Time: %%~tv
echo File Size: %%~zv
goto next
)

:next
del dir.txt
Good Luck(Sigh) The file I coded does not use a command line parameter, but prompts for the fie name. I'm confused about the file name timeinseconds, when in fact the file reported by the batch file is C:\$WINDOWS.~BT.

The file name and file extension are correct as reported in the output. The attributes are also correct (directory). I have no idea why size was not reported correctly,except directories do not have size properties (at least from the command prompt).

SidewinderThis thread is better than many TV soaps.
Good job Sidewinder. I'm SORRY I took up too much of your time.

Keep posting; you know what you are talking about.Quote from: billrich on October 10, 2009, 12:15:00 PM
I used the snake's code except a command line ARGUMENT instead of a prompt.

You and BC are in the same camp: "All Hat and no Cattle."

A twinkle in his eye and murder in his trousers, my mother used to say, or "all piss and vinegar"...

Quote from: billrich on October 10, 2009, 12:15:00 PM
I used the snake's code except a command line argument instead of a prompt.

You and BC are in the same camp: "All Hat and no Cattle."

Ironic. All you've done since your original post is purposely invent situations in which other peoples solutions break. For example by munging the batch file sidewinder provided. It works fine for me.

Obviously you failed to "convert" it to use a command-line argument, because it works fine here.

for a icon file I have:

Quote

D:\>side
Enter file name: D:\question.ico
Date Created: 09/08/2009
Date Accessed: 09/08/2009
Date Written: 09/08/2009
Fully Qualified Name: D:\question.ico
Drive Specification: D:
Path Specification: \
File Name: question
File Extension: .ico
Short Name: D:\question.ico
File Attributes: --a------
File Date/Time: 09/08/2009 05:39 PM
File Size: 15086

D:\>
It failed when I tried to use it on files from another drive:




Probably easily fixed with a PushD of some form, since it works from that directory:

Quote



D:\>side C:\windows\syswow64\shell32.dll
Enter file name: C:\windows\syswow64\shell32.dll
Date Created: 07/30/2009
Date Accessed: 07/30/2009
Date Written: 04/10/2009
Fully Qualified Name: C:\Windows\SysWOW64\shell32.dll
Drive Specification: C:
Path Specification: \Windows\SysWOW64\
File Name: shell32
File Extension: .dll
Short Name: C:\Windows\SysWOW64\shell32.dll
File Attributes: --a------
File Date/Time: 04/10/2009 11:28 PM
File Size: 11584000


In either case perhaps before making alterations to a batch file Billrich should test it as provided, rather then making changes and proclaiming epic failure even when it's fully possible the changes caused the problem, as I believe to be the case here.







Seems to work fine. Of course I didn't mess about with the innards like a inept surgery intern. I believe the logic at this point speaks for itself for everybody but SpectateSwamp Billrich, who will continue on with analogies that bring back his fond memories of the ranch, and yet have no bearing to the context at all.



In other news, I also converted (somewhat more successfully then the batch code... which I didn't mess with at all) the VBS file to access only a single file specified as an argument.

Code: [Select]Set objFS=CreateObject("Scripting.FileSystemObject")
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
strFile= wscript.Arguments(0)
Set objFile = objFS.GetFile(strFile)

name=Replace(ObjFile.Path,"\","\\")
s="Select * from CIM_Datafile Where name = """ & name & """"
Set colFiles = objWMIService.ExecQuery(s)
For Each objFile in colFiles
Wscript.Echo "Access mask: " & objFile.AccessMask
Wscript.Echo "Archive: " & objFile.Archive
Wscript.Echo "Compressed: " & objFile.Compressed
Wscript.Echo "Compression method: " & objFile.CompressionMethod
Wscript.Echo "Creation date: " & objFile.CreationDate
Wscript.Echo "Computer system name: " & objFile.CSName
Wscript.Echo "Drive: " & objFile.Drive
Wscript.Echo "8.3 file name: " & objFile.EightDotThreeFileName
Wscript.Echo "Encrypted: " & objFile.Encrypted
Wscript.Echo "Encryption method: " & objFile.EncryptionMethod
Wscript.Echo "Extension: " & objFile.Extension
Wscript.Echo "File name: " & objFile.FileName
Wscript.Echo "File size: " & objFile.FileSize
Wscript.Echo "File type: " & objFile.FileType
Wscript.Echo "File system name: " & objFile.FSName
Wscript.Echo "Hidden: " & objFile.Hidden
Wscript.Echo "Last accessed: " & objFile.LastAccessed
Wscript.Echo "Last modified: " & objFile.LastModified
Wscript.Echo "Manufacturer: " & objFile.Manufacturer
Wscript.Echo "Name: " & objFile.Name
Wscript.Echo "Path: " & objFile.Path
Wscript.Echo "Readable: " & objFile.Readable
Wscript.Echo "System: " & objFile.System
Wscript.Echo "Version: " & objFile.Version
Wscript.Echo "Writeable: " & objFile.Writeable
WScript.Echo "Install Date: " & objFile.InstallDate
Wscript.Echo "-----------------------------------------------------------------"
Next



This can be accessed in a batch file:

Code: [Select]
cscript fileattribs.vbs D:\testads2.txt


D:\>fileattribs D:\testads2.txt
Microsoft (R) Windows Script Host Version 5.7
Copyright (C) Microsoft Corporation. All rights reserved.

Access mask:
Archive: True
Compressed: False
Compression method:
Creation date: 20090803234730.934563-420
Computer system name: TERATRON
Drive: d:
8.3 file name: d:\testads2.txt
Encrypted: False
Encryption method:
Extension: txt
File name: testads2
File size: 287
File type: Text Document
File system name: NTFS
Hidden: False
Last accessed: 20090803234730.934563-420
Last modified: 20090303190457.875000-480
Manufacturer:
Name: d:\testads2.txt
Path: \
Readable: True
System: False
Version:
Writeable: True
Install Date: 20090803234730.934563-420
-----------------------------------------------------------------









2711.

Solve : Any one know how to hide a file??

Answer»

A friend told me I could creat files in dos system, while could not open in microsoft system. Any one know the exact steps? Well, first off, you are running XP. There us no DOS in XP. There is the COMMAND prompt however, and I shall continue.

Go to the command prompt as you normally WOULD, and type in

ATTRIB /?

You can still access files if they have the SYSTEM and HIDDEN attributes, but it is hard (for skiddies who think they are computer hackers, or someone computer illiterate). the correct syntax would be

"attrib filename +h"

or to unhide, do -h

Quote from: Zeriously on October 08, 2009, 11:42:30 AM

the correct syntax would be

"attrib filename +h"

or to unhide, do -h


A lot of PEOPLE can view hidden files through folder options. Most people can't view system files (+s) because a message box pops up to ask if they're sure and system files are important BLABLABLA and they click no. System/hidden files show up FINE for me in explorer with no prompt of any form.

It is only specific folders that show that prompt; I believe it is a desktop.ini setting for that folder.When you try to change the option of viewing the system files from the reccomended option, it does prompt you not to do it.
2712.

Solve : auyo run and logging?

Answer»

i am having troble with the autorun files they wont work on my memorystick so i plug it in nothing happens forever

and is there a way of recording what program SOMBODY has been on and how long forQuote

am having troble with the autorun files they wont work on my memorystick so i plug it in nothing happens forever

USB cannot be autorun like a CD, however you can CREATE your own option in the "What do you want Windows to do" screen which the user can click to get things started.

Check out this method

Be sure to use relative path pointers as the USB drive letter will be DIFFERENT on each system.

Quote
and is there a way of recording what program sombody has been on and how long for

How are they starting the program now? Double clicking an icon? Batch file? VBScript? You may have to wrap the executable in a batch file which in addition to loading the program, can log the start and end TIMES.

Good luck.
2713.

Solve : Help for sleep command in batch script?

Answer»

Dear All,

I am new bie for windows scripting environment.
I am facing a strange issue.

I have two files First.bat is running all the time and code is

****************
:START

Second.cmd

sleep 1000

goto :START
****************

second file has some piece of instruction to accomplish some task.
when I RUN this first time or second time it works FINE, i.e. sleep for some time and then start processing again.
However after that I obsereved If I press enter than only script resumes else keep on sleeping no matter what time we have provided :|

Could you please advise, where I am missing.
Also I have given "sleep 500" in second.cmd as well. However not stuck at that poing, stuck only at sleep in first.bat.

Kindly advise.

Thank you,
SUNIL Somani
In place of sleep, i have also created delays using ping command such as

Ping 127.0.0.1 -n 60 >pingdelay.txt

Where -n 60 tells it to count 60 ( *about 60 seconds ) and >pingdelay.txt is where the ping OUTPUT is echo'd off to to avoid seeing the pings scrolling. 60 can be changed to any NUMBER to have proper delay.

After this instruction is executed it will move on to the next instruction without delay that you are having.

2714.

Solve : Simple question.?

Answer»

Hello,
Is it possible to make a .bat file do something before exiting?
I have windows XP.Yes.

FBTell me how and I'm thankful.What is it you want to do?

FBI want to call a .bat file when ESCAPE or the exit BUTTON is pressed.You can't change the exit button behavious, and esc can only be USED with external TOOLS. What you want to do sounds more like VB.

FB

2715.

Solve : big prob?

Answer»

when i run a batch file the comand window opens up then closes strait away i need help to fix this problem please ☺open up a normal command prompt i.e. from start&GT;run>cmd. then run your batch PROGRAM from there. if it's an error that's forcing an exit the original cmd will catch it. if it's an exit you've left in (i've don that before couldn't work out why it was exiting) then it won't catch it you'll have to look through the batch .

FBThat is normal.
What do you want it to do?
sorry i was assuming it as an error that was forcing the close (assume makes an *censored* of u and me) if it's running to completion with no more INSTRUCTIONS it will exit. to stop this just insert a pause and exit as the last two lines.

FBIt COULD also be something to do with a syntax error. I have had a few similar ISSUES with loops.
Posting your code could help identify the reason.

In general If everything is good, pause will wait for a key press to exit.

Cheers!!To do a complete DEBUG, you can add after every line:

Code: [Select]echo 1
pauseand for the second line, replace it with echo 2 (and so on and so forth).
After that, you you can tell which line is causing the problem, because the next line will cause it to crash.thancks i figured out why

i forgot to put pause at the end

2716.

Solve : low poh...?

Answer»

low how i can browse the friendster if it is in BLOCK??quick question- have you perhaps read the forum rules that EXPLICITLY state we will not ASSIST with the circumvention of any form of security/banning/authentication?

TRIPLE POST now. Dumb kid.

2717.

Solve : Amiga Dos & MS Dos?

Answer»

I have a friend with a mid-1980's Amiga PC running Amiga Dos with the Amiga OS Workbench shell. He has LOTS of games for this computer on FLOPPY disks.

Will these Amiga Dos games work on MS Dos? Are all Dos operating system compatible with programs, are Apple Dos games compatible with MS dos ones?The abbreviation DOS stands for "Disk Operating System". In the 1980s there were plenty of different computers which had Disk Operating Systems. Microsoft Disk Operating System (MS-DOS for short) was one. Apple DOS (Apple II 1978-1983) was another. Amiga DOS was yet another. LET's not forget Atari TOS (Tramiel Operating System). They all ran on different hardware and are not compatible with each other. At all. Period. However you might be able to run some Amiga and Apple games on a Windows PC using an emulator program, but I think you'll have trouble reading the floppies.


indeed,- DOS bac kthen meant what OS means now. In fact, it's still really a "DOS" since we almost always deal with a hard disk or other disk, but for the most part that is no longer it's Main feature.The question is not a bad question. At one time many of us were hoping there would be a day when interchange stuff goes from one personal computer to another.
That day is now coming, - at last.
Very soon now!
Thanks guys.

I used a bit of DOS growing up (mainly Apple DOS) but I am not that familiar with it as a lot of PC's were running 95/98 by then. I use MS DOS (or FREEDOS) now almost daily and I'm trying to learn it.

I'll probably try an Amiga emulator and hope I don't have problems reading the floppys.I have some old Amiga games on my laptop like MOONSTONE, Elite 2: Frontiers, betrayol at Krondor, Wings, beneath a steel sky, north and south etc etc and I get them to work fine through DosBox but you will have to hunt down the freeware games off the internet they are out there if you look. Some you will have to pay for but there cheap as you like. yup DOSBox 0.72 gets u there, but u gotta know what ur dl. like me, im trying to run K240 [amiga uber strategy game] on my PC but im having no luck. i had little trouble starting up its PC sequell Fragile Allegiance, but DOSBox isnt seeing the files i dl for k240.

btw, what is an .adf extension?
and does anyone possibly know or play k240 that can help me install it?

so far i got the DOSBox to see INSTALL file of the k240, but its not an .exe file somehow cus i cant install it, nor do i see any setup.exe or anything else that can fire up the game.

what i do see is the following:

Source [dir]
install
install~1.inf
k240.inf
k240~1.exo
k240~2.sla
manual
manual~1.inf
readme
readme~1.inf

so what can i do here, anyone?DOSBox emulates MS-DOS, not Amiga DOS.

ok, thats a good start. any idea on what i need?An Amiga emulator.Or a new topic

2718.

Solve : for %v in was unexpected at this time?

Answer»

Code: [Select]cls
@echo off
if [%1]==[] %0 20 18
if [%2]==[] %0 %1 18
set {t}=fb800:0l1f40 b0 71
:loop
if not [%4]==[] for %%v in ( set shift shift goto:loop) do %%v {t}=%{t}% %3 %4
> {s} echo %{t}%
>>{s} for %%v in (echo.q set) do %%v {t}=
< {s} debug > nul
del {s}
I am getting error of:

for %v in was unexpected at this time.

C:\>


And not sure why. This is an old batch from 10 years ago that use to work under Win 95 or 98 SE, but pukes on Win XP Pro. Error seems to be this section of code...but not sure how to fix it... It all looks CORRECT.
Please describe what the batch is supposed to do. The DOS/Win98 version of FOR is quite a bit different from the NT family version found in Windows 2000 and later.
From memory since I dont have an older system to run this on. It use to show a GREY background with blue text to be displayed and might have beeped the PC speaker, although I dont see a Beep command here.

Background and text colors can be solved by color xx command. I COULD essentially drop the code above and add COLOR 81 and get the same display appearance that I remember, but was curious WITHOUT butchering the batch if anyone knew why.

Your statement of Quote

The DOS/Win98 version of FOR is quite a bit different from the NT family version found in Windows 2000 and later.
is probably the REASON why. I guess I should perform a google seach maybe to see the differences and why for the change between pre-NT and NT FOR statement parameters, since that is what it appears to be now.

Thanks for pointing that out!.
2719.

Solve : Batch filebackup to date stamped folder?

Answer»

I am doing a project where i have to create a menu system to backup files to a SPECIFIC location, backup files that have been created since last backup and offer a restore files option. The only problem i have is how to get the program to copy all files from a specific folder to a date stamped folder. Any help appreciatedplease show your local date format setting

here's mine for example

Code: [Select]C:\&GT;echo %date%
05/10/2009My date setting is the same as yoursuse string slicing to get the YYYY MM and DD parts out of %date% and the mkdir command to create the folder NAMED as you want

slice a string thus %string:offset,length% offset is the offset from the start (0 is 1st CHAR) and length is the no of chars.

THis should give you the idea, and also something to build on...

Code: [Select]set dd=%date:~0,2%
set mm=%date:~3,2%
set yyyy=%date:~6,4%
set newfolder=%yyyy%-%mm%-%dd%
if not EXIST %newfolder% mkdir %newfolder%
copy myfolder\*.* %newfolder%

2720.

Solve : Archive Files?

Answer»

I am trying to write a script that will do the following:

1. Test for an archive directory, and create it if it doesn't exist.
2. Move files older than 30 days from an input directory to the archive directory.

Below is the code I have so far. The last line is causing errors which are listed below the code. I will be running this on WINDOWS XP and eventually it will be MOVED to a Server 2003 machine.

Code: [Select]
@ECHO off
setlocal enabledelayedexpansion

set currentdirectory=C:\DocumentQC\Input-Delete
set backupdirectory=C:\DocumentQC\backupdir

IF EXIST %backupdirectory% GOTO MOVE_FILES
MD %backupdirectory%
:MOVE_FILES
FOR /f -p%currentdirectory% -s -m*.* -d-30 -c"CMD /C MOVE /y @FILE %backupdirectory%"


----------------- ERROR -----------------------

-s was UNEXPECTED at this time.

----------------- ERROR -----------------------

I'm obviously using FOR and MOVE incorrectly, any advice would be appreciated. Thanks.Look at for /? And you should see why it isn't working.

2721.

Solve : Win/Batch: How to get the folder name from path?

Answer»

Hi,

Can anyone teach me how to get the string of the folder name from a directory path by DOS batch command?

For example: if the directory path is "d:\app program\test folder", how to extract the string "test folder"?

Thanks
thomasThis will provide the name of the current working directory.

Code: [Select]for /f "delims=" %%A in ('cd') do (
set foldername=%%~nxA
)

echo. Current Folder Name: %foldername%
Hello
C:\app program\test folder>cd \

C:\>dir /s foldertest.txt
Volume in drive C has no label.
Volume Serial Number is F4A3-D6B3

Directory of C:\app program\test folder

10/01/2009 03:59 PM 9 foldertest.txt
1 File(s) 9 bytes

Total Files Listed:
1 File(s) 9 bytes
0 Dir(s) 306,328,834,048 bytes free

C:\>
C:\>type testextract.bat

REM To find the path to test folder,we place a file foldertest.txt in the folder
REM We then searched for that file to get the path string and extract
REM test folder ( the folder name we were after
REM We can USE any drive for drive D: We used C: drive
Code: [Select]@echo off
cd C:\app program\test folder\
echo CD = %CD%
cd \
echo CD = %CD%

dir /s foldertest.txt | findstr "Directory" > tmpFile.txt

echo type tmpFile.txt
type tmpFile.txt

set /P foldername= < tmpFile.txt

set foldername=%foldername:Directory of C:\app program\test folder=test folder%


echo foldername = %foldername%
Output:

C:\> testextract.bat

CD = C:\app program\test folder

CD = C:\

type tmpFile.txt

Directory of C:\app program\test folder

foldername = test folder
C:\>

REM
This line of code:

set foldername=%foldername:Directory of C:\app program\test folder=test folder%

was with the help of the following site for string manipulation:

http://www.dostips.com/DtTipsStringManipulation.php

but I can no longer reach the site.

We replaced one substring of a string with another string. In this case the substring was the complete string. The new string was the folder name.

A more generic batch file might use command arguments and the folder name would not be hard coded in the batch code.

Good luck Actually, my situation is a bit complicated.

I have to get the directory path (say "C:\app program\test folder") from user input and then extract the folder name (say "test folder") for further manipulation.

I think I have to store the path by a variable and then extract the sting by a for
loop.

But I don't know code for the process.

Here is my partial code:

@echo off
echo Please input the path of program files
set /p foldername=
rem then I need the code to manipulate the require field
pause
exit


Quote from: lwkt on October 01, 2009, 11:24:57 PM

Actually, my situation is a bit complicated.

I have to get the directory path (say "C:\app program\test folder") from user input and then extract the folder name (say "test folder") for further manipulation.

I think I have to store the path by a variable and then extract the sting by a for
loop.

But I don't know code for the process.

Here is my partial code:

@echo off
echo Please input the path of program files
set /p foldername=
rem then I need the code to manipulate the require field
pause
exit


If you are going to ask the user for the folder name, then the computer need not find it.

After the folder name is assigned to a variable, how will the variable be used?

If you have the folder name, the computer can find the path to the folder:

dir /s foldername from the root directory will find the path.

Most users cannot enter a complete path correctly. And your goal is to assign a foldername to a variable. The user provides the folder name.

I don't really understand your goal or problem.
Actually I am going to perform backup for the content of folder from different users' request.

User should input the full path of source folder (say "C:\app program\test folder") for backup. I am going to use XCOPY command to perform the backup task. Then, the newly created folder after backup will be appended by a TIME stamp (say ""C:\app program\test folder_2009-10-02").

Therefore I need to extract the folder name for manipulation.

Here is my code: -
=========================================================
echo Please input the name of folder that you want to backup and press "Enter" key
set/p src=
echo.
REM create folder name(say "test folder_2009-10-02" and assigned to variable tgt)
xcopy /a /c /d /e /k /h /y "%src%"\*.* "%tgt%"*.*
echo.
pause
exit
=========================================================

I think ASSIGNING the path string to a variable is feasible step that I can use
FOR loop to extract the required field for manipulation. If so, I hope someone can tell me the WAY to extract the required string.

BTW, any other suggestions are welcome.






Quote from: lwkt on October 02, 2009, 07:13:25 AM
I think assigning the path string to a variable is feasible step that I can use
FOR loop to extract the required field for manipulation. If so, I hope someone can tell me the way to extract the required string.

if %%F is path, %%~nF is lowest folder.

Code: [Select]set mypath="C:\Program Files\X Ray Vision\Bin"
for /f "delims==" %%F in (%mypath%) do set foldername=%%~nF
echo %foldername%
Code: [Select]BinThanks for Salmon's code. it solve my problem.

But may I know the reason to use the option "delims==" in
the FOR command?

Quote from: lwkt on October 03, 2009, 08:55:19 PM
Thanks for Salmon's code. it solve my problem.

But may I know the reason to use the option "delims==" in
the FOR command?



In case path has any spaces, set delims to be beginnning and end of line. Alternative is "delims=".

Code: [Select]@echo off
set mypath="C:\Program Files\X Ray Vision\Bin"

echo with "delims=="

for /f "delims==" %%F in (%mypath%) do (
echo Drive %%~dF
echo Path %%~pF
echo Folder %%~nF
)

echo.
echo without "delims=="

for /f %%F in (%mypath%) do (
echo Drive %%~dF
echo Path %%~pF
echo Folder %%~nF
)


Code: [Select]with "delims=="
Drive C:
Path \Program Files\X Ray Vision\
Folder Bin

without "delims=="
Drive C:
Path \
Folder Program


Got it !! thanks.
2722.

Solve : retrieving only filename using findstr?

Answer»

Hallo to everybody. I'm an italian user, so please forgive my poor english. I follow you from a lot of time but now I need your help so I've REGISTERED myself.

Now I explain my problem. I have to loop recursively a folder in order to find all the files that starts with 6 digits followed by some text, let's say A.csv.

I wrote this

dir /b /s | findstr /i ^[0-9][0-9][0-9][0-9][0-9][0-9]A.csv$

and it works but this command returns me the full paths. I'd like to have only filename. I know about the for command and ~n but I don't know if I can use it with findstr. Thanks in advance. for /f can parse the output of a command line. Use single quotes.

CODE: [Select]for /f "delims==" %%F in ('dir /b /s ^| findstr /i ^[0-9][0-9][0-9][0-9][0-9][0-9]A.csv$') do (
echo %%F
)

Code: [Select]S:\Test\Batch\After 07-09-09\forfind\123452A.csv
S:\Test\Batch\After 07-09-09\forfind\123453A.csv
S:\Test\Batch\After 07-09-09\forfind\123454A.csv
S:\Test\Batch\After 07-09-09\forfind\123455A.csv
S:\Test\Batch\After 07-09-09\forfind\123456A.csv
S:\Test\Batch\After 07-09-09\forfind\123451A.csv

~nxVariable is name + extension. See for /? for full list of variable modifiers.

remember to ESCAPE the pipe symbol | like this ^| or you will get an error

Code: [Select]for /f "delims==" %%F in ('dir /b /s ^| findstr /i ^[0-9][0-9][0-9][0-9][0-9][0-9]A.csv$') do (
echo %%~nxF
)

Code: [Select]123452A.csv
123453A.csv
123454A.csv
123455A.csv
123456A.csv
123451A.csv
Thank you very much Salmon. I didn't know about the escape char, indeed without it I received an error and this was the reason why I thought I couldn't use findstr within for. I've learned a NEW thing.
Thanks again for your kindness and for the speed of your reply. Have a nice day. va bene

2723.

Solve : How do you change the background color and size of the cmd prompt window??

Answer»

I have a batch file that opens a DOS cmd prompt WINDOW but I am stuck on how to change the background color and size of the new cmd prompt window. I have SOMETHING like this but it's only half work (if that make any sense).

start COLOR 1E & mode 40,7 cmd.exe

The background color works but to change the size does not.

As before. Any comments or suggestions would be greatly appreciated.

thanksto change size use Code: [Select]mode con lines=x cols=y
FBSwitches must follow the program being opened. Try this to start Cmd.exe with BLUE background and green lettering in full-screen.

Code: [Select]start /max "Cmd.exe, Green on Blue" cmd /t:1a/k cls

Good luck@echo off
color 0a
mode con=50 cols=75

save as wtv.batQuote from: PirateSamir

@echo off
color 0a
mode con=50 cols=75

Was it tested, is it possibe something is missing Im use to using Command promt ... lol but i would do Color a for green on black otherwise you can type in color dfd to get help for DIFFERENT colors.. just trying to helpsorry that was wrong, dont know wat i was thinking, anyways, save this is as wtv.bat
Code: [Select]@echo off
color 0a
mode con lines=50 cols=75
pause
Also to view all possible colour combinations type in color help in cmd.Quote from: PirateSamir on January 27, 2009, 05:15:25 AM
Code: [Select]mode con lines=50 cols=75

This line LOOKS familiar....

FBQuote from: fireballs on January 27, 2009, 05:17:52 AM
Quote from: PirateSamir on January 27, 2009, 05:15:25 AM
Code: [Select]mode con lines=50 cols=75

This line looks familiar....

FB

lol, its not my fault the guy didnt take your advice also is that my prob to
that's a good question, which is weird considering the omission of punctuation.Wow.
2724.

Solve : Batch file to send email notification?

Answer»

I need to create a batch file that runs EVERY half hour or 1 hour on specific file (log file) and if it sees same TIMESTAMP more than 10 lines it should send email notification.Appreciate if ANYBODY help on this...
for example, timestamp shows in the log file:
[6/12/09 0:07:09:920 EDT] 0000031b SystemOut O MY_PROTO is
[6/12/09 0:07:09:920 EDT] 0000031b SystemOut O PLATFORM is qa
[6/12/09 0:07:09:920 EDT] 0000031b SystemOut O MY_HOST is abc.ac.tx.anet
[6/12/09 0:07:09:920 EDT] 0000031b SystemOut O MY_PORT is 389
[6/12/09 0:07:09:920 EDT] 0000031b SystemOut O MY_USER is
[6/12/09 0:07:09:920 EDT] 0000031b SystemOut O MY_PASS is avcfE
[6/12/09 0:07:09:920 EDT] 0000031b SystemOut O MY_PROTO is ldap://
[6/12/09 0:07:09:920 EDT] 0000031b SystemOut O PLATFORM is prod
[6/12/09 0:07:09:920 EDT] 0000031b SystemOut O MY_HOST is abc.ac.tx.anet
[6/12/09 0:07:09:920 EDT] 0000031b SystemOut O MY_PORT is 389

Thanks,
-Ram

2725.

Solve : I need help in the Loop command?

Answer»

I'm trying to recreate a batch file i did about 3 years ago, I remember most of it, but I had it setup up where if the Call command to run a second batch file and the command to start a program into a loop. The kind of loop was that if the user of the computer closed the program that it WOULD reopen and start again. I cannot remember the right command.
Here is what I got

echo off
:start
start /max C:\1.avi
goto start

However every time it closes out, it reopens like it suppose to but opens the programs like 20 times(that is how many i counted in the Process tab of Task Manager) i had to end the .bat program to get them to stop popping up, and when i close out the .bat the movie plays instead of repeatedly opening, i want it to open, and if i close out, it opens again and starts playing

any help??
I would set the play options to loop in the player as for the nature of such a batch would be a PITA for anyone with it running with limited computer knowledge to stop it or remove it. We wont help here with aiding in the creation of pest or malicious code even if just a joke.

Most common gag being a movie of the desktop and the user 'thinks" that their computer is doing bad THINGS etc, but its a movie overlay. And 2nd most common being a background of a SCREENSHOT with icons that dont exist as an IMAGE to PISS people off when they cant be selected.

2726.

Solve : How to invoke ssh from the batch file in windows?

Answer»

Hi All,
I am a new member to this forum. I am trying to invoke a SSH session from a batch script from windows to login to a linux machine.

I have created a file with .bat extension. I have given my batch file below.

@echo off
echo connecting
ssh [emailprotected]
pause

and it is GIVING the error as follows

'ssh' is not recognized as an internal or EXTERNAL command, operable program or batch file.

please help me....
Thanks in Advance.

Anil
that means your ssh exe is not in your PATH. Thank u very much......

Now i am able to open ssh session from my batch file... and my CODE looks like this

@echo off
echo connecting
"C:\\DOCUMENTS and Settings\\Desktop\\Software\\"putty.exe -ssh 10.50.25.88
pause

thanks a lot once again.......

Anil.

2727.

Solve : batch script move file based on name?

Answer»

Hello,

I WOULD like to create a script (in batch if possible) to move file from my desktop to my server based on it filename it will place it in the correct folder. I have nearly no knowing of any programming language, only very basic batch scripting.

So for example I have [php]Webserver-03-09[23D12A].php on a shared folder on my desktop, so the script should move the file to the D:\backup\Web server folder on the server.
Another example is that filename could be like [flash]frontpage_animation_03_09[45D5F2].swf to be moved to a folder named frontpage animation.

I know the easy way would be to rename the destination folder but the script is primary made for me to get a little better with batch programming.

So the first thing for the script is to remove [] and is content :
I found this : http://archives.devshed.com/forums/ms-dos-127/remove-underscore-from-200-files-1205654.html

for /f "tokens=1* delims=_" %i in ('dir /b/a:-d ') do ECHO "%i_%j" T "%i%j"

But actually I have just tested this command but it doesn t seem to work to remove a underscore... another thing is where is %j coming from ?


if you have Python on Windows and the following assumptions:
1) assuming you can map to your server
2) assuming all file start with [

Code: [Select]import os,glob,sys,re
pat=re.compile("(\[.*?\])")
source = sys.argv[1]
destination = sys.argv[2]
os.chdir(source)
for files in glob.glob("[*"):
newfilename = pat.sub("",files)
if "_" in newfilename:
newfilename = newfilename.split("_")
elif "-" in newfilename:
newfilename = newfilename.split("-")
newpath = os.path.join(destination , ' '.join(newfilename[:-2]))
if not os.path.exists(newpath):
os.mkdir(newpath)
try:
os.rename(os.path.join(source,files),os.path.join(newpath,files))
except EXCEPTION,e:
print e
else:
print "Move %s to %s successful." %( files, destination)
usage: c:\test> python test.py

Here's an executable you can use in your batch
eg
Code: [Select]C:\test>dir
Directory of C:\test

06/12/2009 11:22 PM <DIR> .
06/12/2009 11:22 PM <DIR> ..
06/12/2009 11:18 PM 1,613,993 test.exe
05/02/2009 04:52 PM 29 [flash]frontpage_animation_03_09[45D5F2].swf
06/03/2009 04:29 PM 137 [php]Webserver-03-09[23D12A].php


C:\test>
C:\test>test.exe c:\test c:\tmp
Move [flash]frontpage_animation_03_09[45D5F2].swf to c:\tmp successful.
Move [php]Webserver-03-09[23D12A].php to c:\tmp successful.

C:\test>dir /s c:\tmp\

Directory of c:\tmp

06/12/2009 11:22 PM <DIR> .
06/12/2009 11:22 PM <DIR> ..
06/12/2009 11:22 PM <DIR> frontpage animation
06/12/2009 11:22 PM <DIR> Webserver
0 File(s) 0 bytes

Directory of c:\tmp\frontpage animation

06/12/2009 11:22 PM <DIR> .
06/12/2009 11:22 PM <DIR> ..
05/02/2009 04:52 PM 29 [flash]frontpage_animation_03_09[45D5F2].swf
1 File(s) 29 bytes

Directory of c:\tmp\Webserver

06/12/2009 11:22 PM <DIR> .
06/12/2009 11:22 PM <DIR> ..
06/03/2009 04:29 PM 137 [php]Webserver-03-09[23D12A].php
1 File(s) 137 bytes
Thanks a lot gh0std0g74 ! Generally all the files are beginning with [ but it is not ALWAYS the case, but in this case i ll do that manually. Actually I was planning to learn python so it is a great way to get more in this language.

2728.

Solve : low guys...?

Answer»

i need your help for this problem.. i hope u all can help mePlease DONT try and GET more people to LOOK at your posts by posting again in a completely different area SAYING you need help.

This topic has been LOCKED.

2729.

Solve : I've been trying to get My batch file game to work but it isn't Please help?

Answer»

I want it to be knda an old fashioned multiple path game
where you choose different paths for different things to happen (sorry bad explaination)

anyway here it is :

@echo off
cls
echo Today you will begin you Quest...
echo.
pause
cls
echo The quest to find...
echo.
pause
cls
echo THE ULTIMATE CUPCAKE!!!
echo.
pause
cls
echo Not only is it the best tasting cupcake in the world but
echo it will also grant you the power to...
echo.
pause
cls
echo BECOME INVISIBLE!!! (for 3-11 seconds)
echo.
pause
cls
echo Do you want to Begin? Y or N
set /p co="% %"
if "%co%"=="Y" goto 2
if "%co%"=="N" goto end

2:
cls
echo you wake up in a musty, dark, dank cave
echo you dont know how you got there
echo you feel as though someone is close to you
echo watching you...
echo.
pause
cls
echo Do you A Run to the Exit or B Pull out your Dagger? A or B
set /p co="% %"
if "%co%"=="A" goto R
if "%co%"=="B" goto D

D:
cls
echo You reach for your dagger
echo but in place of where you dagger should be
echo is some thing fleshy
echo.
pause

end:
cls
echo You Lost
echo.
pause

R:
echo You MAKE a mad dash for the exit of the cave
echo but as you head into the sunlight and out of
echo the darkness, you look back for a second
echo and notice something glimmer inside of the cave.
echo.
cls
echo Do you A Go back inside or B Start trying to find your way home? A or B
set /p co="% %"
if "%co%"=="A" goto H
if "%co%"=="B" goto B

H:
echo You look at your surrounding horizon
echo hoping to see a sign of civilization
echo you decide just to start walking
echo.
pause
cls
echo Do you A Head North or B Head East? A or B
set /p co="% %"
if "%co%"=="A" goto N
if "%co%"=="B" goto E

N:
echo You start walking North
echo after walking for about 5 hours
echo it starts to get dark
echo then suddenly you fall into a deep pit
echo.
pause
goto end


all help will be appreciated


So, what's going wrong with your FILE?TRY THIS
Code: [Select]@echo off

cls
echo Today you will begin you Quest...
echo.
pause
cls
echo The quest to find...
echo.
pause
cls
echo THE ULTIMATE CUPCAKE!!!
echo.
pause
cls
echo Not only is it the best tasting cupcake in the world but
echo it will also grant you the power to...
echo.
pause
cls
echo BECOME INVISIBLE!!! (for 3-11 seconds)
echo.
pause

cls
echo Do you want to Begin?
set co=
set /p co=Y or N:
if %co% equ Y goto 2
if %co% equ N goto end
if %co% equ y goto 2
if %co% equ n goto end

:2
cls
echo you wake up in a musty, dark, dank cave
echo you dont know how you got there
echo you feel as though someone is close to you
echo watching you...
echo.
pause
cls
echo Do you A Run to the Exit or B Pull out your Dagger?
set co=
set /p co=A or B:
if %co% equ A goto R
if %co% equ B goto D
if %co% equ a goto R
if %co% equ b goto D

:D
cls
echo You reach for your dagger
echo but in place of where you dagger should be
echo is some thing fleshy
echo.
pause

:end
cls
echo You Lost
echo.
pause
exit

:R
cls
echo You make a mad dash for the exit of the cave
echo but as you head into the sunlight and out of
echo the darkness, you look back for a second
echo and notice something glimmer inside of the cave.
cls
echo Do you A Go back inside or B Start trying to find your way home?
set co=
set /p co=A or B:
if %co% equ A goto H
if %co% equ B goto B
if %co% equ a goto H
if %co% equ b goto B

:H
cls
echo You look at your surrounding horizon
echo hoping to see a sign of civilization
echo you decide just to start walking
echo.
pause
cls
echo Do you A Head North or B Head East?
set co=
set /p co=A or B:
if %co% equ A goto N
if %co% equ B goto E
if %co% equ a goto N
if %co% equ b goto E

:N
cls
echo You start walking North
echo after walking for about 5 hours
echo it starts to get dark
echo then suddenly you fall into a deep pit
echo.
pause
goto endWhere is E supposed to take you in this part
Code: [Select]:H
cls
echo You look at your surrounding horizon
echo hoping to see a sign of civilization
echo you decide just to start walking
echo.
pause
cls
echo Do you A Head North or B Head East?
set co=
set /p co=A or B:
if %co% equ A goto N
if %co% equ B goto E
if %co% equ a goto N
if %co% equ b goto EThnx I'll try it stalor Yeah thnx stalor i got it now i'll post the game when i'm finished (probably in about a week)Quote from: stalor214 on January 27, 2009, 08:13:13 PM

TRY THIS
Code: [Select]echo Do you A Head North or B Head East?
set co=
set /p co=A or B:
if %co% equ A goto N
if %co% equ B goto E
if %co% equ a goto N
if %co% equ b goto E

Why not use the /I in the IF statements? /I makes it case it so it ignores case and thus you could use
Code: [Select]if /I %co% equ a goto N
if /I %co% equ b goto E

Which should still get you the same results as
Code: [Select]if %co% equ A goto N
if %co% equ B goto E
if %co% equ a goto N
if %co% equ b goto ESorry didnt think about that i was tired@echo off

cls
echo Today you will begin you Quest
echo The quest to find
echo The Ultimate Cupcake
echo Not only is it the best tasting cupcake in the world but
echo It will also grant you the power to
echo Become invisible (for 3-11 seconds)
echo.
pause

cls
echo Do you want to Begin?
set co=
set /p co=Y or N:
if %co% equ Y goto 2
if %co% equ N goto end
if %co% equ y goto 2
if %co% equ n goto end

:2
cls
echo you wake up in a musty, dark, dank cave
echo you dont know how you got there
echo you feel as though someone is close to you
echo watching you...
echo.
pause
cls
echo Do you A Run to the Exit or B Pull out your Dagger?
set co=
set /p co=A or B:
if %co% equ A goto R
if %co% equ B goto D
if %co% equ a goto R
if %co% equ b goto D


cls
echo You reach for your dagger
echo but in place of where you dagger should be
echo is some thing fleshy
echo It is a hand it grips you by the nape
echo Of your neck and hits you head against
echo The cave wall.
pause
goto end

:R
cls
echo You make a mad dash for the exit of the cave
echo but as you head into the sunlight and out of
echo the darkness, you look back for a second
echo and notice something glimmer inside of the cave.
echo.
pause
cls
echo Do you A Go back inside or B Start trying to find your way home?
set co=
set /p co=A or B:
if %co% equ A goto B
if %co% equ B goto H
if %co% equ a goto B
if %co% equ b goto H

:H
cls
echo You look at your surrounding horizon
echo Hoping to see a sign of civilization
echo You decide just to start walking
echo.
pause
cls
echo Do you A Head North or B Head East?
set co=
set /p co=A or B:
if %co% equ A goto N
if %co% equ B goto E
if %co% equ a goto N
if %co% equ b goto E

:N
cls
echo You start walking North,
echo After walking for about 5 hours
echo It starts to get dark
echo Then suddenly you fall into a deep pit
echo.
pause
goto end

:B
cls
echo You slowly walk back inside
echo As you continue walking you see
echo The glimmer again
echo You slowly creep towards it
echo As you get closer you hear
echo Breathing.
echo.
pause
echo Do you A Run out of the cave or B stand still?
set co=
set /p co=A or B:
if %co% equ A goto R
if %co% equ B goto S1
if %co% equ a goto R
if %co% equ b goto S1

:S1
cls
echo You continue walking for many hours until
echo You think you can see your Hut on the horizon
echo You start running
echo As you enter the hut you realize it isn't yours
echo And the inhabitants of the hut don't seem
echo Friendly.
echo.
pause
goto end


:E
cls
echo You head East for about 4 hours
echo You can see that it is starting to get dark
echo.
pause
cls
echo Do you A Setup camp or B Continue walking?
set co=
set /p co=A or B:
if %co% equ A goto R
if %co% equ B goto S1
if %co% equ a goto R
if %co% equ b goto S1
echo

:R
cls
echo You find a nice shaded spot in the trees
echo You build a tepee type house
echo Out of dead branches
echo And spanish moss for insulation.
echo You finish your temporary home
echo Just in time it has become completely
echo Dark you crawly into your tepee and go to
echo Sleep.
echo ...
echo ...
echo You wake up fealing refreshed
echo.
pause
cls
echo Do you A Look for food or B Continue walking?
set co=
set /p co=A or B:
if %co% equ A goto F1
if %co% equ B goto B1
if %co% equ a goto F1
if %co% equ b goto B1
echo

:B1
cls
echo Do you A Go East or B Go West?
set co=
set /p co=A or B:
if %co% equ A goto S1
if %co% equ B goto B3
if %co% equ a goto S1
if %co% equ b goto B3
echo

:B3
cls
echo You continue walking Westward
echo You come across a Castle
echo It has Large life-like stone
echo GARGOYLES gaurding it
echo.
pause
cls
echo Do you A Go Inside or B Continue walking Westward?
set co=
set /p co=A or B:
if %co% equ A goto Win
if %co% equ B goto S1
if %co% equ a goto Win
if %co% equ b goto S1
echo

:Win
cls
echo You walk inside and see the
echo Ultimate Cupcake on a pedistool
echo You eat it!
echo.
pause
goto Y

:Y
cls
echo You Won!!!
echo.
pause
exit

:end
cls
echo You Lost
echo.
pause
exit

:F1
cls
echo As you go looking for food
echo You stumble upon a chest
echo As you open it you see a cupcake
echo "Could it bee the Ultimate Cupcake?"
echo You pick it up and see a sign on it
echo It says "Poison" surely a hoax
echo To keep people from eating it
echo You take a bite out of it.
echo.
pause
goto endGRATZ final refined VERSION:

color d
@echo off

REM"THE QUEST FOR THE ULTIMATE CUPCAKE"
CREATED BY: EMMANUEL LYKES
ALL RIGHTS RESERVED (NOT REALLY)

cls
echo Today you will begin your Quest
echo The quest to find
echo The Ultimate Cupcake
echo Not only is it the best tasting cupcake in the world but
echo It will also grant you the power to
echo Become invisible (Side effects may include death,
echo Explosion of bladder, loss of toes and/or fingers,
echo And sudden cravings for Maple Syrup)
echo.
pause

cls
echo Do you want to Begin?
set co=
set /p co=Y or N:
if %co% equ Y goto 2
if %co% equ N goto end
if %co% equ y goto 2
if %co% equ n goto end

:2
color d
cls
echo You wake up in a musty, dark, dank cave
echo You dont know how you got there
echo You feel as though someone is close to you
echo Watching you "Maybe it's that creepy
echo Girl at school who's been stalking me"
echo You think to yourself.
echo.
pause
cls
color d
echo Do you A Run to the Exit or B Pull out your Prison shank ?
set co=
set /p co=A or B:
if %co% equ A goto R1
if %co% equ B goto D
if %co% equ a goto R1
if %co% equ b goto D


cls
color d
echo You reach for your shank
echo But in place of where "Ol' shanky" should be
echo Is something furry,
echo It is the paw of the Crazy Giant Vampire Rabbit
echo It grips you by the nape
echo Of your neck and hits you head against
echo The cave wall.
echo You are the Rabbit's next meal
echo.
pause
goto end

:R1
cls
color d
echo You make a mad dash for the exit of the cave
echo But as you head into the sunlight and out of
echo The darkness, you look back for a second
echo And notice something move inside of the cave.
echo.
pause
cls
color d
echo Do you A Go back inside or B Start trying to find your way home?
set co=
set /p co=A or B:
if %co% equ A goto B
if %co% equ B goto H
if %co% equ a goto B
if %co% equ b goto H

:H
cls
color d
echo You look at your surrounding horizon
echo Hoping to see a sign of civilization
echo You decide just to start walking
echo.
pause
cls
color d
echo Do you A Head North or B Head East?
set co=
set /p co=A or B:
if %co% equ A goto N
if %co% equ B goto E
if %co% equ a goto N
if %co% equ b goto E

:N
cls
color d
echo You start walking North,
echo After walking for about 5 hours
echo It starts to get dark
echo Then suddenly you fall into a deep pit
echo Filled with steak so Sweet and
echo Savory you can't Help but eat them.
echo After about 46 (and a half) steaks you
echo Die of a heart-attack
echo.
pause
goto end

:B
cls
color d
echo You slowly walk back inside
echo As you continue walking you see
echo Something move again
echo You slowly creep TOWARD it
echo As you get closer you hear
echo Breathing.
echo.
pause
cls
color d
echo Do you A Run out of the cave or B Stand still?
set co=
set /p co=A or B:
if %co% equ A goto R1
if %co% equ B goto S2
if %co% equ a goto R1
if %co% equ b goto S2

:S1
cls
color d
echo You continue walking for many hours until
echo You think you can see your Hut on the horizon
echo You start running
echo As you enter the hut you realize it isn't yours
echo And the inhabitants (escaped Oompa Loompas)
echo Of the hut don't seem friendly
echo They violently shuv 23 pounds of fudge down you throat
echo Then they roast you and feed you to thier pet gummi bear.
echo.
pause
goto end


:E
cls
color d
echo You head East for about 4 hours
echo You can see that it is starting to get dark
echo.
pause
cls
color d
echo Do you A Setup camp or B Continue walking?
set co=
set /p co=A or B:
if %co% equ A goto R
if %co% equ B goto S1
if %co% equ a goto R
if %co% equ b goto S1
echo

:R
cls
color d
echo You find a nice shaded spot in the trees
echo You build a tepee type house
echo Out of dead branches
echo And old YMCA pamphlets for insulation.
echo You finish your temporary home
echo Just in time, it has become completely
echo Dark you crawl into your tepee and go to
echo Sleep.
echo ...
echo ...zzz
echo ...
echo You wake up feeling refreshed
echo.
pause
cls
color d
echo Do you A Look for food or B Continue walking?
set co=
set /p co=A or B:
if %co% equ A goto F1
if %co% equ B goto B1
if %co% equ a goto F1
if %co% equ b goto B1
echo

:B1
cls
color d
echo Do you A Go East or B Go West?
set co=
set /p co=A or B:
if %co% equ A goto S1
if %co% equ B goto B3
if %co% equ a goto S1
if %co% equ b goto B3
echo

:B3
cls
color d
echo You start walking Westward
echo You come across a castle shaped like
echo A giant Pikachu
echo.
pause
cls
color d
echo Do you A Go Inside or B Continue walking Westward?
set co=
set /p co=A or B:
if %co% equ A goto Win
if %co% equ B goto S1
if %co% equ a goto Win
if %co% equ b goto S1
echo

:Win
cls
color d
echo You walk inside and see the
echo Ultimate Cupcake on a pedistool
echo You eat it!
echo.
pause
goto Y

:Y
color a
cls
echo YOU WON!!!
echo.
pause
exit

:end
color c
cls
echo You Lost
echo.
pause
exit

:F1
cls
color d
echo As you go looking for food
echo You stumble upon a chest
echo As you open it you see a cupcake
echo "Could it be the Ultimate Cupcake?"
echo You pick it up and see a sign on it
echo It says "MADE OUT OF CRACK IF
echo YOU SNORT IT YOU WILL O.D." surely a hoax
echo To keep people from snorting it
echo You happily snort it up!
echo.
pause
goto end

:S2
cls
color d
echo You stand still hoping that whatever was breathing
echo Went away
echo You hear a loud crack behind you
echo "Oh no it's Brittany Spears armed with
echo A baby" She hits you repeatedly on the head with
echo The baby until you are dead.
echo.
pause
goto end
2730.

Solve : password recovery?

Answer»

help ive forgotten my password to my website and i cant log on and the password recovery system is not working is there another way such as a PEICE of code or a website that can help please reply We don't give password recovery help on here. Sorry.
ask the web masterthe funny thing is i am the admin of the siteQuote from: steven32collins on December 02, 2008, 11:50:06 AM

the funny thing is i am the admin of the site

Well then, shame on you.
Quote from: steven32collins on December 02, 2008, 11:50:06 AM
the funny thing is i am the admin of the site

Interesting...we haven't heard this one before.

And no...it's not funny.Quote from: patio on December 02, 2008, 01:52:02 PM
Quote from: steven32collins on December 02, 2008, 11:50:06 AM
the funny thing is i am the admin of the site

Interesting...we haven't heard this one before.

And no...it's not funny.

I'm telling you! It definitely IS my laptop! My 6 month old baby reset the BIOS password! The cat helped her!

"Right after i spilled coffee on the keyboard..."ask the one who writes the codesThere are some BIOS password recovery programs. I'm a BIT leery about downloading unknown programs, as I had nasty experiences with a trojan stuck in my system restore...Quote from: qwah! on December 05, 2008, 04:58:58 PM
There are some BIOS password recovery programs. I'm a bit leery about downloading unknown programs, as I had nasty experiences with a trojan stuck in my system restore...

How is a BIOS password recovery program going to enable him to login to a website he can't remember the password for ? ?As far as BIOS passwords are concerned, they provide no security since you can just remove the battery.


i have finaly reset my ACCOUNT what i had to do is get my freind to log onto the admin cp and find my account delete it then i had to make it again (i could not change the password from someone elses acount (it has password comfermation it asked for my old one) after i made a new one and had to make it root admin again so i got it working againI'm not convinced this would EVEN work...but good to hear.
2731.

Solve : Get only the date?

Answer»

BFC, what part of "we don't do peoples school assignments for them" don't you understand?Code: [Select]|date |find >> Date.txt
Quote from: BatchRocks on January 31, 2009, 05:56:56 PM

Code: [Select]|date |find >> Date.txt


Batchrocks, could you explain that code please? (Have you tested it?)

Quote
We try not to HELP with homework. If this is what you are after, please at least be honest and don't try to hide the purpose for the QUESTION. HONESTY sometimes gets results!
Source

17 posts and no solution. Hmmm, I suggest a compromise. The script below uses Win98 BATCH language. It produces the correct RESULT in WinXP but not Win98. After dissecting the code to see how it runs, you should be able to produce the correct result in Win98.

Code: [Select]@echo off
ver | date > temp.bat
echo set dt=%%5>the.bat
call temp.bat
del temp.bat
del the.bat
echo %dt%

Hint: 3 changes to the code must be made to run correctly in Win98.

Good luck. An excellent solution, Sidewinder!
I got it to work on my old computer .
2732.

Solve : creating directory in DOS?

Answer»

hello,

I have a problem with creating a directory in DOS.
I can't create a directory with the form:
"274oct012009thursday" where :
274-is a random number
oct012009 -date
thursday-day
tomorrow the directory will look like:
"275oct022009friday"

Can you help me in this problem? TnxCan you please post your code so we can see why the rand() is malfunctioning maybe? Interesting that it appears to ++ the 274 to 275

Most common issue I have seen with concatinating the info into a single folder name / directory is that you end up with ....\274\oct\01\2009\ where274 BECOMES a directory and the date a series of subdirectories there of.
this code:"

Set FDate=%Date:~-10,10%
Set Fdate=%FDate:/=%

MD d:\users\doru\DOS\%FDate%"

will made a directory with the name:10012009,

but I would like to display 274oct012009thursday.
for tomorrow will display 275oct022009friday, 276oct032009saturday etc



In the following script it is assumed that:
1. The 'random' number to which you refer is in fact a sequential number.
2. The number sequence will commence with 001.
3. All sub-directories of the directory d:\users\doru\dos\ will have been created by the script.
4. Your date is in the format 'day mm/dd/yyyy' eg Fri 10/02/2009 (although the separator / might be another permitted CHARACTER).

The script is untested.

Code: [Select]@echo off
cls
setlocal

:: Set day and YEAR...
set ddyyyy=%date:~7,2%%date:~-4%

:: Convert short day name to long day name...
set day=%date:~0,3%
if /I %day:~0,1% equ M set day=Monday && goto month
if /I %day:~0,1% equ T if /I %day% equ Tue (
set day=Tuesday && goto month
) else (
set day=Thursday && goto month
)
if /I %day:~0,1% equ W set day=Wednesday && goto month
if /I %day:~0,1% equ F set day=Friday && goto month
if /I %day:~0,1% equ S if /I %day% equ Sat (
set day=Saturday
) else (
set day=Sunday
)

:: Convert month number to alpha month....
:month
set month=%date:~4,2%

:: Remove leading zero if it exists...
set /a month=100%month% %% 100

set monthalpha=Jan Feb Mar Apl May Jun Jul Aug Sep Oct Nov Dec

for /f "TOKENS=%month%" %%# in ("%monthalpha%") do (
set month=%%#
)

:: Get next sequential number...
pushd d:\users\doru\dos\ || Echo PUSHD failed job terminated && exit /b

:: After the directory 001* has been created the following line can be removed
:: and directory 000* deleted.

if not exist 000*\ md 000DummyDirectory
for /f "delims=" %%# in ('dir /ad /b /o-n') do (
set lastdir=%%# & goto makedir
)

:: Make new directory...
:makedir
set lastdir=%lastdir:~0,3%

:: Remove leading zeroes if they exist...
:loop
if %lastdir% gtr 0 if %lastdir:~0,1% equ 0 (
set lastdir=%lastdir:~1%
goto loop
)

set /a nextseqnbr=%lastdir%+1

:: Replace leading zeroes...
if %nextseqnbr% lss 10 set nextseqnbr=00%nextseqnbr%
if %nextseqnbr% gtr 10 if %nextseqnbr% lss 100 set nextseqnbr=0%nextseqnbr%

:: md %nextseqnbr%%month%%ddyyyy%%day%

echo New directory to be created = %nextseqnbr%%month%%ddyyyy%%day%

popd
exit /b

the script is interesting but it's not workingYou'll have to be a lot more specific than that. "Not Working" could mean anything from CRASHING on the first command to Pushd failing, to creating the required directory but the date is wrong.

Are there any error messages displayed, have you tried REMing out @echo off to display a listing as the script progresses? Can you determine at what point the script fails?

[Edit] Further thought... Is the 'random/sequential' number the day number in the year? e.g. Oct 3rd 2009 is day number 276 of 2009.

2733.

Solve : directory name=date and hour??

Answer»

Hi

Newbie, its late and I'm tired. Need help.
In a batch file: I wanna make a directory with the NAME = "date and hour" (yyyy-mm-dd-hour). For example:

2009-02-01-04

Don't know how to get the hour in a variable (with the date).

In xp pro.Hmm...

This spits out the date and time:


CODE: [Select]@echo off
time /t >> T.txt
date /t >> T.txt
exit
It makes it into a new file, named T.txt.Mumin - Welcome to the CH forums.

Try this:
Code: [Select]
@echo off
cls
set datime=%date%-%time:~0,2%

echo %datime%

Good luckManipulating the date and time environment variables is dependent on your Windows regional settings ... but for the U.S. English DEFAULT settings for Windows XP, you can use:
Code: [Select]md "%date:~-4%-%date:~-10,2%-%date:~-7,2%-%time:~0,2%"
And I guess you would want to substitute the space with a 0 (when the hour is less than 10) like:
Code: [Select]set DateHr=%date:~-4%-%date:~-10,2%-%date:~-7,2%-%time:~0,2%
md "%DateHr: =0%"Thanks all, that did the trick. Nice response. It's a batch file to make sorting and STUFF easier/quicker managing photos from my camera.

2734.

Solve : Storing command results in a variable.?

Answer»

Lets SAY I TYPE in

CODE: [Select]var

and it gives me

Code: [Select]Microsoft Windows [Version 6.0.6001]

Now how would I store that in a variable? Or is it
that you can't store that in a variable.
I've tried everything and I'm stuck with this. redirect to a file and read that file into a variable using for?FOR

Code: [Select]@echo off
cls

for /f "delims=*" %%A in ('ver') do (
set something=%%A
)

echo Version = %something%
I was close. I GOT the for part right! Then I can just delete that file.. That works perfectly!

2735.

Solve : using usb jump drive in a msdos-only os?

Answer»

Is there a way to set up msdos to recognize a USB jump drive to store files as on an a: drive?

dell 3Ghz syst msdos only I don't KNOW if this will be a help, might be worth a looksee here..

Good luckThanks for the INFO - I tried that a couple of years ago and just couldn't get it to work right. I was hoping something else might have come along.

Thanks anyway.Quote

was hoping something else might have come along

Well, yeah. Adter the Days of DOS lots of things came along so that upgrading DOS was not worth the effort. Now we have more HARDWARE and more FREE software than before.
We have other kins of flash drives. You could get card READER that will work in a MS DOS machine. Not a USB device, but a flash card reader.

And why do you HAVE to use DOS? There are free OS that can do the job. Does the system have a Hard Drive? Does it have a CD-Drive?

Is this a old system with only a floppy and a couple of USB ports?
I'm using it on a ~3Ghz dell to collect data via a qbasic pgm. The system was wiped clean of the xp os and just left with dos 7, which works fine for what I need. If I loaded a win os (98 and >) I could easily run my pgm in a dos shell and switch to win to xfer data to jump drive. Is there a freeware windows substitute out there? Or something that would accomplish the same thing? (linux?)

Thanks!Puppy Linux is very small and boots fast. You put it on a CD, boot it, mount and read your USB and copy the files to the DOS drive. Then reboot back into DOS.
Get a ISO CD image of Puppy at:
http://www.puppylinux.org/
Anything here of use:

http://www.theinquirer.net/inquirer/news/069/1046069/yes-there-are-usb-drivers-for-dosQuote from: Geek-9pm on January 31, 2009, 09:34:35 AM
Puppy Linux is very small and boots fast. You put it on a CD, boot it, mount and read your USB and copy the files to the DOS drive. Then reboot back into DOS.



will it load as freestanding os on my HD ? don't have a cd rom
I have got a bootable MS-DOS 7 pen drive which has QBasic. It is FAT formatted and it is a breeze to copy files onto it and boot the PC from it.
Quote from: Dias de verano on January 31, 2009, 02:19:12 PM
I have got a bootable MS-DOS 7 pen drive which has QBasic. It is FAT formatted and it is a breeze to copy files onto it and boot the PC from it.

Outstanding! Er, is a pen drive a jump drive? If it is I can just run everything on it and data xfer is no issue.
Where did you find it?
Quote from: wkmacc on January 31, 2009, 02:39:32 PM
Outstanding! Er, is a pen drive a jump drive?

"JumpDrive" is what Lexar call their USB flash drives. It is a brand. Names in common use for these drives are "memory stick", "key drive", "USB key, "pen drive", etc.

They look like this



Quote
Where did you find it?

I just bought a 128 MB flash drive (about 5 years ago), and using instructions very widely available on the Web, I made it bootable.

This is as good a place as any to start.

http://www.bootdisk.com/pendrive.htm

The method I used involved using the HP utility mentioned on that page.







Quote
will it load as freestanding os on my HD ? don't have a cd rom

You have to borrow a CD Drive from sombody.
Or have then write it to a HHD for you
Here is the tutorial.

http://www.puppylinux.org/wiki/installation/hdd-full-installation

2736.

Solve : Suppress the black DOS screen when running a batch file?

Answer»

My clients are running Window XP.

I have to put a batch in the allusers startup folder. When my users login, a black DOS screen pops up and RUNS the file. The PROBLEM is some "smart" users decide to click the x and exit out of the script before it finishes. LATER on they will complain that things don't work.

Is there a way to suppress this black DOS screen from showing up when it's running?

Thanks.You could download this file cmdow.exe , place it in system32 folder and begin your batch script with the line
cmdow @ /HID
Run the script with Code: [Select]start /min and the batch file will run minimized.

FBfb, like the TS said, some SMART people are clicking the X. If they're smart enough to do that, they're smart enough to restore a window. Just use the bat2exe.exe program available in the utilities.So you want a batch file to run in the background. Good way of getting people to tell you how to do it. If you said you want to run a batch file in the background, people wouldn't have told you in the first place.Well, the start /min seemed to do the trick but it leaves the dos screen minimized after the script is completed successfully.

Anyway to exit out after it's done?

Thanks.To exit the batch file type 'exit' as the LAST line.

FBWhat does your batch exactly do at start up that would make the users want to exit it? ( Guessing it has some sort of restrictive function ) ( "Maybe there is a better solution we can provide through Group Policy etc" )DUDE. When a black screen that could possibly Trojan pops up. You want to exit it.

2737.

Solve : MS SQL data to text file??

Answer»

is it possible to convert a mssql data to a text file using a batch file?Are you referring to MS Access or MS SQL Server? Access has a built in export facility on the file menu. With SQL Server you will need to write your own program or perhaps a script that can connect to the database.

This may help

Good luck. Thanks... Do you know how to write the script to connect to MS SQL server?Quote

Do you know how to write the script to connect to MS SQL server?

In order to keep down the embarrassment level, I have LEARNED not to post when there are too many variables to come to a clear solution. On the other HAND, some seemingly simple QUESTIONS have morphed into complex entities that required actual <gasp> research.

Let hope this won't come to that.

The easiest way to connect to SQL Server is using ActiveX Data Objects (ADO). Which VERSION of SQL Server are you using and what is the server name? The key to accessing a database is the connection string. The more information about your database you can provide, the easier it will be to write a script.



An earlier response provided a link. Any reason it was not helpful?
2738.

Solve : Looking for all %% calls listing?

Answer»

I was wondering is anyone knew of a site that shows all % % system calls. GOOGLE search for batches %% calls shows tons of Phone Call info but no system call info.

I am looking for a list that shows %date% , %time% , and all others available to use for DOS Batches for both OLDER DOS as well as Windows % % system calls from command line. Saw a reference to %processor_architecture% in someone elses post here regarding and autorun issue and that sparked my interest to see if I can find a list of all DOS/Windows % % calls.

ThanksType SET at the command prompt. And by the way, they are VARIABLES (short-formed to VAR), not calls. Extracted from SET/? in Win XP.
Quote

If Command Extensions are enabled, then there are several dynamic
environment variables that can be expanded but which don't show up in
the list of variables displayed by SET.
These variable values are
computed dynamically each time the value of the variable is expanded.
If the user explicitly defines a variable with one of these names, then
that definition will override the dynamic one described below:

%CD% - expands to the current directory string.

%DATE% - expands to current date using same format as DATE command.

%TIME% - expands to current time using same format as TIME command.

%RANDOM% - expands to a random decimal number between 0 and 32767.

%ERRORLEVEL% - expands to the current ERRORLEVEL value

%CMDEXTVERSION% - expands to the current Command Processor Extensions
version number.

%CMDCMDLINE% - expands to the original command line that invoked the
Command Processor.


More info here....

This site claims to have a full listing of system information variables.

Hope this helps.

There's something wrong with their definion of %random%. It doesn't expand to a decimal, it expands to an integers. Point taken.

Here's a Wiki...

Quote from: Helpmeh on October 01, 2009, 04:30:40 PM
There's something wrong with their definion of %random%. It doesn't expand to a decimal, it expands to an integers.

"Decimal" means base-10.Quote from: BC_Programmer on October 01, 2009, 06:56:46 PM
"Decimal" means base-10.
Ok. I thought decimal is the little . after the one's digit.

And %random% does expand to an integer. How many times does it take before an un-modified %random% expands to a number with a decimal (that is not 0 you sneaky goose). It always does. the number is base-10.

it would be completely useless if the %RANDOM% variable EVER game back a floating point number since you can't process them with set /a.


Decimal; "dec" means 10.

hexadecimal: hex (6)+ dec(10) = 16 (0...9, A...F).

One can even "invent" bases using the standard prefixes.

base 18? Probably Octadecimal. base 8? Octal.

an Integer cannot have a fractional portion but a floating-point number can be an integer.Hey Cool,

Thanks for info...so they are reserved variable names then I am guessing?

That would be why google had no hits for me...wrong statement..lol

Many thanks to all who CONTRIBUTED info on this.

Dave
2739.

Solve : Basic Batch File?

Answer»

I have no clue about MS DOS commands or Creating Batch FILES.

I'm looking for a simple batch file which when executed, copies the contents of the folder that it resides in, into a destination folder that I specify in the code. Also, creates a desktop and a start menu shortcut of one of the files.

Thanks in advance.

Regards,
Kalyan VermaI would PLACE the batch outside the folder to be copied otherwise it is trying to COPY itself elsewhere too.

xcopy "c:\foldertobecopied\*.*" "E:\datadestinationfolder\*.*" /s/d/y

This can be used if copying to an external hard drive or thumb drive at drive E to folder NAMED datadestinationfolder. You simply change the path in foldertobecopied and datadestinationfolder to your actual path. "" will be needed if spaces are present in the path such as MY DATA etc. Switches /s/d/y are used to copy latest info if you are going to use for updating edited files at the destination from the source as well as maintains the directory tree associated with the files and agrees to overwriting already existing files and folders if present.

Desktop shortcut can be created by using the Windows Shortcut maker and manually placing the file path in there, then add it to ALL USERS in c:\documents and SETTINGS\ or just your profile in the desktop folder as a *.lnk shortcut file if you just want your profile to have it on your desktop instead of all users.

Hope this helps

Quote from: kalyanverma on September 30, 2009, 12:33:52 PM

I have no clue about MS DOS commands or Creating Batch Files.
if you have no clue, start to do some reading by yourself. see wiki and the part where it says external links.
2740.

Solve : doskey macros?

Answer»

Could someone give me an EXAMPLE of how to use $* in a command line...

I'm looking at a book that explains it's definition, but I still don't get it $* ACTS as a placeholder for additional parameters:

e.g. Quote

doskey d=dir /o-n
will list the directory in reverse alpha order but you cannot add any further parameters at execution TIME. If, at the command prompt, you enter Quote
d /b
the /b parameter will be ignored and a FULL listing in reverse alpha order will be produced.

However, Quote
doskey d=dir /o-n $*
will allow further parameters to be added so that Quote
d /b
will PRODUCE a listing in reverse order in bare format.

Heaps more info here...

thank you sir You're welcome..
2741.

Solve : Finding the Identities GUID?

Answer»

Hi i'm trying to make a batch file to find the unique GUID of an account in windows xp.
I'm able to use reg query and finstr to get a txt file with this :

Default User IDREG_SZ{30D58BD6-739C-4333-9AA4-8A8B3CCEC613}

How can i extract the GUID {30D58BD6-739C-4333-9AA4-8A8B3CCEC613} from this text file?
Thank youWithout knowing the exact reg and findstr instructions you used, we can only offer a generic ANSWER:

Code: [Select]@echo off
for /f "tokens=5" %%i in (reg query ... | findstr ...) do echo %%i

By wrapping your instructions in a for instruction, you should be able to parse out the GUID which is the 5th token in Default User ID REG_SZ {30D58BD6-739C-4333-9AA4-8A8B3CCEC613}

Good LUCK.

Be SURE to replace the ... with actual values.Hi thank you for the reply.
I'm not so good in batch scripting so i tried to use your suggestion with this:
Code: [Select]for /f "tokens=5" %%i in ('reg query HKCU\Identities\|findstr /C:" Default User ID"') do echo %%iBut the result is | not expected
What is the problem?
If i use the pipe with this
Code: [Select]reg query HKCU\Identities\|findstr /C:" Default User ID">example.txtit works....
I'm confused

inside the for loop it must be "^|"

Code: [Select]for /f "tokens=5" %%i in ('reg query HKCU\Identities\ ^|findstr /C:" Default User ID"') do echo %%i
FBThank you all, it works.
Can someone drive me to some web resources to learn how to use dos commands?
Using the explanation of cmd is useful but without examples it is DIFFICULT to understand.
For example why do i have to use %%i in batch files but if i use it directly in the commnad window i have to use %i ?I'm trying to edit the windows registry with this cmd file:
Code: [Select]@for /f "tokens=5" %%i in ('reg query HKCU\Identities\^|findstr /C:" Default User ID"') do @set guid=%%i
reg add HKEY_CURRENT_USER\Identities\%guid%\Software\Microsoft\Outlook Express\5.0 /v Launch Inbox /t REG_DWORD /d 0 /fBut when i launch the .cmd files it says :

Error: too many parameters from command line

Solved: sorry for being a newbie : keys with spaces NEED ""

Thank you all

2742.

Solve : Need Help with LAME batch processing?

Answer»

I just needed HELP with batch processing of lame (it works in DOS)
Firstly i encode WAV files to MP3 with LAME XP (it is GUI for lame)

i decode mp3 files to wav by the following command line
in batch file

mkdir
FOR %%a in (*.mp3) DO lame --decode "%%a" "%%a"
cd
ren *.mp3 *.wav


Problem is "it decodes the audio ONLY in the directory in which this batch file exists"

Hence i want a command line which would decode all audio files FROM ALL THE SUBDIRECTORIES INSIDE THE FOLDER

could sumbuddy pls help me
Ok.

@echo off
For /F "tokens=1,2 delims=." %%a in ('dir /b /s *.mp3') do (
Lame --decode "%%a.%%b" "%%a.%%b"
Ren "%%a.%%b" "%%a.wav"
)Means how could i describe!!!!!!!!!!

In simple words

i convert WAV to MP3 with Lamexp
and then PACK them with 7zip

now if i shared this 7zip with my brothers pc

and i WANTED it to decode again (in ma brothers pc,, )(mp3 to wav) then what would the command line shld b

If i packed it in Drive D

and if my brother unpacked it in E Drive
then what shld b d command line

(mkdir
FOR %%a in (*.mp3) DO lame --decode "%%a" "%%a"
cd
ren *.mp3 *.wav)

2743.

Solve : disk read error.....press ctrl+alt+del to restart?

Answer»

hi,
PLEASE i need help.i have an HP COMPAQ nx6110 with windows xp sp2 installed and led on it but of LATE when i start the SYSTEM ,the HP logo is displayed and afterwards, it writes 'disk read error' and then ask me to press ctrl+alt+delete to re startbut if i FOLLOW the instruction given,it comes back to the same error message.please i need help.thanksDo you have the Windows CD?

2744.

Solve : Is it possible to my batch file always on top??

Answer»

I've created a simple batch FILE and would like my batch file to be always on top of all other WINDOWS. Is this possible?

thanksNo. However, if you use some AutoIt script you could probably do SOMETHING like that. But there's no simple method.http://www.fadsoft.net/AlwaysOnTopMaker.htm I used to use this before i found one of my other apps has that ability. My CURRENT one doesn't recognise cmd/batch windows though Don't REMEMBER if this one does.

FB

2745.

Solve : Antivirus is Soluation of Virus ????

Answer»
HI, all are useing antivirus SOFTWARE but STILL virus is load and we format the SYSTEM so what is the roll of antivirus.

with antivirus our system's 40% to 50% RAM useing on that process our computer going slow down.

so i ask you to all antivirus is soluation or just a ?
2746.

Solve : Reply problem?

Answer»

I want to add a reply to this topic but the Reply, Notify, Send Topic and Print buttons are hidden when the page completes loading. The buttons are displayed on other topics. Any ideas what I'm doing WRONG PLEASE?

ThanksThat thread is long and worn.
Why not start a new topic?
How about:
'Simple Date and TIME functions in a BATCH file.'
Code: [Select]REM Wake-Up.bat
@Echo Hello, today is %DATE%.
@echo Ribgt now the time is %TIME%. Check to see if you took your pills.
beep
The time isn't very useful THOUGH. It brings up a bunch of numbers using navy time.LOL @ calling it "navy time"17:37:33.00

That's what it gives me. I am looking more for a 5:38 pm.Quote from: BatchFileCommand on January 28, 2009, 04:38:04 PM

17:37:33.00

That's what it gives me. I am looking more for a 5:38 pm.

Then change your date format in CP>Regional & Language Options>Customise>Time

That's XP....

Still doesn't solve my problem of not being able to Reply to one Topic out of the many.Quote from: BC_Programmer on January 28, 2009, 04:20:49 PM
LOL @ calling it "navy time"

makes a change from "military time"... these Yanks... ... Where I am it's called "normal time"....
Dias - I wanted to thank you in-topic for your response to my query here but for some obscure reason or reasons I cannot do so and I note you do not appreciate PMs about FORUM topics. So, out of topic, a big thank you for your excellent scripts.

H..Hedonist - glad I was able to help - I have sent you a PM.
2747.

Solve : change alpha by one value?

Answer»

I have a script that TAKES the date and CREATES a directory named yyyymmdd daily.
Works great but after I create directory I WANT move files from toady into yesterday's direcotry.

Such that today 29 Sept I will move files into the directory 20090928 then tommorow 30 Sept I will move files into directory 20090929.

I am trying to DECREMENT the DD in my program but not having any luck. Anyown have any ideas?
Regards,
DH
Please show your code so far.

2748.

Solve : How do you use concatenate in batch file??

Answer»

The user enters in the command line: ADOBE, macromedia, whatever

Is it possible to concatenate the string that is hard code in the batch file with the user input.

i.e. START program.adobe

I would like to start the application, using START command. The word "program" is hard code in my batch file. Now adobe is what the user input.

How do combine the program.adobe as one string.

Any comments is always welcome and appreciated. thanksCode: [Select]set /p run=what do you want to run?
start program.%run%
like that? why do you want to have program before the executable to run anyway?

FBthis works perfectly. thank you.

At work, I USE a program that's able to ACCESS different servers. So I would TYPE serverName.blah.blah.com, the blah.blah.com is always the same and must be entered, when I need to access the servers. Only serverName is different. So me being lazy, I only type in serverName and the blah.blah.com is concatenate into serverName and VOILA!

thanks

2749.

Solve : how i can kill proposes services?

Answer»

I am using Xp Pro sp3
how i can kill proposes services (Windows Security CENTER SERVICE) by batch without restart THe commnd is like that

Code: [Select] taskkill /im rundll32.exe /f
That's end the windows security center Process...

NOte: IF Open Some other control panel Appl. process like IE propertis page or eny other it also colse with this command.There are many things that use rundll32.exe , so don't just tskill it. somebody wants to force the windows security service to close...

does this not raise a red flag for anybody so far?It raises the red banner. The flag requires a bit more strength to hoist up.Quote from: Carbon Dudeoxide on SEPTEMBER 26, 2009, 10:10:37 AM

It raises the red banner. The flag requires a bit more strength to hoist up.
and a strong wind. There's always plenty of that here.... Quote from: patio on September 26, 2009, 10:22:59 AM
There's always plenty of that here....

I went to a Lebanese restaurant last night and had koftes...

I am so sorry for the wrong language
i typed wrong

Of right

how i can kill processes services


&AMP;

i fhnd from friend

Code: [Select]
well what do you mean

if you mean the service in the task manger beside the process

then i think i have a small tool that can do that

http://www.dynawell....2000/netsvc.zip

when you want to do something

you will need to use this commands

"""netsvc \\%computername% /LIST << this will list the Service"""



"""netsvc \\%computername% /stop "Service name" << this will Stop the Service""""



to start replace stop with start


Edit:

found another way using internal tool

"""sc stop "Service name" << that will stop the service"""



and to start type start

thx for help to all
2750.

Solve : A log, that makes a folder.?

Answer»

Hello!

Simple 'LOG' .bat file:

Code: [Select]@echo off
color A3
echo @echo off >>T.bat
echo echo Hi >>T.bat
echo echo This is a test >>T.bat
echo pause >>T.bat
echo EXIT >>T.bat
pause
exit
So it makes a batch file that says
Hi
This is a test

But, can you MAKE a log using >> that makes a folder, and when it creates that folder, make a file IN it?

Thanks...

BR

EDIT: I have it to make a file, then that file makes a directory, then the file moves itself into the directory. Is there a way that it duplicates the file, THEN moves it to a dir?You would just add this

Code: [Select]echo echo mkdir folder >> T.bat
call T.bat
move file folder

That will create a folder command in the batch file. Then it calls that batch file (which will create the folder), then it will go BACK to this and move the file into the folder.
Quote from: BatchFileCommand on January 29, 2009, 06:24:30 AM

You would just add this

Code: [Select]echo echo mkdir folder >> T.bat
call T.bat
move file folder

That will create a folder command in the batch file. Then it calls that batch file (which will create the folder), then it will go back to this and move the file into the folder.


This only does make a file, T.bat, then doesn't make a folder, and, it doesn't call it.

EDIT: Now, it makes the T.bat and then it makes a folder, folder, and then it moves T.bat inside the folder.

Code: [Select]@echo off
echo mkdir folder >> T.bat
call T.bat
move T.bat folderOh, I assumed you knew to put the name of the file where I put file.