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.
| 651. |
Solve : How Use Errorlevel Handler? |
|
Answer» I have scripts which has many DOS copy / xcopy / move statements. I do not want to code if %ERRORLEVEL% after each statement which is completely inefficient, anyone have thoughts for the best way in handling this? I do not want to code if %ERRORLEVEL% after each statement which is completely inefficient Do you want to abort the script if a copy statement threw an error ? What do you mean "inefficient"? I want it to continue onward, eg., execute copy1 then call the errorhandler, then return to execute copy2,..... copy1 call errorhandler # will always return to the next stmt whether there is an error or not copy2 call errohandler # will always return to the next stmt whether there is an error or not ..... copyN So the errorhandler will write a message to a log file and then return? What message? Will the errorhandler do ANYTHING else? Why do you think you need to "call" the error handler? You see, I don't understand why you think this... Code: [SELECT]copy command1 call :errorhandler %errorlevel% copy command 2 call :errorhandler %errorlevel% ... copy command N call :errorhandler %errorlevel% goto end :errorhandler if %1 gtr 0 echo %date% %time% Copy error happened! >> error.log goto :eof :end echo script finished is more efficient than this: Code: [Select]copy command1 if %errorlevel% gtr 0 echo %date% %time% Copy error happened! >> error.log copy command 2 if %errorlevel% gtr 0 echo %date% %time% Copy error happened! >> error.log ... copy command N if %errorlevel% gtr 0 echo %date% %time% Copy error happened! >> error.log echo script finished When running a batch script that has copy | xcopy | move, it is possible to be unaware of an error not until someone tells you they are missing a file. You are correct that the error handler probably is not more efficient especially if I just want to OUTPUT that there was an error encountered since I am not zeroing in on a particular error code. It's always good to get others ideas.... Thanks Salmon Trust. I do not recall, what would the errorlevel be for the following: copy path1\file path2\file >> /tmp/log.txt 2>&1 if %errorlevel% gtr 0 echo %date% %time% Copy error happened! >> error.log the ">>" is just to capture the resultant output from the copy | move | xcopy command... if the copy failed, but the ">>" was successful, what would the errorlevel be set to? if the copy was successful, but the ">>" to a file failed, what would errorlevel be set to? |
|
| 652. |
Solve : Sample of an If statement, comparing two variables . . .? |
|
Answer» I'm used to using the PL SQL if-then-else CONCEPT, so this is really frustrating me. I've found some examples, but evidently I'm doing something wrong, because when I add my if statement to the code, the file just bombs out and can't even capture what the error is. Anyway, can someone show me a good example of an If statement, comparing two variables? |
|
| 653. |
Solve : First time batcher needing help.? |
|
Answer» First let me appologise if this has been covered somewhere. i did look, but its hard to find something when you dont know the words you need Is there a way to put into a batch file code that will seek the location of the folders you wish to modify.I honestly don't know how to help unless you give me a little more information. Are you wanting explorer to open up to the file location? Are you wanting a batch to perform some tasks on the files within the folder? What modification are you looking to perform? BTW, these commands will work equally well on all listed OS's.Sorry i should have explained what the entire job of the batch file is. this is just an expresion of intent as i dont know batch language very well at all. 1. find install location. 2. create back up folder 3. move files from installed/subdir to install/subdir/backup 4. copy new files from /modinstall folders to installed/subdir 5. run /installed/file.exe 6. wait for file.exe to terminate 7. delete files(that we copied) from installed/subdir 8. restore files from /installed/subdir/backup to /installed/subdir It will be fairly simple i think to do most of that, but in order for the whole thing to work, the batch file needs to be able to locate /installed or the entire script is for nothing.would just like to point out, im only asking for help with step 1, the rest i want to try myself, but i wouldnt know where to begin on step 1Okay, this gets a little tricky, because the location could be quite variable as far as where in the subdir the actual files you are trying to modify are located. If you are willing to do a little preliminary work, I can help you with a simple batch that will get the location. Let me know if you would like to do that, or if you are wanting ONE that will find what you are looking for WITHOUT prelim work.im willing to do whatever it takes to get this thing working. the main thing is that the user recieving my files doesnt have to do anything except run the bat (and maybe type in their install location if it cant be auto DETECTED) basicly the point of this bat is to make something that is complicated quite simple for them. can we use the file.exe as the anchor? its in the top directory of everything that needs to be modified.If you are looking for the "file.exe", then it becomes easy, so long as it is a unique name. Code: [Select]echo off cd ..\..\..\..\..\..\..\..\..\..\ for /f %%A in ('dir /s /b "file.exe" ') do set location=%%~dpA Now if you are not certain if the "file.exe" will be unique (for example install.exe), then you just have to add a little more to ensure you grab the right one. Code: [Select]echo off cd ..\..\..\..\..\..\..\..\..\..\ for /f "delims=" %%A in ('dir /s /b "file.exe" ') do ( echo %%A | find "[Unique folder string]" if errorlevel 0 set location=%%~dpA ) Obviously you would need to substitute the [Unique folder string] with something that is unique to the name of the folder you are trying to get. After either of these, the location variable should hold the folder you are trying to grab. If you need any help with any of the additional steps, please let us know. Quote from: Raven19528 on November 14, 2011, 09:47:04 AM Most times, where you run your batch will not be more than 10 folders deep in the file structure, however you can add more onto the below if you think you need to. Put this before the dir to search the entire structure: Or just use \ to specify the root directory. Quote from: BC_Programmer on November 15, 2011, 11:01:30 AM Or just use \ to specify the root directory. Or that... Thank you very much! LoL, i dont understand it, but it does look like the kind of thing that will work. its going to be a very steep learning curve for me, and may take weeks till i get my head round it. i will pop back in and report my progress and ask for more help if desperate...once i finish...or fail to finish, as the case may be. i will post the entire code here and the specific use it has come to. It is very tempting to keep asking, i have more questions than answers atm, but as they say, "give a man a fish and he will eat for a day, teach him how to fish and he will eat for the rest of his life" Quote from: GiGaBaNE on November 15, 2011, 11:41:27 AM "give a man a fish and he will eat for a day, teach him how to fish and he will eat for the rest of his life" Yeah, but that's pretty close to, "The best way to teach a man to swim is to throw him in the water. The success rate is 100% for those who survive." Quote from: Raven19528 on November 15, 2011, 11:48:37 AM Yeah, but that's pretty close to, "The best way to teach a man to swim is to throw him in the water. The success rate is 100% for those who survive." The thing is, many people who visit forums like this regularly prefer helping someone who has made some kind of effort, to writing a whole script for somebody who isn't really interested in how it works. |
|
| 654. |
Solve : move files where filenames are not having extensions? |
|
Answer» I have a list of file names in File.txt, where they look like 'x yz.doc', 'ab c.doc' the below code is working only if they are WRITTEN like this 'x yz.doc.docx', 'ab c.doc.docx' in File.txt. Is there any way to make the below PROGRAM work for the list having 'x yz.doc', 'ab c.doc'?? Please help.. echo off set old=c:\InPut set new=c:\OutPut REM create a text file for log purpose for the files which missed moving echo Files not having DB entries > Missed.txt echo --------------------------------- >> Missed.txt for /f "delims= skip=1" %%G in (File.txt) do ( if EXIST %old%\%%G ( MOVE %old%\%%G %new%\ ) else echo %%G >> Missed.txt ) pauseSorry I can not help. For the benefit of others, here is a reference to the skip options and some other things about the FOR command. http://ss64.com/nt/for_f.htmlTo be sure that file handling code will correctly work with paths and file names that may have spaces, enclose them in QUOTE MARKS. This applies generally. Code: [SELECT]for /f "delims= skip=1" %%G in (File.txt) do ( if EXIST "%old%\%%G" ( move "%old%\%%G" "%new%\" ) else echo %%G >> Missed.txt ) |
|
| 655. |
Solve : Bat To Exe error? |
|
Answer» I just finished my epic program, now I need it to run in the background. |
|
| 656. |
Solve : Script created to change log on account/password services help? |
|
Answer» i'm trying to write a script to stop a group of services , change the Log on name / set password for each service and then start then back up. For this examples I used the BITS Service in windows ..... What I have so far are as FOLLOWS: I'm not sure about MUCH of this and any help would grateul! sc query state= all | grep "SERVICE_NAME: BITS" > C:\sc.out -----------------Start Services Change Script------------------- sc config OBJ= TeeCee etc. sc stop . . . sc start . . . C:\>sc stop sc stop [BITS] C:\>sc start sc start [BITS] ... C:\>sc config SYNTAX: sc config [BITS] DisplayName= password= ... CONFIG OPTIONS: NOTE: The option name includes the equal sign. type= start= error= binPath= group= tag= depend= obj= DisplayName= password= ---------------END-------------------------------------- It would seem you already have your code, you just need to put it together. Code: [Select]sc <server> stop [BITS] sc <server> config [BITS] obj=TeeCee DisplayName=<TESTUSER> Password=password sc <server> start [BITS] I don't use batch for a lot of network things, and this is untested.What would you suggest? I am trying to create something to run for a group of services... Its about 8 services that I always changed per clients server to the correct domain\Log On and Password save it and restart services but i have to do this for each of them everytime on tons of different servers so i was trying to find a better way.. Thanks for the help !!!!!!"It would seem you already have your code, you just need to put it together. Code: [Select] sc stop [BITS] sc config [BITS] obj=TeeCee DisplayName= Password=password sc start [BITS] I don't use batch for a lot of network things, and this is untested." and YES anything to help me put this together is greatly appriciated!Try this batch file. You will need to create a plain text list (in notepad) of servers using a carraige return to seperate them. I.e. >>List.txt<< server1 server2 server3 etc. You will also need to fill in the [service1],[service2] in the below code with the services you are needing to change. Most of this code just allows you to run the batch file and determine the username and password when you run it instead of having to modify the batch every time. If the services tend to change often, you may want to run an embedded "for" loop to help alleviate your need to modify the batch program. Let me know if you would like to see that coded out. Code: [Select]echo off :username cls echo. echo Enter the UserName set /p user={User} cls echo. echo %user% echo. echo Is this correct? set /p yn1={y/n} if /i "%yn1%"=="y" goto password goto username :password cls echo. echo Enter the password set /p pass={Password} cls echo. echo %pass% echo. echo Is this correct? set /p yn2={y/n} if /i %yn2%"=="y" goto services goto password :services for /f "delims=" %%A in (List.txt) do ( sc %%A stop [service1] sc %%A config [service1] obj=TeeCee DisplayName=%user% Password=%pass% sc %%A start [service1] sc %%A stop [service2] sc %%A config [service2] obj=TeeCee DisplayName=%user% Password=%pass% sc %%A start [service2] ...lather, rinse, repeat... ) Thank you kind sir! What I have is as follows: I created a list.txt and placed it in my root (C) , i'm also not sure what belongs in the field... i'm assuming my computer name , but after running it i'm getting a syntex error Thoughts? echo off :username cls echo. echo Enter the UserName set /p user={User} cls echo. echo %user% echo. echo Is this correct? set /p yn1={y/n} if /i "%yn1%"=="y" goto password goto username :password cls echo. echo Enter the password set /p pass={Password} cls echo. echo %pass% echo. echo Is this correct? set /p yn2={y/n} if /i %yn2%"=="y" goto services goto password :services for /f "delims=" %%A in (List.txt) do ( sc %%A stop [BITS] sc %%A config [BITS] obj=TeeCee DisplayName=%user% Password=%pass% sc %%A start [BITS] sc %%A stop [BITS] sc %%A config [BITS] obj=TeeCee DisplayName=%user% Password=%pass% sc %%A start [BITS] ...lather, rinse, repeat... ) Quote from: animalkrack3r on November 30, 2011, 04:49:20 PM Code: [Select]for /f "delims=" %%A in (List.txt) do (*chuckles* I love how you used the exact script... you can take out the lather, rinse, repeat line, it was in there so you would know that any additional services you wanted to update would have the same syntax as what you see there. The server name needs to be the full computer name of the server. I.e. if you are on a domain, it needs to have the "dot domain name" included. If it is just your computer (or just the computer that it is going to run on), you can actually replace that with a "." and you will accomplish the same thing. If it is the same services that have to be configured on each server then wy not make a text file with the services that need to be configured and create an inner for loop to parse that as well.lol excuse my extreme noobness with batch files, thank you very very much Raven! Squashman, explain ? thanks! |
|
| 657. |
Solve : Batch File That Opens A Specific Window In Outlook? |
|
Answer» Hello all, |
|
| 658. |
Solve : How to Copy the file in subfolders and move the same file to new folder? |
|
Answer» I want to COPY the file from subfolder C (Folder--->subfolder A----> subfolder B------>subfolder C) and move the same file to a new folder. I need to copy *.txt from set of folders->subfolders->subfolders to a specific path. for /f "delims=" %%A in ('dir /b c:\*.txt' ) do copy "%%~dpnxA" "d:\text" The Poll is coming along nicely... just use xcopy if more than one file ie: xcopy c:\folder\folder\folder x:\destination oh and not SURE but file types need{ *.*.whatever} to WORK Quote from: patio on November 28, 2011, 05:09:23 PM The Poll is coming along nicely...I don't understand this specific Poll, both options are the same Quote from: kbit on November 28, 2011, 10:51:25 PM just use xcopy if more than one file ie: xcopy c:\folder\folder\folder x:\destination I thnk you can safely ignore this post. OMG prompt responses ... Tx a ton for every one for their replies.... But , Lemme explain you further about my folder structures. ************* Tree ---> A -->1 -->2 -->3 --> xyz.txt Tree ---> B -->1 -->2 -->3 --> abc.txt Tree ---> C -->1 -->2 -->3 --> rxy.txt Tree ---> D -->1 -->2 -->3 --> tuv.txt Tree ---> E -->1 -->2 -->3 --> unv.txt ************* Likewise, we have many folders, which were created by an application. From the "Tree" directory, i want to copy all the *.txt files to D:\Test C:\Tree> Dir *.txt/s ---- This displays all the txt files from the subdirectories. My requirement : c:\Tree> Copy Dir *.txt/s D:\Test --- This command will not work, just to tell what is our requirement. If i apply XCopy in the Tree Directory, it will copies *.txt files with their directories. BUT I NEED ONLY TXT FILES. We will be doing further process with the txt files. Thanks in advance Cheers Jas Try using the following code snippet: Code: [Select]cd /d c:\tree for /r %%A in (*.txt) do copy %%A d:\test Please let us know either way if it works or not. If you are trying to run this from the cmd prompt instead of a batch file, only use one "%" for the variable. I.e. %A instead of %%AThis is Awesome....... Its working....Raven Thanks a lot Cheers, Jas |
|
| 659. |
Solve : Problem with cd? |
|
Answer» Hi. I have a program where the user specifies a game directory and I create a bat file to launch the game. Part of the bat file is switching to their directory. I'm having an issue when people have foreign characters in their directory. For example, someone from Brazil causes this command in their bat file: |
|
| 660. |
Solve : Remove the content of Temp Directory!???? |
|
Answer» Hello folks, i want a bat file to remove every thing from the %temp% directory and my code is Code: [Select]del /q "%userprofile%\Local Settings\Temp\*.* but this bat file only removes the files and not the folders as ccleaner does. BC: I know you're going to say why I am wrong. Go ahead. Main problem would be rerouting the temp files to the RAM disk, since %TEMP% is a per-user variable. And of course the issue of using up your RAM for the otherwise menial task of storing temporary files. Aside from that, it's not a terrible idea on XP and earlier if the system has GOBS of RAM but low disk space. Quote Main problem would be rerouting the temp files to the RAM disk, since %TEMP% is a per-user variable. True. That's why I have created a batch that sets temp variables easily, so that it can be done for each user. Code: [Select]echo off SET /P DIRNAME=Type the path to the RAMDrive: REG ADD "HKCU\Environment" /v TEMP /t REG_EXPAND_SZ /d %DIRNAME% /f REG ADD "HKCU\Environment" /v TMP /t REG_EXPAND_SZ /d %DIRNAME% /f REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v TEMP /t REG_EXPAND_SZ /d %DIRNAME% /f REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v TMP /t REG_EXPAND_SZ /d %DIRNAME% /f Quote from: Raven19528 on November 15, 2011, 10:11:58 AM Try using this: aannnnn Raven19528 what do you know Code: [Select]rd /s /q "%userprofile%\Local Settings\Temp" your code works and it removes the folder as well as the files. Good going, by the way rd is the remove directory isn't it:then how come it removes the file as well . Sorry BC Programmer your code i.e., Code: [Select]del /q /s "%userprofile%\Local Settings\Temp\*.* doesn't work it only removes the files same like my code except giving the /s switch. Same was for the other codes. Anyways isn't it GREAT to know what a bat file can achieve to do the same task. PS: Just thanked Raven for this job.is the 4KB used for the folder's directory entry really that critical? Quote from: Floppyman on November 16, 2011, 02:30:57 AM by the way rd is the remove directory isn't it:then how come it removes the file as well . Using the /s switch on the rd (which yes, is remove directory, same as rmdir) causes it to remove the folder and all files and folders within the directory. You can view the full explanation by typing rd /? at the cmd prompt.Hello hello newsflash Code: [Select] rd /s /q "%userprofile%\Local Settings\Temp" this code of Raven has stopped working , last time i had to perform a System Recovery and what do you know the bat file doesn't work to well. It removes the TEMP folder entirely, has anyone even been trying this out. Its really important for me. BC programmers does perform a little better Code: [Select]del /q /s "%userprofile%\Local Settings\Temp\*.* Any suggestion i have to be better aware next time when i thank someone. Little HELP here. Quote from: Floppyman on November 25, 2011, 10:07:04 PM Any suggestion i have to be better aware next time when i thank someone. What I do is perform rd /s . (can you see the dot?) from within each directory I want to clear. Being logged in to a directory via the CD command means it won't get deleted. I tend to always add the /d switch to the cd command but I guess that's a personal preference. To turn off the "., Are you sure (Y/N)?" prompt, use the /q switch and if you don't want to see the messages about what it couldn't delete, add 2>nul to redirect stderr to the null device. For example: (the paths are mine, yours may differ) cd /d %temp% & rd /s . /q 2>nul cd /d %windir%\temp & rd /s . /q 2>nul And Floppyman, maybe a bit less of the smart mouth? People have given their time freely to help you, and have done their best. Crude ungrateful sarcasm spoils the forum and looks bad. Anyhow, that's just my opinion. Quote from: Floppyman on November 25, 2011, 10:07:04 PM Little help here. No need for this either. Helping you is not obligatory, and the goodwill that motivates people to do so is a fragile thing that is easily dispersed, as I hinted above. I use to have this on a CD Of course my 'CleanIt' folder also contained these files: AllDone.exe (this is a 'dropcount' file) CHOICE.com sizeOLD.exe (this is a 'dropcount' file) sizeNEW.exe (this is a 'dropcount' file) taskkill.exe TempClose.exe (An old AutoIt file) wscript.exe Anyway, if you want me to zip it up and attach all this stuff let me know Actually not even sure if I'm allowed to do that? It was originally made by me for Windows XP terminals that needed their Temp folders cleaned out periodically. I also put an invisible script on it http://forums.techguy.org/dos-other/644932-solved-howto-run-batch-file.html But these days, CCleaner has command prompt options, so its of no use anymore Quote echo offIf there is ONE thing I've yet to understand, it's people's obsession with files in the temp directory, and treating their deletion like some kind of ritual involving relatively complex scripts. Could not agree more...course there are 100's of other relatively simple tasks we see people attempting to write complex scripts for as well. |
|
| 661. |
Solve : Batch file compiled into exe doesn't work correctly...? |
|
Answer» Hey, I compiled my batch file into an exe and it does not work. When I run it, it just says "Press any key to continue. . ." (pause). I'm using Windows 7 Home Premium if that makes any difference.Quote from: Squashman on December 03, 2011, 06:11:52 PM With a 64 bit OS, java is installed in the the Program Files (x86) folder. Only the 32 bit Java goes there. Like many people I have both. 64 bit apps (e.g. 64 bit browsers) use the 64 Java in C:\Program Files. 32 bit apps use the 32 bit Java in C:\Program Files (x86). Anyhow, to the OP, and anyone INTERESTED in the topic of batch-to-exe converters, they are entirely unofficial, the quality of coding can be very variable, and they only support a subset of batch commands and features. If you really must have an .exe, use a different language e.g. FreeBasic. And another thing... these so called batch-to-exe "compilers" don't actually compile anything; they just take your batch and ENCLOSE it in a wrapper. When the resulting .exe file is run, it extracts the original batch to a folder somewhere and runs it, so it is quite possible that %0 expands to something you don't expect. Quote from: Salmon Trout on December 04, 2011, 01:42:36 AM When the resulting .exe file is run, it extracts the original batch to a folder somewhere and runs it, so it is quite possible that %0 expands to something you don't expect. Like this: Test.bat Code: [Select]echo off echo %%0 values: echo %%0 %0 echo %%~dpnx0 %~dpnx0 echo %%~d0 %~d0 echo %%~p0 %~p0 echo %%~n0 %~n0 echo %%~x0 %~x0 echo %%programfiles%% %programfiles% Run test.bat in 64 bit CMD session: Code: [Select]%0 values: %0 test.bat %~dpnx0 c:\Batch\Bat_To_Exe_Converter\Test.bat %~d0 c: %~p0 \Batch\Bat_To_Exe_Converter\ %~n0 Test %~x0 .bat %programfiles% C:\Program Files Run test.bat in 32 bit cmd session: Code: [Select]%0 values: %0 test.bat %~dpnx0 C:\Batch\Bat_To_Exe_Converter\Test.bat %~d0 C: %~p0 \Batch\Bat_To_Exe_Converter\ %~n0 Test %~x0 .bat %programfiles% C:\Program Files (x86) Compile test.bat to test.exe and run from same folder: Code: [Select]%0 values: %0 "C:\Users\UserName\AppData\Local\Temp\3564.tmp\Test.bat" %~dpnx0 C:\Users\UserName\AppData\Local\Temp\3564.tmp\Test.bat %~d0 C: %~p0 \Users\UserName\AppData\Local\Temp\3564.tmp\ %~n0 Test %~x0 .bat %programfiles% C:\Program Files (x86) Run compiled test.exe from Drive Y: (a pen drive) Code: [Select]%0 values: %0 "C:\Users\UserName\AppData\Local\Temp\C0A3.tmp\Test.bat" %~dpnx0 C:\Users\UserName\AppData\Local\Temp\C0A3.tmp\Test.bat %~d0 C: %~p0 \Users\UserName\AppData\Local\Temp\C0A3.tmp\ %~n0 Test %~x0 .bat %programfiles% C:\Program Files (x86) |
|
| 662. |
Solve : Echo repeatedly in same place without 3rd party exe? |
|
Answer» No need for GNU echo or other 3rd party apps. It didn't perform in XP, the output was displayed as one continuous line indicating that both CR and LF were suppressed. Any words of wisdom? I have run the same code that I posted above, in Windows 7 (64 bit) and Windows XP SP3 (32 bit) and it works equally well in both. Are you running exactly the same code? (That is, did you re type it or copy-and-paste?) Quote from: Salmon Trout on December 02, 2011, 12:09:36 AM I have run the same code that I posted above, in Windows 7 (64 bit) and Windows XP SP3 (32 bit) and it works equally well in both. ... and Windows 2000 SP4 also. Right, thanks for all your work. The script was copied/pasted. I was probably a bit too hasty in completely condemning the script but still have a problem. Although I've only tested in XP Home and XP Pro Corporate I cannot get the script to run successfully if Cmd.exe is opened then the bat filename entered using Start>Run>Cmd or opening a Cmd window using a shortcut.. This is true regardless of where the script is located. The result is: Code: [Select]The time now is is 17:33:53.56TheThe time now is is 17:33:53.73TheThe time now is is 17:33:53.90TheThe time now is is 17:33:54.06TheThe time now is is 17:33:54.25TheThe time now is is 17:33:54.40TheThe time now is is 17:33:54.57TheThe time now is is 17:33:54.75TheThe time now is is 17:33:54.92TheThe time now is is 17:33:55.09TheThe time now is is 17:33:55.25TheThe time now is is 17:33:55.43TheThe time now is is 17:33:55.59TheThe time now is is 17:33:55.78TheThe time now is is 17:33:55.95TheThe time now is is 17:33:56.09TheThe time now is is 17:33:56.28TheThe time now is is 17:33:56.42TheThe time now is is 17:33:56.60TheThe time now is is 17:33:56.78TheThe time now is is 17:33:56.93TheTerminate batch job (Y/N)? Note the STUTTERING "The" A wee bit of sleuthing shows that CR is being set to The in the first loop. However the script does run successfully if run in the GUI (by clicking to open the file). Any pearls of wisdom as to what I'm doing wrong? Are you gonna believe it? I was invoking the batch script using only the filename (without extension) so %0 contained just Trial1 When I invoked the script using Trial1.bat all went smoothly. Another lesson learned. Thanks again S.T. D.I am gonna believe it, because of my own mistake! I saw the "trick to get a carriage return into a variable" ages ago and saved the line to play around with sometime. In the original code, it wasn't %0 - it was %~dpnx0 which expands to the full drive letter, path, name and extension of the script being run. I thought I'd simplify it and it worked OK for me because I always called it either in a command session using the name + extension or from Windows Explorer by double clicking the script icon. From what I can see, the trick exploits the fact that COPY /Z generates a CR for FOR /F to capture after a successful operation, (copying the current script to the null device must always work), and %0 works if you specify the extension, %~nx0 works if you are calling it from a different folder on the same drive, and you need %~dpnx0 if you are calling it from a different drive. I GUESS this makes sense in terms of how the shell assumes the current drive, path, etc when commands are typed, and knowing that Windows Explorer uses the whole drive/path/name/extension. So that %~dpnx0 was there for a reason, and you have very kindly helped me get that straight in my head, by your alertness and patient testing, for which I thank you. Gee whizz, my ego has just done a quantum leap forward. I've also found that if any accessible filename is USED instead of of %0 the script is quite happy to proceed when invoked using only the filename, obviously the file must be a permanent fixture in its location. I have had success using %comspec%. Onward and upward, thank you for the very interesting explanation. I have found another way to get an ASCII 13 (or any other) character into a batch variable, this time using the jscript engine's String.fromCharCode function. Code: [Select]echo WScript.echo (String.fromCharCode(WScript.arguments(0))); > ascii2string.vbs For /F "delims=" %%a in ('CSCRIPT //NOLOGO /E:JScript ascii2string.vbs 13') Do Set "CR=%%a" del ascii2string.vbs The above replaces this line for /F %%a in ('copy /Z "%0" nul') DO set "CR=%%a" OK, it's 3 lines instead of 1 line, (although you can combine them into one using & ) and you need the batch to be in a writeable location, but you can specify which ASCII code you want in the variable e.g. 8 which is BACKSPACE. The trouble with using backspace is you have to count how many you want to use whereas CR just takes you back to the start of the line. I am working on a way of actually embedding the jscript into the batch so it doesn't need to create and kill a separate temp vbs file and therefore could be run on a non-writeable medium. Quote from: Salmon Trout on December 04, 2011, 07:05:29 AM I am working on a way of actually embedding the jscript into the batch so it doesn't need to create and kill a separate temp vbs file and therefore could be run on a non-writeable medium. Code: [Select]set Dummy=1;/* echo off REM The first line of this hybrid JScript/CMD script REM begins with a command which is common to both script languages REM and which makes the remainder of the line inconsequential to CMD. REM CMD sets "Dummy" with the value "1;/*", REM JScript sets "Dummy" to the value "1" and the /* starts a comment block REM So the CMD part goes here where JScript will ignore it setlocal EnableDelayedExpansion REM PASS this script to the JScript engine to get CR character in a variable For /F "delims=" %%a in ('cscript //nologo /E:JScript "%~dpnx0" 13') Do Set "CR=%%a" REM This is a demo for /L %%N in (1,1,100) do ( <nul set /p "=!date! !time! %%N!CR!" ping -n 2 127.0.0.1 > nul ) Echo Finished pause goto :eof REM Below is the end of the JScript comment block REM Under that is the JScript part of the hybrid script REM We make CMD exit the script with goto :eof so it REM never gets to the /* REM NB Unlike VBScript, JScript is case sensitive REM e.g. WScript needs REM capital W and capital S and cript in lower */ WScript.Echo (String.fromCharCode(WScript.arguments(0))); Just brilliant S.T. Great fun, I added a beep as each time was displayed. Great toy to play with for a while. Thank you.It might have a practical use e.g. display the progress of some task or other; you could make a progress bar out of characters such as # |
|
| 663. |
Solve : how to find current directory from which batch file is executed? |
|
Answer» Hi Hi The OS will first look at the CURRENT directory for myfile.bat If myfile.bat is not in the current directory, the OS will use the official search path to fo find myfile.bat C:\Windows\system32>path /? Displays or sets a search path for executable files. PATH [[drive:]path[;...][;%PATH%] PATH ; Type PATH without parameters to display the current path. Including %PATH% in the new path setting causes the old path to be appended to the new setting. C:\Windows\system32> C:\>cd \ C:\>dir /s myfile.bat rem the above code will find all locations of myfile.bat on your computerFred, that doesn't actually answer the question which was asked: how can a batch file know its own directory? Quote from: Salmon Trout on December 03, 2011, 05:58:42 AM Fred, that doesn't actually answer the question which was asked: how can a batch file know its own directory? What happens when myfile.bat is stored in more than one directory? Quote from: Fred6677 on December 03, 2011, 06:06:08 AM
Each one, when run, will know which directory it is in. Oh. Er, Hi Bill! Now we've got that out of the way, maybe I'd better address the confusion that Bill has introduced. The OP asked how a batch file may know its own folder. He asked: Quote I have a batch file named myfile.bat placed at D:\myfolder1\ This is a typical question asked when the batch file is going to be placed on a medium (CD-ROM, pen drive etc) where the drive letter is not known in advance. Often the batch file is required to copy files from its own folder. A batch file has access to the %0 parameter which can be used with the standard parameter modifiers so the batch file can get information about itself, its location, etc. Code: [Select]echo off echo This batch file's full path and name %~dpnx0 echo This batch file's drive letter is %~d0 echo This batch file's folder is %~dp0 echo This batch file's filename is %~n0 echo This batch file's extension is %~x0 echo This batch file's file date is %~t0 echo This batch file's size in bytes is %~z0 echo. pause Code: [Select]S:\Test\batch>dir Volume in drive S is USB-S Volume Serial Number is 2C51-AA7F Directory of S:\Test\batch 03/12/2011 15:34 <DIR> . 03/12/2011 15:34 <DIR> .. 03/12/2011 15:34 371 ShowData.bat 1 File(s) 371 bytes 2 Dir(s) 168,383,356,928 bytes free S:\Test\batch>ShowData.bat This batch file's full path and name S:\Test\batch\ShowData.bat This batch file's drive letter is S: This batch file's folder is S:\Test\batch\ This batch file's filename is ShowData This batch file's extension is .bat This batch file's file date is 03/12/2011 15:34 This batch file's size in bytes is 371 Press any key to continue . . . and you run the batch file the result will be something like this Quote from: Salmon Trout on December 03, 2011, 05:23:40 AM The parameter %~dp0 contains the batch script's drive and pathThanks Salmon Trout! You provide the best & exact solution of my PROBLEM in only one line. Thanks a lot |
|
| 664. |
Solve : wat is wrong in the syntax?? |
|
Answer» the below code is working to move File.txt from Input folder to OutPut. her... I had "his or her account" in my brain but my fingers typed "his or account". I knew that... |
|
| 665. |
Solve : Multiple variable with multiple text files? |
|
Answer» I am trying to do something I think is simple however I am having difficulty. I am trying to create a simple smpp application to send messages that will read the Numbers as well as text from a file as a variable. I can do one or the other but have been unable to do both at the same time. What I want to do is one step futher and make the text "batch file test" a variable and put it in a seperate text file. I think the question you are thinking is not the question you are asking. The answer to this is: Code: [SELECT]set bft="batch file test" echo %bft% > seperate.txt You seem like you probably already knew how to do this, so my question is, what exactly is your question? In regards to your INITIAL statement, a FOR command like you have set up will capture text and numbers just the same. How do you know you are not able to capture both at the same time? Also, be aware that if there is text on one line, and a number on the next, then it isn't that the FOR command won't read them because they are different formats, but that it won't read them together because they are on different lines. In any case, please expand and provide us with some better information so that we can give you the most correct answer.Are you saying that whatever text message you want to send out to each number you just want to hard code it into a TXT file and read in that TXT file to send to each number? This way you never have to edit the batch file. You would only have to edit your list of phone numbers and the text message you want to send out.I have two text files. First text file is list1.txt and contains the following 539990000 539990001 539990002 539990003 539990004 539990005 539990006 539990007 539990008 539990009 539990010 539990011 539990012 539990013 539990014 539990015 539990016 539990017 539990018 539990019 539990020 539990021 539990022 539990023 539990024 539990025 539990026 539990027 539990028 539990029 539990030 the second text file will contain up to 160 characters in this case for testing it will say test of smppclient contents of text.txt test message I have an application called smppproxy which I can manually inject messages I am trying to create a batch file to send to a list of numbers ( from a file) as well as use the text as a variable. So if I want to send the text test message to a given list of numbers ( list1.txt) with the text of (test mesage) I can or I can change the text by having a different text in the text file. Below is the information on the smppproxy if that helps. I apologize if I am not making myself clear. I have just been unable to read the text.txt file in as a variable I have been able to send a message to an entire list of numbers with no trouble with the batch file below. All I am trying to do is add one extra variable for the text "batch file test" and the text is read from a file The text also has to be in " " echo off FOR /F "tokens=*" %%I in (C:\Users\Clay\Desktop\batch\list1.txt) do call :smppclient %%I goto :eof :smppclient smppclient -u SMPPSMS -p TANSTAAF -a 208.52.110.18/16400 -s 1 -T "batch file test" -O Alerts -D %1 >> bulk.txt :: DONE C:\Services\executables>smppclient Usage: Option Content Description ------ ------- ----------- -h BOOLEAN(0,1) 1 to print this usage message -t BOOLEAN(0,1) 1 to enable SMPP Tracing -pp BOOLEAN(0,1) 1 to enable Optional Parameter Printing -lp BOOLEAN(0,1) 1 to load Optional Params -lap BOOLEAN(0,1) 1 to load All Params -pl VALUE 1 to 8000, Payload length -lm BOOLEAN(0,1) 1 Send More Message Optional Parameter Value 1 -plt VALUE 0-Default(WAP WDP),1-WCMP -pf STRING Load the payload from this file name. -V VALUE 0x34 (Version 3.4) -X BOOLEAN(0,1) ClientTransmitter = 1 (default) ClientReceiver = 0 ClientTransceiver = 2 -Q BOOLEAN(0,1) 1 to Suppress output to screen -k BOOLEAN(0,1) When unbinding, keep the TCP/IP session alive -u STRING(1..12) Username, Ex: SYSID -p STRING(1..12) Password, Ex: PASSWORD -a HOSTNAME/PORT Ex: hostname/9703 -s NUMBER(1..8000) number of Submits -r NUMBER(1..8000) number of Replaces -c NUMBER(1..8000) number of Cancels -data NUMBER(1..8000) number of Data_sm -sm NUMBER(1..8000) number of Submit multis -i NUMBER(1..8000) number of Infos -q NUMBER(1..8000) number of Querys -l NUMBER(1..8000) number of EnquireLinks -W NUMBER(1..nnnn) Wait/Delay (milliseconds) between transactions -rc NUMBER(1..n) Number of retries on connect fault -rd BOOLEAN(0,1) Registered Delivery (mask) 0x00=None, 0x01:DlvNonDlv 0x02:NonDlv 0x04=DlvAck, 0x08:ManAck 0x10:IntAck 0x20=AlrAck -ec NUMBER Esm Class, (mask) 0x00=Default 0x01=Datagram 0x02=Transactional 0x03=StoreForward -rp BOOLEAN(0,1) ReplaceIfPresent 0 = No, 1 = Yes -rb BOOLEAN(0,1) 0 = No Rebind, 1 = Perform Rebind -rcon BOOLEAN(0,1) 0 = No Reconnect, 1 = Perform reconnect and rebind -dm NUMBER(1..n) Default message catalogue number -vt BOOLEAN(0..1) Generate varied text strings -T DATA(1..128) Message text -d DCS/DataCodingScheme -P NUMBER(0..255) PID/ProtocolId -R STRING Address range for bind_receiver -D NUMBER Dest Addr , Default 1230000... -O NUMBER Orig Addr -S NUMBER Service Type -DT STRING DestTypeOfNumber -OT STRING OrigTypeOfNumber -DN STRING DestNumberPlan -ON STRING OrigNumberPlan -ba STRING Base Dest Address, will be incremented -bo STRING Base Orig Address, will be incremented -mp NUMBER Message Priority, 0 = Normal, 1 = Urgent -mr NUMBER Message Reference - for Query/Cancel -dt UTC_TIME Deferred Delivery Time UTC_TIME: YYMMDDhhmmssnnp -et UTC_TIME Message Expiry Time UTC_TIME: YYMMDDhhmmssnnp -st STRING System Type -rt NUMBER Set the socket read timeout to NUMBER seconds. The default is no timeout. -stats Print statistics -smcount NUMBER(1..8000) number of destinations per submit multi -ws NUMBER The Bind Transmitter window size. The default is 1 -sp NUMBER WAP Source port -dp NUMBER WAP Destination port -ssu NUMBER WAP source subunit -dsu NUMBER WAP destination subunit -umr NUMBER User message reference -mwi NUMBER Set the message waiting flags. The posible values are: SMPP_MWI_OFF=0x00 - Turn MWI indication off SMPP_MWI_ON =0x80 - Turn MWI indication on The MWI ON/OFF values should be ored with these values: SMPP_MWI_VOICE=0x00 - Voice mail message waiting SMPP_MWI_FAX=0x01 - Fax message waiting SMPP_MWI_EMAIL=0x02 - Email message waiting SMPP_MWI_OTHER=0x03 - Other messaeg waiting Count - No. of messages waiting [0-254] or 255(unknown) Format: MWI or MWI,Count,...,MWI,Count -rxcnt NUMBER messages count a client receiver will receive before sending an Unbind Examples: Submit: smppclient -u 987654 -p PSWD -a hostname/5016 -s 10 -T HelloWorld -D 1234567 Replace: smppclient -u 987654 -p PSWD -a hostname/5016 -r 10 -T HelloWorld -D 1234567 Query: smppclient -u 987654 -p PSWD -a hostname/5016 -q 10 -mr 1234... Delete: smppclient -u 987654 -p PSWD -a hostname/5016 -c 10 -mr 1234... MWI: smppclient -u 987654 -p PSWD -a hostname/5016 -s 1 -lp 1 -mwi 0x80,0x3,0x82,0x8 [regaining space - attachment deleted by admin]set /p message=I will remove myself from this very usefull forum so you can deal with people on a higher level than I.I just gave you the answer. You said you wanted to know how to put the contents of a TEXT file into a variable. I just showed you that. Code: [Select]H:\>set /p message=<text.txt H:\>echo %message% Some text message I want to send H:\>Will make it even easier for you. Code: [Select]echo off set /p message=<text.txt FOR /F "tokens=*" %%I in (C:\Users\Clay\Desktop\batch\list1.txt) do ( echo %TIME% >> bulk.txt smppclient -u username -p password -a ipaddress/port -s 1 -T "%message%" -O Alerts -D %%I >> bulk.txt )Hi Bill...Did he just delete his account. Man that ticks me off. Try and help someone and they just give up. So all the time that you put in to helping them is just wasted. Quote from: Squashman on December 16, 2011, 09:42:37 AM Did he just delete his account. Man that ticks me off. Try and help someone and they just give up. So all the time that you put in to helping them is just wasted. Can't change people Squashman, best to leave it be. You did answer the question, and if anyone else ever comes with the same or SIMILAR problem, you can refer them to this post instead of rehashing it again. Best thing to do is just go pick up your favorite violent game and kill something. That always helps me feel better and is a great way to relieve FRUSTRATIONS. Quote from: Raven19528 on December 16, 2011, 11:08:01 AM Best thing to do is just go pick up your favorite violent game and kill something. That always helps me feel better and is a great way to relieve frustrations.I guess a quick game of Arkanoid will calm me down. |
|
| 666. |
Solve : help with drive letter changes to delete specified files from a usb key? |
|
Answer» hey guys new here, i wanted to pick your brains as im struggling to find an answer to what im looking for! The OP had posted the same question in the Batch Programs Thread and I already answered it more fully, but in essence: that is what i was looking for thank you! instead of naming a drive i wanted to state THIS drive whatever letter it is it dont matter just this drive! rather than actually naming a drive! ill test it and see how it works thanks hopefully i wont bug no one anymore! ill defo stick around as its quite an interesting language im just completely unfamiliar with it do i still use CD\ or is that now redundant as %~d effectively does the same thing? thanks! Quote from: ekto on December 01, 2011, 01:28:11 PM do i still use CD\ or is that now redundant as %~d effectively does the same thing? CD\ will be redundant if you use the full path and filename. that didnt seem to work? it gives this message: the filename, directory name, or volume label syntax is incorrect it was all running from the usb key as well? heres my code: ECHO Y del %~d0:\folder\file1.dll del %~d0:\folder\file2.dll del %~d0:\folder\file3.dll del %~d0:\folder\file4.dll pausewhat happens if you replace del with echo del ? it ECHOS on screen like this: F::\folder\file1.dll etc etc etc is it meant to have a double colon? thanks i tested with a single colon, i left it like this: del %~d0\folder\file.dll but nothing happened and no files deleted, the only code i found that does work is this but it deletes the whole drive: ECHO Y CD .. START CMD /C RMDIR /S /Q "%~dp0" Quote from: ekto on December 01, 2011, 02:44:30 PM
You spotted the problem. I made a mistake before, for which I apologise. The fact is that %~d0 becomes the drive letter and colon. So the script should look like this Code: [Select]del %~d0\folder\file1.dll del %~d0\folder\file2.dll del %~d0\folder\file3.dll del %~d0\folder\file4.dll Please forgive my error. Quote from: Salmon Trout on December 01, 2011, 03:39:32 PM So the script should look like this If that still isn't working, try putting quotes around it. Code: [Select]del "%~d0\folder\file1.dll" del "%~d0\folder\file2.dll" del "%~d0\folder\file3.dll" del "%~d0\folder\file4.dll" Quote \folder\file1.dll We are presuming that this and the others are the actual folder and file names that need to be deleted? (I.e. they weren't just examples for discussion PURPOSES) |
|
| 667. |
Solve : Stop writing "echo"? |
|
Answer» Is there a way I could stop writing echo so many times but NOT in a continuous line? Is there a way I could stop writing echo so many times but NOT in a continuous line? Yes, learn Powershell If you mean NT batch, everything is a tradeoff. This little ditty requires a single echo command.. Better? You be the judge. Code: [Select]echo off for %%i in ("Hi" "Other" "Stuff" "Here") do echo %%~i Code: [Select]set string="1 Paris" "2 London" "3 Rome" "4 Madrid" for %%A in (%string%) do echo %%~A Do you write with notepad? Just write your stuff without using the word 'echo'. Substitute a symbol, maybe the character. Then when you are done, use the replace all feature to change every to echo. Is that not what you want? Quote from: T.C. on November 14, 2011, 01:34:41 AM So you don't like writing echo? Join the madhouse! if you were brought up on BASIC you could do this to make yourself feel at home Code: [Select]echo off set gosub=call set return=goto :eof echo main code %gosub% :subroutine %gosub% :subroutine %gosub% :subroutine pause exit :subroutine echo in subroutine %return% Quote from: Salmon Trout on November 17, 2011, 01:19:50 PM if you were brought up on BASIC you could do this to make yourself feel at home Would that be IBM Basic assembly language for system 360? Quote from: T.C. on November 17, 2011, 08:06:32 PM Would that be IBM Basic assembly language for system 360? IBM Basic assembly language doesn't have either RETURN or GOSUB instructions, which are pretty MUCH exclusive to dialects of BASIC. (BASIC != Basic)Just adding my two cents. Code: [Select]echo off CALL :ECHOS HI other stuff here GOTO :EOF :ECHOS :ELOOP IF "%1"=="" GOTO :EOF echo %1 SHIFT GOTO ELOOPMaybe the OP should tell us What he wants to do instead of How to do it. As mentioned earlier, the TYPE command is used echo a whole text file. Are you still thee? Please shoe an example whee you really did use echo many times in a batch file. He hasn't ben back in 3 WEEKS... |
|
| 668. |
Solve : VBS/Batchscript hybrid Eval.? |
|
Answer» Win XP Home 32 bit SP.3+ Cmd.exe The following script returns Pi with 14 decimal places. It does not. The fraction 22/7 is NOT equal to pi. 2. To use that VBScript one-liner to give a result rounded to 2 decimal places do this cscript //nologo %temp%\eval.vbs "round(%calc%,2)" 3. To get pi, use 4*ATN(1) as the expression to be evaluated Code: [Select]c:\>for /f %A in ('cscript //nologo eval.vbs "round(4*ATN(1),5)"') do echo %A 3.14159 Remember to use 2 % signs in a batch (e.g. %%A) what concerns me is the use of floating point with currency values, so I'll point out the existence of the CCur() function which will convert the VBScript value into a Currency (scaled 64-bit Integer) Variant, which is accurate to 4 decimal places and doesn't suffer from the various gotchas that one finds with floating point. Quote Petroutsos writes, "The topic of printing with Visual Basic is a non-trivial topic...Nobody said anything about printing, or .NET, for that matter...Thank you all for your inputs. At my fairly basic level of knowledge some details in the replies are beyond my understanding but Round as shown by Salmon Trout does what I was looking for. Kind regards to all. Betty.Another option for you as well. Code: [Select]C:\Users\Squash\batch>for /f %A in ('cscript //nologo eval.vbs "FormatNumber(22/7,9)"') do echo %A 3.142857143 Quote from: Squashman on December 09, 2011, 04:57:34 PM Another option for you as well.Does not work for me. Quote from: Geek-9pm on December 09, 2011, 05:31:46 PM Does not work for me.Did you create the eval.vbs script first? Code: [Select]C:\Users\Squash\batch>echo wscript.echo eval(wscript.arguments(0))>eval.vbs C:\Users\Squash\batch>for /f %A in ('cscript //nologo eval.vbs "FormatNumber(22/7,5)"') do echo %A 3.14286 C:\Users\Squash\batch>for /f %A in ('cscript //nologo eval.vbs "FormatNumber(4*ATN(1),5)"') do echo %A 3.14159 C:\Users\Squash\batch>for /f %A in ('cscript //nologo eval.vbs "FormatNumber(4*ATN(1),9)"') do echo %A 3.141592654if you don't want to round but rather want to truncate values: Code: [Select]Function Truncate(ByVal Value,Byval NumDigits) Dim digitfactor digitfactor = (10^numdigits) Truncate = Fix(Value * digitfactor)/digitfactor End Function or just use that as part of the expression as needed, with eval.vbs. Code: [Select] for /f %A in ('cscript //nologo eval.vbs "Fix(Atn(1)*4*(10^4))/(10^4)"') do echo %A replacing 4 with the desired number of significant digits. this should give back 3.1415 (rather than a rounded value of 3.1416)The OP started with the 22/7 thing and then later said she wanted to represent decimals like in dollar$. That is confusing. Who would ever calculate dollar values using a bad form of Pi? And if for some reason you had to use Pi to calculate some kind of monetary thing, and if it was ever recursive or iterative, Pi would have to have more that just two decimals. The error would accumulate. Dollars requires a currency format. It has rules that go beyond Eval and Round and things like that. Currency imposes a strict format for the output as it would appear on a console or printer. I still do not understand her intended use. Setting the number of decimal places does not mean that the output is consistent with a range of values that may occur in monetary transactions. They teach that in Computers 101. Is the OP just trying to bait us? I'm back again to try to explain... My original query was Is it possible to select the number of decimal places returned by Eval please? . As simple as that. I now realise that I should not have posted referring to Pi or to currency amounts, those two subjects may have clouded the issue. I had, and still have, no intention of calculating Pi, or using Pi in any calculation, the script was used as an example only and in my earlier vain attempts to solve my query without referring it to the forum. All I wanted to know was if the number of decimal places returned by Eval could be selected. However, the experience has had its benefits, I now have several options and have enhanced my scant knowledge base. It was never my intention to bait anyone, as a newbie I'm not clever enough or devious enough to do that, or to waste the very VALUABLE time of the forum gurus If I ever post another query rest assured I will have given the format and WORDING of the query a lot more consideration than I did on this occasion. Again thanks to all, please consider the subject closed. Betty |
|
| 669. |
Solve : Help | I am new to making batch file :-(? |
|
Answer» Hi All, |
|
| 670. |
Solve : Password Encoder+Decoder? |
|
Answer» I'm making a Register Program and I was wondering if anyone had code to Encode and to Decode a String. Are you talking about encryption? Encoding would essentially be putting something into programming language. Please be more specific. Encoding and Encryption are both routines that work with data. Has nothing to do with a programming language in either case. Encryptions purpose is to disguise the data so that it cannot be read by anyone but the intended recipient. Encoding is used merely to work with a data in a more suitable FORMAT, or for space or other concerns. For example, most compression algorithms are encoding/decoding algorithms. in the case of a zip or other compressed file that is ENCRYPTED, you've got both. That said, they do probably mean encryption. And if you don't know how to do something like this, I THINK it is time to reassess whether you really ought to spend time adding a pointless "feature" like this to a application when you could be working on new features and/or functionality of the application. |
|
| 671. |
Solve : Date by month-day-year in batch file?? |
|
Answer» I am wondering if it is possible to have a batch file display the Month first, then the day, then the year. |
|
| 672. |
Solve : batch file to check whether a file is completely written? |
|
Answer» Hi all, |
|
| 673. |
Solve : Problems in batch file running in parallel? |
|
Answer» this problem is associated with my SERVER (Windows Server 2003 R2 Enterprise x64 EDITION) I think it would be beneficial to everyone if we could see each batch file in its entirety and see how the Tasks are scheduled in Task Scheduler. +1 |
|
| 674. |
Solve : Meaning of "echo."? |
|
Answer» What is the meaning of "echo."? I cannot find this ANYWHERE. I know it does not print the ".". |
|
| 675. |
Solve : Need a DOS vesion that orks with NTFS formatted disks.? |
|
Answer» Very unhappy with the version of DOS that comes with Windows XP Pro. I am tired of getting messages telling me I cannot do what I want to do. An example is deleting a file that was left by an old program. MS TELLS me that XP and XP DOS are not allowed to do it. Is there a DOS version available (does not need to be free) that works with NTFS formatted disks and does not listen to Microsoft? Think about this. "Is there a DOS (IMPLYING MS_DOS [Microsoft_Disk Operating SYSTEM]) version that works with NTFS (Microsoft developed file system) and does not listen to Microsoft?" Ummm... No. Try Linix. On to the deeper issue, what error messages are you getting? If it's an old file that isn't used by any program at the time and you have administrative privileges to the computer, there should be no reason you can't delete it. You may have a virus.NTFS4DOSSorry for the delay in returning. Thanks for the replies. I'll get NFTS4DOS. Tom |
|
| 676. |
Solve : does closing cmd window terminate the command running?? |
|
Answer» does closing the cmd window currently running a DEL /f/s/q filepath well thats a load off, i know it deleted some files but a few is better then the TB of data Surely you know how to find how much data and how many files are left? |
|
| 677. |
Solve : create null file's? |
|
Answer» hi its nice man very thank you so instead of (name.txt), try this ('dir /b f:\ramin'), let me know if that works Quote from: skorpio07 on December 14, 2011, 03:49:19 PM When I do use the dir command I always try and do a pushd to set the working directory FIRST and I usually make sure I exclude listing directories. But it would probably be better to ue the for /d option.i am noob can you give me a complate cod for (( so instead of (name.txt), try this ('dir /b f:\ramin'), let me know if that works ))such as Quote for /f "tokens=*" %%A in (name.txt) do copy "f:\modern\modern.iwi" "F:\New Folder\%%~A" so thanks and / Squashman thank's for help Code: [Select]for /f "tokens=*" %%A in ('dir /b f:\ramin') do copy "f:\modern\modern.iwi" "F:\New Folder\%%~nA" Squashman's pushd reference is good, though unnecessary in this instance I believe (though not a bad habit to start if you are planning on getting into programming.) I don't understand the point behind using the /d switch over the /f switch though. Please explain./Raven19528 Thanks its working good I know it's more but i have just 1 question again when the source [ ('dir /b f:\ramin') ] have sub-folders i must create sub-folders manually in [ "F:\New Folder\%%~nA" ] with out it, its not worked so is it possible the sub-folders create automatically (forced) with out me ?!! and it just only copy the file names from [ ('dir /b f:\ramin') ] and the file format from [ f:\modern\modern.iwi ] not copied ?!! so the copied files have no formats ?! Quote from: Raven19528 on December 14, 2011, 05:25:44 PM I don't understand the point behind using the /d switch over the /f switch though. Please explain. It's not "instead" of the /f switch. FOR can use wildcards like this FOR %%A in (*) which will find files, FOR /D %%A in (*) will find directories. SEE the FOR help. Quote from: raminr63 on December 14, 2011, 09:34:46 PM I know it's more but i have just 1 question again ?! and waitting lol Quote from: raminr63 on December 15, 2011, 02:09:09 AM ?! and waitting lol Goodbye... un-notifying... Quote from: Salmon Trout on December 15, 2011, 12:27:50 AM FOR can use wildcards like this FOR %%A in (*) which will find files, FOR /D %%A in (*) will find directories. See the FOR help. So if I get this right, I could use 'FOR /F /D %%A in (*)' and find both files and directories in a particular location? Would this find the files and folders within the SUBDIRECTORIES? I would think not because that would be what the /R switch is for, but I'm not certain. Quote from: raminr63 on December 15, 2011, 02:09:09 AM ?! and waitting lol Comments like this (as shown) are not appreciated. Understand that we do not work on this forum, but that we volunteer our time and knowledge as we can. This is a really fast way to make sure that your posts are ignored by those who can provide you help. And the at the end does not make up for the blatent impatientness of the post. It's my belief that this is a situation where Squashman's suggestion of using pushd will be needed to help get everything done the right way. I haven't taken the time to try to test anything on this, but perhaps if you can show some patience, the SPIRIT of the holiday season will be enough that you do receive some help on the topic. Again, we work here for free. Please keep that in mind when requesting help. Quote from: Raven19528 on December 16, 2011, 11:25:57 AM So if I get this right, I could use 'FOR /F /D %%A in (*)' and find both files and directories in a particular location? Would this find the files and folders within the subdirectories? I would think not because that would be what the /R switch is for, but I'm not certain. The FOR help, accessed by typing FOR /? at the prompt describes the syntax very clearly. |
|
| 678. |
Solve : How do delimit an environment variable? |
|
Answer» search around for this but couldn't find anything that would work. I wouldn't make a habit of using numbers for the FOR loop variable especially if you have batch files that use cmd line input or you are calling another label or batch file. I've been using numerals (and most PRINTABLE ASCII special characters in the range of decimal 33 thru' 254) as For loop variables in batch scripting for some time and never ever had a problem which can be associated with their use which I realize is undocumented. Can you provide an example of a numeric For loop variable which causes a problem in a batch script please, typos excluded? Thanks. Code: [Select]for /f "delims=" %%1 in ("%testfile%") do set filenam=%%~n1 Salmon I tried the following from the DOS prompt.. (after setting testfile=sp.cmd) for /f "delims=" %a in ("%testfile%") do echo %a~n1 which returned: sp.cmd~n1 so i tried this: for /f "delims=." %a in ("%testfile%") do echo %a~n1 which returned: sp~n1 so i tried this: for /f "delims=." %a in ("%testfile%") do echo %a:~n1 which returned: sp:~n1 what am i doing wrong? Quote from: skorpio07 on December 13, 2011, 07:44:23 AM what am i doing wrong?Your syntax is off, and it SEEMS you are misinterpreting how the for statement is working. For a quick explanation, your %a is the token that you are setting so the ~n1 is not actually doing anything. If you are looking to grab the name of a file (which is what I am assuming you are wanting using the ~n parsing syntax) then that needs to be set before the variable. Example: for variable %a, to grab the name you would need to use %~na. This is why the help text suggests to use capital letters, as it helps to distinguish parsing syntax from the variable. I.e. %~nA for a %A variable. For what you are trying to accomplish, using the for "delims=." %a in ("%testfile%") do echo %a should get you what you are looking for. The only issue you would end up running into is there is a "." in the file name. If you are looking to grab the name of the file however, you can also try using for /f "delims=" %a in ("%testfile%") do echo %~na and you should end up with identical results, only this one should ALLOW for additional "."s to be in the filename. Remember that when using these in a batch file, you need to double up the percent signs. %a=%%a and so forth. Squashman, T.C.'s method of using ASCII 33-254 will work in most applications. What I have found the most annoying part about all of it is trying to figure out which ASCII character comes next, which is why I continue to use the letter variables. I still remember my alphabet from school most days. thanks raven i should have posted that i had already gotten the right solution (there is obviously more than one) with this: for /f "tokens=1 delims=." %%a in ("%testfile%") do (set temptst=%%a) --running inside a batch file-- but nice to know that this works as well: for /f "delims=." %%a in ("%testfile%") do (set temptst=%%a) and for /f "delims=" %%a in ("%testfile%") do (set tempst=%%~na) and im sure there are other ways as well, my response to salmon was that i was trying addtional ways of getting the filename so i tried his method to see if it would work (my syntax was off, i got it now!) and thanks again to TC, i now know better how to extract tokens...and on that note, one question with regards to tokens: what is the difference between: tokens=1-5 and tokens=0,2 (the question is what is the difference between the dash and the comma) where would i find the microsoft answer to that as well. thanks again Quote from: skorpio07 on December 13, 2011, 10:30:59 AM what is the difference between: You can't have a token 0 (zero), they start at 1 (the first). The difference is that "tokens 1-5" selects tokens 1 to 5 and "tokens=1,5" selects tokens 1 and 5. I can think of at least 4 ways to get familar with how they work: (1) Study the FOR documentation which you can see by opening a command window and typing FOR /? at the prompt. Most commands have help you can see by this method. (2) Study the Microsoft Command-Line Reference A=Z at http://technet.microsoft.com/en-us/library/bb490890.aspx (3) Just Google for stuff about batch command syntax, there are zillions of pages out there. (4) Most fun, I think, and a good idea in many ways, do some experiments at the command prompt. You won't break your computer as long as you don't FOOL around with DEL where you have precious files. Remember that you use one percent sign at the prompt where you would use two in a batch script, so (for example) you would use %A %B etc at the prompt and %%A %%B etc in a batch file. You may as well precede the echo command with an symbol to avoid seeing it on the screen. Code: [Select] C:\>for /f "tokens=1-5" %A in ("ant bee cat dog egg fire goes hat ink jet kit") do echo %A %B ant bee C:\>for /f "tokens=1,5" %A in ("ant bee cat dog egg fire goes hat ink jet kit") do echo %A %B ant egg C:\>for /f "tokens=1,2,6-7" %A in ("ant bee cat dog egg fire goes hat ink jet kit") do echo %A %B %C %D ant bee fire goes C:\>for /f "tokens=1,2,6,8-9" %A in ("ant bee cat dog egg fire goes hat ink jet kit") do echo %A %B %C %D %E ant bee fire hat ink C:\>for /f "tokens=1,9 delims=," %A in ("ant,bee,cat,dog,egg,fire,goes,hat,ink,jet,kit") do echo %A %B ant ink C:\>for /f "tokens=11 delims=," %A in ("ant,bee,cat,dog,egg,fire,goes,hat,ink,jet,kit") do echo %A kit Salmon Trout's way is by far the most bullet proof. If someone puts a period in their file name besides the extension then you are going to start getting undesirable results. So if your file name is My.File.Name.txt, you are not going to get what you want for your output if you are using the delimiters option. By using the MODIFIERS like Salmon Trout did, you will always get the extension removed from the end. I do realize that you can use a number in a FOR LOOP but it is just really bad habit to get into. Just like Salmon Trout warns us for using Double Colons for comments. That too is probably bad coding practice and I am guilty of it but I just like the way it looks. When you write batch files that are hundreds of lines long that use command line input and are calling out to other batch files and other labels you can easily get Mixed up on When you are suppose to be using %%1 versus %1 in your coding. Over the years I can't recall a programming language that used numbers as the FOR Loop variable. My experience is limited to Fortran, Pascal, Basic and shell scripting like BASH, Power Shell and Batch. Just my two cents.many thanks squashman, yes, i agree that upon consideration, ST's method is better, as i won't know for sure that there is only 1 period in the filename. and i don't use ::, just rem's I see that Salmon Trout already beat me too it, but here is what I was working on while he was quicker on the DRAW this time. The tokens within a for statement are not well explained in the help text. I too had some questions on them and CH helped steer me in the right direction, so hopefully I can utilize what I was taught and pass it along. The particular statements within the quotes in the for command help to determine how the input is parsed and assigned. The best way to see this would be to use some examples. For all of these examples, we are going to have a variable called testset. Code: [Select]set testset=one two three four five six seven Now you already know that the delims= statement allows you to set what the delimiters are. The default delimiters are the space and carriage returns. So for the following for statement, the additional text would be what variables are equal to. Code: [Select]for /f %a in ("%testset%") do ( echo %A = %a echo %B = %b echo %C = %c echo %D = %d echo %E = %e echo %F = %f echo %G = %g ) >%A = one >%B = two >%C = three >%D = four >%E = five >%F = six >%G = seven The %a in this case is the explicit token, the one that you explicitly define. The tokens that follow it are the implicit tokens that the for command implicitly defines and assigns. Nothing groudbreaking yet, but we need some ground work to break. With "tokens=", you are able to define which "tokens" are actually assigned data. It gets a little hard to explain, but perhaps is easier to show. Code: [Select]for /f "tokens=1,2" %a in ("%testset%") do echo %a %b >one two To specifically answer your question, the comma seperates the tokens while the dash signifies a range. Try to follow how this next one works. Code: [Select]for /f "tokens=2,4-6" %a in ("%testset%") do echo %a %b %c %d >two four five six Because in this setup, the first delimited token (one) is not designated as assignable, it is discarded and the second delimited token (two) which is designated as assignable is assigned to the first (explicit) token. In this construct, it's easier to think of two different sets of tokens being used (I wish I was creative enough right now to think of a different name to use for them, but I'm not.) The only other caveat to add is the addition of the "*" at the end of the tokens statement. Using tokens=1* in the second code (for /f "tokens=1,2" %a in ("%testset%") do echo %a %b) will actually give you the output of one two three four five six seven because it takes the first delimited token and assigns it to %a, but the "*" tells it to take the rest of the line and assign it to %b. Please let us know if you have any other questions on the for statement, and I'll try to locate the post that taught me about all of this. Quote from: Raven19528 on December 13, 2011, 12:08:16 PM The default delimiters are the space and carriage returns.From the help file. Code: [Select]delims=xxx - specifies a delimiter set. This replaces the default delimiter set of space and tab.Many many thanks for this education, you hit the nail on the head with the explanation. precisely what i was looking for with respect to tokens. and yes if you have that link, i will go and further my knowledgebase. Quote from: Raven19528 on December 13, 2011, 12:08:16 PM I see that Salmon Trout already beat me too it, but here is what I was working on while he was quicker on the draw this time. |
|
| 679. |
Solve : how do i modify a windows 7 firewall???? |
|
Answer» i would LIKE to make my own windows firewall but i would like to USE my EXISTING forewall program. please help |
|
| 680. |
Solve : rename files ?? |
|
Answer» I am trying this |
|
| 681. |
Solve : Add Domain users to multiple machines / Read info from text file? |
|
Answer» I am using the batch file below, to add 30 domain USERS to the administrators |
|
| 682. |
Solve : if file exists in one folder but not in another folder, delete the file? |
|
Answer» I need to be able walk thru and read all the files in G:\folderA and all files in subfolders under folderA and determine if the file exists in C:\folderA. If the file cannot be found in G:\folderA, then deleted the file in C:\folderA. I need to be able walk thru and read all the files in G:\folderA and all files in subfolders under folderA and determine if the file exists in C:\folderA. If the file cannot be found in G:\folderA, then deleted the file in C:\folderA.I think you got that LAST sentence backwards. If the file cannot be found in C:\folderA, then delete the file in G:\folderA.You are absolutely correct. My bad. CyberalEasy enough to do with a Batch file. Leaving work now. Might get back online later tonight.Squashman, No problem at all. I'll check later or tomorrow. Thanks CyberalThis turns out to be a simple one liner. Code: [Select]FOR /R "G:\FolderA\" %%I in (*) DO IF NOT EXIST "C:%%~pnxI" DEL "%%~I"Squashman Wow, this worked perfectly! Thanks so much. Another quick question I thought you could do multiple actions as long as you begin with '(' and end with ')'. As shown below .... Am I out in left field on this? I am on Windows 7 if that MAKES a difference FOR /R "G:\testBUdir\" %%I in (*) DO ( IF NOT EXIST "C:%%~pnxI" del %%~I echo c:\%%~pnxI has been deleted echo something again ) Quote from: cyberal on December 23, 2011, 10:01:46 AM Am I out in left field on this? No, you are absolutely correct. You just need to make sure of your parentheses construction and that it follows all the proper syntax. For instance, what you have shown here will not work, because you did not "open" the IF NOT EXIST statement. It should be as follows: Code: [Select]FOR /R "G:\testBUdir\" %%I in (*) DO ( IF NOT EXIST "C:%%~pnxI" ( del %%~I echo c:\%%~pnxI has been deleted echo something again ) ) I use the spacing for my own sanity, as it allows me to see exactly which parentheses CONSTRUCTS are being opened and closed, but you can use different or no spacing if you like. Works perfectly now! Thanks for all your help and have a great holiday cyberalYou are deleting from the G: DRIVE not from the C: drive so your echo statement should just be. echo %%I has been deleted Quote from: Raven19528 on December 23, 2011, 10:38:04 AM I use the spacing for my own sanity, as it allows me to see exactly which parentheses constructs are being opened and closed, but you can use different or no spacing if you like.Same here but I like to use TABS.Truely appreciate all the help ! Thanks again and have a great holiday .... cyberal |
|
| 683. |
Solve : Mysterious Batch Error? |
|
Answer» I'm working on a batch file game (a sort of quiz).
What I'm doing at the moment is the part that reads the first four lines of the file. I'm using 'functions' (info at HTTP://ss64.com/nt/syntax-functions.html) and I have a function to read the first four lines. Here it is: Code: [Select]:getquestion setlocal EnableDelayedExpansion>>OUTPUT.txt setlocal>>OUTPUT.txt set number=%1%>>OUTPUT.txt set /a startline=%number%*6>>OUTPUT.txt set /a endline=%startline%+3>>OUTPUT.txt set i=%startline%>>OUTPUT.txt for /f "eol=¬" "skip=%startline%" %%a (FACTS.txt) DO ( set /a i+=1>>OUTPUT.txt>>OUTPUT.txt echo %%a>>OUTPUT.txt if %i%==%endline% do endlocal>>OUTPUT.txt goto eof>>OUTPUT.txt ) endlocal>>OUTPUT.txt setlocal DisableDelayedExpansion>>OUTPUT.txt goto :eof>>OUTPUT.txt As you can see, I've been trying to figure out what the problem is by putting >>OUTPUT.txt at the end of each line to try to figure out what the problem is. I run the batch, but the moment that function is called, it just closes. I look in OUTPUT.txt. Nothing at all. Can anybody track down the problem? By the way, the line of code that calls the function is: Code: [Select]call :getquestion %level%>>OUTPUT.txtYou would be better off having each question in your FACTS.txt file on a single line. A heck of a lot easier to parse with a batch file that way. Question, Choice A, Choice B, Choice C, Answer, Explanation. Why do you have that GOTO EOF in your FOR LOOP. That will immediately break the FOR LOOP after it parse the first line of the FACTS.txt file. I believe the line should be GOTO :EOFIs the variable NUMBER the Question Number you are trying to pull from the Fact.txt file. If so, your math logic is screwed up with that. If you are passing the question number to the function you would need to multiply and then subtract to get the first line of the question. Question 2 should be lines 7 to 12 of your text file. But using your logic the startline would be 12 and the endline would be 15. So to get your startline you should be doing this: set /a startline=(%number%*6)-5In this line, where is the value of %1% coming from? Quote set number=%1%>>OUTPUT.txtQuote from: Salmon TROUT on December 22, 2011, 10:01:22 AM In this line, where is the value of %1% coming from?I am assuming he is not showing us the entire batch file. I am just assuming he is calling the function above and passing the question number with the CALL.Just remember that assuming makes an *censored* out of u and some guy named MING... Quote from: Squashman on December 22, 2011, 10:03:32 AM I am just assuming he is calling the function above and passing the question number with the CALL. If that is so, maybe he thinks that %1% is going to hold the passed parameter? Quote from: BC_Programmer on December 22, 2011, 10:12:43 AM Just remember that assuming makes an *censored* out of u and some guy named Ming... I know that guy...he was in my Darts League...Ok. I suggest making a new output.txt file. |
|
| 684. |
Solve : Long Delays ... SLEEP or Better Method?? |
|
Answer» I was wondering if SLEEP is the best method for a 10 minute delay or if there is anything else out there that works better for longer than what sleep was really created for delays in batch files for say 10, 15, 30 minutes etc? I was wondering if SLEEP is the best method for a 10 minute delay or if there is anything else out there that works better for longer than what sleep was really created for delays in batch files for say 10, 15, 30 minutes etc? Why do you think that whichever version of sleep.exe you have was "created for" certain lengths of delay? It waits for the number of milliseconds or seconds (according to version) that you tell it to wait. It doesn't care if it is 30 seconds or 300 or 3000. |
|
| 685. |
Solve : FFmpeg converting to flv but with 0 file size? |
|
Answer» I'm having problems regarding conversion of video to FLV format. Below is my command |
|
| 686. |
Solve : Ghost Floppy Batch Formula Needed? |
|
Answer» December 31, 2011 Dear Forum, First, Happy New Year to y'all!!!!! What I need help on is a batch file that I can put on a floppy that can execute a Ghost.exe DOS file that is on the G:\ Drive. A little background: 1. I've been using Ghost since version 5 back in 1995. 2. I've always used a Ghost boot floppy with an Autoexec.bat file to do my bidding. 3. When Ghost 2003 came out, I could not use it with an Autoexec.bat file because I did not want to "Mark" my HDD, just too "Big Brotherish" for me. 4. I then got a hold of Ghost Corporate v7.5 and THAT worked great with my Ghost floppy sets to: Make to HDD Make to CD Make to HDD And CD CRC Check HDD Image CRC Check CD Image Restore From HDD Restore From CD Whatever I wanted to do, I just popped in the appropriate floppy and turned my computer on and Ghost did its thing. The above worked with my Windows 98SE box, but my new Windows 7 box doesn't "play nice" with Ghost Corporate v7.5 but is OK with Ghost v11.5. BUT, v11.5 is 2262 KB's so I'm FORCED to go the "Bootable CD" or "Bootable USB" Thumb Drive route. I just want to keep it via floppies! This is how I'm presently set up on my 98SE box for making an image file of C:, putting it on my HDD and then CRC checking the image: echo off GhostCE.exe -clone,mode=pdump,src=1:1,dst=G:\01_Ghost\Newest.gho -z3 -fx -sure GhostCE.exe -chkimg,G:\01_Ghost\Newest.gho -sure Soooo, what I want to do is put the Ghost v11.5 DOS exe in a folder on the G:\ Drive and have the boot floppy run an Autoexec.bat file to go to it and do what I want it to do, be it Make to HDD or CRC Check CD Image, etc... The folder I made is G:\!-Ghost and I named the Ghost file Ghost115.exe. Can anyone come up with a batch file to give me joy? Thanks in advance. Bug_zsSolved!!! Trial and error got me the answer that worked perfectly on my Windows 7 box from a boot floppy: echo off G: CD \!-Ghost Autoexec.batSpoke too soon. For some reason I now GET the proverbial "Bad command or file name". I even tried going with... echo off G: CD \!-Ghost Ghost115.exe NO joy! HELP!!!!!! Bug_zsWhen you boot with the floppy to a DOS prompt, is the G: drive visible? And is the !-Ghost folder visible? And the Ghost115.exe file? Try this: Code: [Select]echo off cd /d G:\^!-Ghost (Not sure if the cd /d will work, I recall something about limiting the use of switches in boot sequences) Ghost115.exe The ^ "escapes" the "!" and makes it so the batch program SEES it as a character instead of the start of a variable, which is what it is currently seeing and likely the reason you get the "Bad command or file name". The cd /d will work in cmd prompt in Windows, but I am uncertain of it's availability with the process you are describing. If it does not work, you original two line approach should still work for it. For future reference, it is usually a good idea to limit special character usage in folder names you are wanting to use batch files with and on and in.I have no idea why he gave his directories names using non-standard characters...his batch may work but he's asking it to do something it will not. Ghost recognises all command functions ...always has...but not if there written outside the lines. Also curios is why there are no Path statements or variables... Quote from: Raven19528 on January 04, 2012, 11:35:56 AM The ^ "escapes" the "!" and makes it so the batch program sees it as a character instead of the start of a variable, which is what it is currently seeing and likely the reason you get the "Bad command or file name". It can't see it as the start of a variable. MS-DOS does not use ! as a variable delimiter. He mentions autoexec.bat, which means he is using real MS-DOS, not Windows NT family cmd (often wrongly and confusingly called "DOS"). !-GHOST is a legal folder name in MS-DOS. Quote The cd /d will work in cmd prompt in Windows It won't work in MS-DOS, whose version of the CD command lacks the /D switch. Quote from: Salmon Trout on January 04, 2012, 11:58:10 AM It can't see it as the start of a variable. MS-DOS does not use ! as a variable delimiter. He mentions autoexec.bat, which means he is using real MS-DOS, not Windows NT family cmd (often wrongly and confusingly called "DOS"). !-GHOST is a legal folder name in MS-DOS.Yeah I know there are a lot of differences between DOS and cmd, I just have no idea what all of the differences are. Perhaps then the reason he is getting the bad command error message is due to the fact that he has the "\" preceding the folder he is searching for. Though I do believe patio's question about the lack of path statements and variables should also be addressed prior to troubleshooting. No sense in troubleshooting a product that won't do what he wants when it is working properly. Quote from: Raven19528 on January 04, 2012, 12:08:38 PM Perhaps then the reason he is getting the bad command error message is due to the fact that he has the "\" preceding the folder he is searching for. That should work just fine. I wonder if MS-DOS can even see the G: partition. Quote from: Salmon Trout on January 04, 2012, 12:35:58 PM I wonder if MS-DOS can even see the G: partition. That may be the issue. I wonder if the G: is being mounted prior to this running. The OP may need to put mount.exe on the boot disk and mount the G: drive prior to running this particular command sequence in the batch file. Quote from: Raven19528 on January 04, 2012, 12:53:53 PM That may be the issue. I wonder if the G: is being mounted prior to this running. The OP may need to put mount.exe on the boot disk and mount the G: drive prior to running this particular command sequence in the batch file. It might be an NTFS partition, or a non-AHCI SATA drive. I suspect G: is an optical drive...which means his batch isn't even close to working... January 4, 2012 Dear Forum, First, thank you for your extensive replies. A bit of background and mini-update... 1 TB HDD with the following C: 75 Gigs NTFS Windows 7 64 Bit D: 25 Gigs NTFS Program Files E: 15 Gigs NTFS F: 600 Gigs Fat32 G: 30 Gigs Fat32 Ghost Images H: to M: various sizes all Fat32. Z: is my DVD Burner (1st thing I always do on an install is set CD\DVD to Z) I built a "Standard Ghost Bootable CD/DVD--on Steroids" from NightOwl at the Radified Ghost board: http://nightowl.radified.com/bootcd/bootcdintro.html I added the ahci.sys file, for Ghost to see SATA CD\DVD DRIVES from: http://h20000.www2.hp.com/bizsupport/TechSupport/SoftwareDescription.jsp?lang=en&cc=us&prodTypeId=12454&prodSeriesId=1844973&swItem=wk-61401-1&prodNameId=1844975&swEnvOID=2096&swLang=13&taskId=135&mode=4&idx=0 and added this line in the config.sys file: device=ahci.sys /d:nightowl I added an Autoexec. bat file with this in it: echo off Ghost115.exe -clone,mode=pdump,src=1:1,dst=1:5\01_Ghost\Newest.gho -z3 -fx -sure Ghost115.exe -chkimg,1:5\01_Ghost\Newest.gho -sure and booting from the DVD in the BIOS, Ghost made an image of my C: drive, CRC checked (or Verified) it and put it into my G:'s 01_Ghost folder. So, at least half of the problem is solved, but getting a FLOPPY to trigger the "MakeHDD.bat" is still in need of solving. Tried: echo off CD /D G:\^!-Ghost Ghost115.exe Got "Bad command or file name" >It might be an NTFS partition, or a non-AHCI SATA drive. As you can see from above, G: is Fat32 and my SATA is set to AHCI >I suspect G: is an optical drive As you can see from above, Z is my DVD burner Bug_zsPossibly the OP thinks that drive letters which are assigned in Windows are known about, and used by, MS-DOS booted from a floppy disk? Again, I'll suggest that you do a little research and take a look at mount.exe. This is going to be needed if you are wanting to designate drive letters on an empty HD. For Vista and 7, mountvol.exe was introduced. You can take a look at some of the documentation on it here. It is very similar to mount.exe, so take your pick as to which you would like to use, though mountvol does provide some additional functionality. Utilize either of these utilities to mount the drives that you are referencing later in your boot process. You will need to conduct the research to find what some standard mount points are on HDDs. Also, as a REMINDER, the command prompt that you are using on your Win 7 is very different from the MS-DOS that is being run during an OS install. Keep this in mind as you continue this adventure. |
|
| 687. |
Solve : Extract first letter from file names, and move files in to folder...? |
|
Answer» Hello all.
To extract the first letter of a variable is pretty simple: Code: [Select]set str=1234 set str=%str:~0,1% echo %str% In the example above, first str is set to "1234", and then set to the first character, resulting in "1". So I thought I could use the above technique and the FOR command. However, I just can't extract the first letter from file names within the FOR command. For instance, in the code below I attempt to, for each TXT file in the folder:
Code: [Select]cls echo off set /p str="" for %%f in (*.txt) DO ( set str=%%~nf echo this is the filename: %%~nf echo this is the variable: %str% pause ) exit But what actually happens is that the result of line (3) is OK, changing for each file, while variable STR echoed in line (4) remains fixed with a value that was set at some point. My conclusion is that variable STR never is set with the file name. Or maybe it is, but only once. I looked in to expanding the variable by using "!" (e.g.: !str!), but I couldn't get that to work. Once I do get to assign the file name to a variable, then I can extract the first letter (as DESCRIBED, with %str:~0,1%) and proceed with my plan. Any ideas on how I can achieve my objectives, and why I can't set the variable with a file name? Thanks a lot, Michael You need to enable delayed expansion. This allows you to use the exclamations around your variable names. echo off & setlocal enabledelayedexpansion Quote from: Squashman on December 31, 2011, 11:46:16 PM You need to enable delayed expansion. This allows you to use the exclamations around your variable names. A-ha.... SOMETHING NEW I learned. I wasn't aware that it had to be explicitly enabled. I'm not home right now but will work on this ASAP. Thanks again, Michael |
|
| 688. |
Solve : Batch file to copy & paste text? |
|
Answer» Hello All, I need the batch file to copy from the 0 to the end of the 1st line What 0? I can see five zeroes. The second line is the same as the first line except there are a bunch of spaces and then a 2. What do you mean "paste" it? 99940 E1 -0001.30 # to 99940 E1 -0001.30 2 right now I need a batch file to input the # 2 the very last position on this line. so, this is what the line is right now 99940 E1 -0001.30 I need to have the 2 to be put the very end of that line, so the line will look like 99940 E1 -0001.30999999999999999999999999999992 my thought process was, copy the position after the last 0 to the end of the line. then paste the spaces to where the 9's are with the 2 the very end. i'm sorry for confusing everyone on this.. :-(that will not work the way that i want it to. I have the lines that I'm looking for but I need to have the 2 in position #118 in the text file. in the posting above, it's creating additional spaces and that will not be in the proper format. any idea's on how I can insert the 2 in position #118 of a text file ?What are all those 9s for? Anyhow, the short answer is that you can't directly insert a character into a text file using a simple script. What you can do is read in the original text file, and add the new character to the end of each line, and write the lines out to a new file, which you can then rename to replace the original file. Anyhow, I wouldn't use batch for this, I'd use Visual Basic Script. Quote from: Salmon Trout on December 30, 2011, 12:40:49 PM Anyhow, I wouldn't use batch for this, I'd use Visual Basic Script. I can post a script if you want. Well it would be easy enough to remove the existing spaces at the end of the line and then repad the line with a bunch of spaces and substring that variable to a length of 117 and then put the number at the end. Quote from: Squashman on December 31, 2011, 07:13:21 AM Well it would be easy enough to remove the existing spaces at the end of the line and then repad the line with a bunch of spaces and substring that variable to a length of 117 and then put the number at the end. As posted, each line has TRAILING spaces. I don't know if they exist in the files the OP wishes to process? OP please clarify. If trailing spaces need removing prior to processing, the rtrim function can be used. Also I noted that some of the example lines posted above have one leading space, and some do not. And a hash/pound sign seems to have crept in at position 118. Again, OP please clarify. And all those 9s have not been explained. Anyhow a simple VBScript like the one below should do the needful. Code: [Select]Const ForReading = 1 Const ForWriting = 2 Set objFSO = CreateObject("Scripting.FileSystemObject") Set ReadFile = objFSO.OpenTextFile ("input.txt", ForReading) Set Writefile = objFSO.CreateTextFile ("output.txt", ForWriting) Do While Not ReadFile.AtEndOfStream ReadLine = Readfile.readline WriteLine = ReadLine & Space(117 - LEN(ReadLine)) & "2" wscript.echo "Read line: " & ReadLine wscript.echo "Write line: " & WriteLine Writefile.writeline WriteLine Loop Readfile.Close Writefile.Close |
|
| 689. |
Solve : make multiple folders with files from a list file? |
|
Answer» I have a text file exported from the movie collectorz program and I want to add my DVD collection to xbmc through stub files. I found this code and modified it to give me the files. If you are not using the Script that was provided to you on the other forum (DosTips.com) you posted this question on please post the code you are using. Ok it's complicated just because I was in charge of it.... this is my test text file I PUT a bunch of goofy stuff in it to see if it would fly. everything but the colon goes through. I only make the files with a .dvd extension here cause it was messing me up to have both EXTENSIONS (dvd.disc) Code: [Select](500) Days Of Summer!;2009 6th Day, The;2000 10,000 Bc;2008 11:14;2005 2010: The Year We Make Contact;1984 Brüno;2009 Disney Surf's Up;2007 Dolan's & Cadillac;2009 This script takes the names and outputs the files into a subfolder named files.... this is the 30th or 50th thing I tried Im not sure why it works but it does...LOL with the EXCEPTION of the two names with colons. Code: [Select]set dir=C:\temp\test\files\ set ext=dvd for /f "tokens=1,2 delims=;" %%a IN (haa.txt) do >"%dir%\%%~a (%%b).%ext%" ( echo.^<discstub^> echo.^<message^>%%~a is located in the DVD rack^</message^> echo.^</discstub^> ) This file is in the files folder it takes the files appends the .disc ext and moves it into the folder it has just created. Im praying that when I do the whole list of 3000 it don't go bananas Code: [Select]echo off for %%a in (*.*) do ( md "%%~na" 2>nul ren *.dvd *.dvd.disc move "%%a.disc" "%%~na" ) pause I'm sure there are better ways to do this and if I spent my time learning to write code instead of chasing women drinking beer and watching movies I'd have more time to watch movies ... **edit** well there are other things that mess it up like the u with two dots above it (WITCH I cant even find on the keyboard..LOL) the ? mark also messes it up and my copy of alien3 the 3 is in subscript that also don't make it through the ringer. but for those three files I can make corrections I suppose I can just do a search and replace in the text file and get rid of all the miscellaneous crap. **EDIT** I just ran the file through a search and replace program and removed all the illegal charters so all is good. Quote from: Veltas on January 04, 2012, 09:30:49 AM A colon is not allowed in the name of a file or folder on Windows. So whether or not a batch file can read it, for this purpose it's irrelevant. You'll need to think of different names! Yeah I understand this fact, I was looking for a way to remove them in the batch file on the fly. |
|
| 690. |
Solve : need help about archiving batch? |
|
Answer» i have an idea so i wanna ASK is it possible i work with scanning pictures and i archive them in server in folder skenirani and then sub folders with name of media ex: r:/clipping_skenirani/globus or r:/clipping_skenirani/vest and there are .jpg files i want to archive in r:/bekap but not all pictures inside the media folders . ex: vest got pictures from 2 mount like 01_11_2011_vest.jpg and 01_12_2011_vest.jpg so basically i want to create batch file that will find and move to r:/bekap all the files containing mount ex: 01_11_2011_vest.jpg but not to move the files with 01_12_2011_vest.jpg and then to zip them in bekap folder bekap.zip. i try this way but something goes wrong it don't search in sub folders Look at xcopy. sismis: have you tried this? xcopy /? has ALL the answers you need.i have tried xcopy but still copies all sub directories in the skenirani directory instead only the files. i will continue using my old way using start find files and folder searching the skenirani with paramters *.jpg then select all cut paste in backup and zip them Quote from: sismis on January 04, 2012, 05:19:05 AM i have tried xcopy but still copies all sub directories in the skenirani directory instead only the files. i will continue using my old way using start find files and folder searching the skenirani with paramters *.jpg then select all cut paste in backup and zip them Right. My mistake. You keep doing it that way. Maybe one day you will actually read the basic help given by the /? switch and DISCOVER the /S switch, but until then let's pretend there isn't a way to do this. ok Quote from: BC_Programmer on January 04, 2012, 05:28:36 AM Maybe one day you will actually read the basic help given by the /? switch and discover the /S switch, but until then let's pretend there isn't a way to do this. I wish I had thought of saying that. Code: [Select]echo off cd /d r:\Clipping_Skenirani_Napisi echo Enter Search String set /p search=? for /r %%A in (*%search%*) do (copy %%A r:\bekap) "C:\Program Files\7-Zip\7z.exe" a -tzip "R:\bekap\%search%lala.zip" "R:\bekap\" It's a shame none of the built-in command-line utilities have the basic ability to copy a folder and file spec and all it's subdirectories and files. Would really be nice if we could change that ENTIRE script to far fewer LINES, if only XCOPY had a switch that could be used to indicate it should copy the files in the folder as well as recursively copy files and subdirectories in each of it's subdirectories. Oh well. I guess it's just another example of the type of low-quality software that microsoft releases. Just like how Word doesn't have basic mail-merge functionality or how Excel can't even do formulas, I tried, I put "5+5" in the formula box and it just says 5+5! That's false advertising right there. No of course I didn't read the manual. I think the issue was that the OP didn't want any of the subdirectories in the folder being copied to, just a long list of files. Anyway, s/he has the answer they are looking for, in multiple paths of execution, so hopefully we can just call this one solved. On another note, I can't even get Excel to recognize 1+1. It just keeps saying 1+1. Must be some really dumb people working at Microsoft to not know what 1+1 is. It keeps trying to tell me the "=" goes at the beginning. Every 1st grader knows the "=" goes at the end. Come on, that's just basic. Quote from: Raven19528 on January 04, 2012, 12:43:46 PM I think the issue was that the OP didn't want any of the subdirectories in the folder being copied to, just a long list of files. Xcopy would do exactly what they needed. If used properly. And if it had the fictitious switches, such as /S. |
|
| 691. |
Solve : Batch to add/delete based of *.>users? |
|
Answer» Can you assisted with commands or examples to get me STARTED? I needed to create a batch file to run based on a list of WINDOWS profile usernames to include the default profile. This batch file will be running in SCCM package. |
|
| 692. |
Solve : Create batch for making dirs with spaces? |
|
Answer» till now I've this |
|
| 693. |
Solve : batch string help? |
|
Answer» So I was trying to do the following: oooooh! String comparison in Windows command language (batch) is very simple. Everything is evaluated, so the quotes are part of the string and they have to be on both sides of the == section of the statement. You don't have to use quotes, although many people do, you can use just about any non-special character or characters (so not <>|% etc). C:\>set var=egg C:\>if (%var%)==(egg) echo yes yes C:\>if [%var%]==[egg] echo yes yes C:\>if {%var%}=={egg} echo yes yes C:\>if .%var%.==.egg. echo yes yes C:\>if $%var%$==$egg$ echo yes yes C:\>if abc%var%def==abceggdef echo yes yes |
|
| 694. |
Solve : Chained ifs within a for statement.? |
|
Answer» I am attempting to store a list of drives which possess a TEST directory in their root folder within a pseudo-array. For the purpose of this example, I would then want them read back. Question: If you feel the need to laboriously create pseudo-arrays, and you find batch syntax "cumbersome", why not use a language with proper arrays and cool looking code, like VBScript or, better, Powershell? This is the last bit of scripting needed now, though, and I'd really rather not learn a new language and then rewrite over 200 lines of script (some of it pretty convoluted) just to avoid ugly code. Quote from: Sirim on January 07, 2012, 12:05:30 PM Let's say I have have three drives: C:\, D:\, F:\ and I:\. I can count, honest. I added a fourth drive in when I wanted a second example, but forgot to replace the 'three' with 'four'. echo off for %%A in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do ( if exist "%%A:\" ( if exist %%A:\Test echo %%A:\Test EXISTS if exist %%A:\Info echo %%A:\Info exists ) ) The pseudo-array CREATION was required; the echoing it out was just for the example. Working code below: Code: [Select]echo off Set foldercounter=0 for %%A in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do ( if exist "%%A:\" ( if exist %%A:\Misc call Set folder_%%foldercounter%%=%%A:\Misc & Set/a foldercounter+=1 if exist %%A:\Test call Set folder_%%foldercounter%%=%%A:\Test & Set/a foldercounter+=1 ) ) if %foldercounter%==0 goto end set foldercounter2=0 :loop set foldermalformedname=folder_%foldercounter2% call echo/%%%foldermalformedname%%% set/a foldercounter2+=1 If not %foldercounter%==%foldercounter2% goto loop :end |
|
| 695. |
Solve : FreeDOS to Linux boot with a custom restore CD? |
|
Answer» I have a arcade game. It is called Deal or No Deal and it gives out tickets when you win. It is made by a company called ICE Game. The motherboard went bad for second time and I can't find the same model as a replacement. ICE wants almost $1000.00 for a replacement computer. This is a common problem with their gear and I think it goes back to the bad Capacitors that plagued many computers. On the batch file listed above, this is the first part. I can try to explain how this is working, but I don't know where to start on helping with your overall issue. rem Check for memdisk existence, errorlevel 1=found ; 0=notfound -> This line is a remark, it does nothing in the program itself. set dest=A: -> This is setting the 'dest' variable that is used later in the program. if "%OS%"=="Windows_NT" goto begin -> The variable 'OS' holds the current operating system this batch file is run in. If it is a 'Windows_NT' operating system, then it simply jumps to the :begin label. if not exist a:\freedos\ifmemdsk.com goto begin -> This tests to see if the file exists. If it does not exist, then it jumps to the :begin label. a:\freedos\ifmemdsk.com -> This simply starts the identified process. It gives control to that process, and will not continue until the process closes. if errorlevel 3 goto begin -> This tests the errorlevel, which is increased anytime a process has an unexpected output, and jumps to the :begin label if true. If the ifmemdsk.com process had three unexpected outputs, then the errorlevel would equal 3. (Errorlevel is something I'm not overly familiar with, and this is from my basic understanding on errorlevels.) if errorlevel 1 set dest=B: -> Same as above, only testing for a different errorlevel and setting a different value for the 'dest' variable if true. goto begin -> Jumps to the :begin label. I hope that helps. If you have any questions on the explanations, please ask. Quote from: uriahsky on January 04, 2012, 04:59:17 PM rem Check for memdisk existence, errorlevel 1=found ; 0=notfound It seems to change the initial value of dest to SUIT the case. If memdisk exists and %OS% doesn't expand to Windows_NT then dest = B: Otherwise dest = A:So it is checking for memdisk and if it is found it sets the dest variable to B and if not to A? Then the part where %os% ==windows nt. Is it looking somewhere for "OS" to be set as "Windows NT" or something else? Where is "OS" going to be set? But either way it is basically moving the program onto the "Begin" But then in the begin part under if "%dest%"=="B:" echo Please insert a (non)empty formatted diskette in your diskette drive. if "%dest%"=="A:" echo please remove bootdisk and insert a (non)empty formatted diskette in your diskette drive These things are being done automatically. But how? Did I miss a start up file? It is echoing a command for the user but I never do anything during the installs. If a computer is booted with a CDROM is it the AUTORUN.INF file that is read or could it be any of these. Boot.Catalog Boot000.Catalog DFSDOS.EXE ISOLINUX.BIN LVM.PD1 MAKEITSO.BAT RESTORE.DFS PART0IMZ VSSVER.SCC Those are the only other files in the directory. The MAKEITSO.BAT consists of isolinux\buildcd\mkisofs -o ..\explet.iso -N -l -no-iso-translate -relaxed-filenames -R -r -boot-info-table -iso-level 3 -no-emul-boot -b isolinux.bin .\ But where is this getting called? Thanks, I have learned a few things already. Russ Quote from: uriahsky on January 04, 2012, 07:16:21 PM Then the part where %os% ==windows nt. Is it looking somewhere for "OS" to be set as "Windows NT" or something else? Where is "OS" going to be set? %OS% is an embedded variable. Certain variables are made available as soon as cmd prompt is started, and %OS% is one of them. %Windir% is another one that is available in cmd prompt, and holds the file location of the windows directory. So if you installed everything on your system with default settings, %windir% will be "c:\windows", but if you installed your Windows onto a D: drive, then %windir% would be "d:\windows." %OS% holds the operating system that is detected when cmd prompt is started. Which means if it detects that a "Windows_NT" operating system (which I believe is what any version after Win 98 will have), then it will jump to begin. The big caveat on all of this is that none of these variables will be available in MS-DOS, so what should happen is Code: [Select]if "%OS%"=="Windows_NT" goto begin will expand to Code: [Select]if ""=="Windows_NT" goto begin and the program will continue by looking for ifmemdsk.com in the a: drive. What it is essentially doing is making sure that you do not try to overwrite the disk that is running the startup program.Thank you, I had no idea about the embedded variables. I have ran through this disk a number of times and I found a way to step through all of the .bat files. It looks like the first part loads drivers for the the CD, and does a few other things then makes about five partitions and then puts linux into one of them and then that is where the Nvidia drivers come into things. So, I may need to focus on the Linux part to figure out how to change the Nvidia driver. |
|
| 696. |
Solve : Batch File help for Beginner? |
|
Answer» Hi All, |
|
| 697. |
Solve : Tokens and Delims??? |
|
Answer» I have been using BATCH FILES for a while now, but I have not learned what or how to use the tokens and delims and I have a feeling that they are very useful. Can SOMEBODY please FILL me in, thanks. Tokens are sections of a string, separated by delimiters. |
|
| 698. |
Solve : Retrieving filepaths from a directory and performing analysis on them.? |
|
Answer» Hi all, Also, on a related note, when extracting the filename from the path (although I usually need the path, sometimes I need the name), I am using the cumbersome line I don't know why you call that "cumbersome". It's a one line method of getting the name and extension. That's about as "neat" as NT batch scripts get. Question: If you feel the need to laboriously create pseudo-arrays, and you find batch syntax "cumbersome", why not use a language with PROPER arrays and cool looking code, like VBScript or, better, Powershell? What is your objective with that script? THANKS very much, Salmon Trout, that does the job wonderfully. I'm using this strange method because I'm that bad at writing batch files. If there's a better way of doing what I'm trying to, I'm happy to hear it, as I indicated in my first post. The reason I chose to use a normal MS DOS batch file is because I've used them before. Not a particularly good reason, admittedly. Quote from: Salmon Trout on January 05, 2012, 01:12:16 PM "with the 2>nul removed" - did you mean like this? Yes, exactly. As for why I'm doing this, the script will feed an unknown number of files into an application (amongst other things). As I've stated, the code I wrote was just an example showing what I was trying to achieve, without my putting the FULL code in. See above! I edited my post while you were answering. Quote from: Sirim on January 05, 2012, 01:51:23 PM The reason I chose to use a normal MS DOS batch file is because I've used them before. Not a particularly good reason, admittedly. A very poor reason coming from an apparently intelligent person! By the way, this is not "MS-DOS". please read multiple edits to my reply no.1 above Your updated solution also works perfectly and is neater, thanks. When I said it was cumbersome, I was referring to the way in which I'm essentially using the for statement to convert a normal variable into the %%[letter] form, so that I can then extract the filename using %%~nx[letter]. I'm only creating a pseudo-array because I can't think of a simpler way of doing it. Again, I emphasize that I'm not skilled at working with these files. Quote from: Salmon Trout on January 05, 2012, 01:55:18 PM A very poor reason coming from an apparently intelligent person! Sorry. You're completely right on both counts. Would cmd.exe batch files describe them well enough? Quote from: Sirim on January 05, 2012, 02:25:16 PM When I said it was cumbersome, I was referring to the way in which I'm essentially using the for statement to convert a normal variable into the %%[letter] form, so that I can then extract the filename using %%~nx[letter]. The FOR command was designed for exactly that kind of task. If you check the help (type FOR /? at the prompt) you will see all the ~ variable modifiers. They also work with single percent parameters, %0 (special) and %1 to %9 Quote Would cmd.exe batch files describe them well enough? Yes, or "NT family command scripts". Your code is not "bad" at all, it is very intelligent. |
|
| 699. |
Solve : Beginner needs help, in renaming a lot of files.? |
|
Answer» Hello, |
|
| 700. |
Solve : enter character recognized as character? |
|
Answer» Hello, Pardon my grammer.Yeah, it was getting ROUGH near the end there. Again, we don't know for sure the language, which makes it difficult to tailor the response to help you specifically. In VBScript, if you are wanting one line of code to display multiple lines of output, you can use the carriage RETURN to do so: Code: [Select]wscript.echo "This is how" & VBCRLF & "you can get" & VBCRLF & "multiple lines of text" & VBCRLF & "with one line of code" which would display Code: [Select]This is how you can get multiple lines of text with one line of code Running this strictly from the command line though, I recommend trying this, though I have no idea whether or not it will work. Code: [Select] im createissue --hostname=mks-psad-test --port=8002 --user=blabla --password=xxxxxx --type=issue --field=Summary="Summarize your requestdd" --field=Description="Describe your request" & VBCRLF & "new" & VBCRLF & "line" & VBCRLF & "again one" --field="Issue Type=Change Request" --field="Project=/Tool_Support" --field="System Element"=89462 --field="Stakeholder Reference"=blabla Quote from: Geek-9pm on January 23, 2012, 02:02:56 PM I hope this is of some help. Pardon my grammer. I will pardon your grammar but I refuse to pardon your spelling of grammar. Quote from: mibushk on January 23, 2012, 03:47:58 AM im createissue --hostname=mks-psad-test --port=8002 --user=blabla --password=xxxxxx --type=issue --field=Summary="Summarize your requestdd" --field=Description="Describe your request This looks like MKS Integrity Manager which... Quote [...] provides a command line interface (CLI) to manage users, groups, and permissions; and issues. Unlike Source Integrity Enterprise Edition, the Integrity Manager CLI does not yet provide the same functionality as the graphical user interface (GUI) or Web interface, and only a few command line interface commands support GUI interaction. At this time, the command line interface provides basic Integrity Manager functionality. For complete functionality, use the graphical user interface or Web interface. Quote im createissue [--addAttachment=value] [--addRelationships=value] Really you need to consult the MKS Integrity documentation and see if the app even supports embedded newlines in the relevant parameter string. If this is your job, to write front ends for MKS Integrity, how come you do not have access to all the relevant documentation? Unless the Integrity app supports some kind of embeeded newline indicator, e.g. \n I can't see how you are going to do this. Quote from: Geek-9pm on January 23, 2012, 02:02:56 PM But you do have to indicate how items are exasperated I have seldom read such profoundly wise advice. Quote from: Salmon Trout on January 24, 2012, 01:13:40 PM some kind of embeeded newline indicator some kind of embedded newline indicator |
|