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.
| 7201. |
Solve : How to send just one line from a ping result to a log-file?? |
|
Answer» How do i send just one line containing one specific word, let SAY "TTL" from a ping result to a LOG-file? omittance Omission Sorry! Proud to be a NORWEGIAN! |
|
| 7202. |
Solve : running a .com program wiht a batch file? |
|
Answer» I am working on automating a .com file. I think the bast way to do this is with a batch file, but I'm open to suggestions. Once called the .com file asks for 3 user inputs. I can't figure out how to mimic the user There are free keyboard/mouse macro creators out there. I bought the one from JitBit which can mimic users and fully automate processes like this, especially if the information that is entered is static ( never changes ). This type of AUTOMATION can be used for good or evil as for Jitbit allows for you to create stand alone macros as EXE's which can run on systems that dont have the software installed. I have only used this software for the good of automation myself such as creating macro's that run as automatic installers that I can launch from thumb drive and have my own complicated unattended automated installs in a corporate environment to multiple systems at the same time after going through a single install with the macro software recording every action and time delay between actions. I tried all the free macro utilities out there for automating keyboard and mouse and none were stabile enough to put trust into them on a corporate network until I found JitBit which was worth the money. ( Currently using it to automate part of a GAME that requires about 2 hrs a DAY of grinding. I now have a routine that does this gind on my system unattended and I can go back later and spend my in-game virtual money etc to progress further and only have to endure the 30 minutes a day of a fun game that is the fun part and skip over the boring grind part. ) http://www.jitbit.com/macro-recorder/ |
|
| 7203. |
Solve : Batch file to copy and Increment? |
|
Answer» After wasting far too much time trying to figure this out I thought I'd just ask. I'm trying to write a batch file (OS is WInXP) that will copy (or use xcopy) one .txt file from 1 directory into another directory on a different drive and then increment the file name so I have several backups of the original file. This is simple DOS stuff but I'm stumped never having WRITTEN batch files. Any help would be greatly appreciated. David....This will date and time stamp a file. That's much more useful than a plain number. The first four lines of this code will give you reliable YY DD MM YYYY HH Min Sec variables in XP Pro and higher. Code: [Select]@echo off for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a" set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%" set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%" set "fullstamp=%YYYY%-%MM%-%DD%_%HH%-%Min%-%Sec%" copy "c:\folder A\file.txt" "c:\folder B\file-%fullstamp%.txt" >nul pauseset destination=C:\Dummy\ set Location=D:\Dummy\Test.txt set FILENAME=Test set a=1 :LOOP if exist %destination%\%filename%_%a% set /a a+=1 && goto :loop copy %location% %destination%\%filename%_%a%.txt Untested Though what foxidrive say's is true, a date\time would be much better for you.Thank you both for your efforts. I will most likely use the one that adds the date stamp but I also like the one that adds -1 to the file name. Is there a string I can add to that batch file where it will increment file name (filename-1.txt, filename-2.txt, -3.....etc)? Not in one command, I CREATED a loop that would increment a variable (%a%) by 1 each time it ran, then had it copy the file X times saving it with "-%a%" at the end. This would be the way I would do it, but I'm sure there are may other ways to complete the task. |
|
| 7204. |
Solve : DOS Internet program? |
|
Answer» Hi guys I'm new to the forum and I was reading some of the topics and I didn't see anything that would help me. I am trying to make a PROGRAM that when I double click on it from the desktop or press a button on my keyboard it goes to a specific url, but when I do this I get this, |
|
| 7205. |
Solve : xcopy and Windows 7? |
|
Answer» I just bought a Samsung Ultrabook with Windows 7 Home Premium. I use Dos batch files to backup my data but these files do not seem to work. I went into the Dos command PROMPT and tried to use the xcopy command, but I get a reply: xcopy is not a recognized internal or external command... The same goes with robocopy, though both of them should be available in Windows 7. The copy command works, but I need a command that would allow me to copy also subdirectories (switch D) and leave unchanged files alone (switch S). Salmon Trout: surely the error would be different if it was a permissions issue. A good point; the OP said he "just bought" the ultrabook; if it is brand new you would expect the PATH system variable to be still set to the default and therefore find xcopy and robocopy. Maybe Fabricious should type PATH at a prompt and tell us what he or she gets? If a new variable, carelessly called %path% is in existence, that will screw things up. Or a rogue program installer could have mangled it. Fabricious are you sure that isn't Win7 Starter ?/ ? ? Hi Fabricius! I am a newbie at this and do not know MUCH. But I would like to try and help. Maybe you get this strange comment "xcopy is not a recognized internal or external command" because you haven't used it correctly (I imagine and HOPE MS-DOS is properly emulated even in Windows 7) I really don't know (runs XP) but I think you should be able to, in the command prompt, run: xcopy c: e: /d /s if you want to copy all new files (with respect to the residing files in the destination drive, here called e:) from c: to the destination drive, e: Using the /d-switch will thus enable copying of new files only and Using the /s-switch will enable copying of all subdirectories. Actually I think I will use this command the next time I want to back-up my music. Because I do not want to wait another two hours for all my 5GB music to be copied and Windows actually sucks at this kind of synchronization. MS-DOS rules! Best regards, RogerQuote from: patio on November 04, 2012, 09:39:41 AM Fabricious are you sure that isn't Win7 Starter ?/ ? ? +1, I'm not 100% sure but it would MAKE sense that Win7 Starter doesn't have Xcopy or RoboCopy installed, and netbooks almost always come with the Starter Edition.Hi! I would like to refrase my command to: xcopy c:\path_S e:\folder_D /d /s where path_S is the path to your folder which you want to copy folder_D is the folder you want to create and/or copy to (I think you will be prompted if the folder does not excist) /d is the switch that makes all the files that are newer than the files in the destination folder (folder_D) being copied /s is the switch that makes all the subdirectories in the source folder (path_S) being copied The above destiction is neccesary due to the fact that xcopy cannot copy itself (yields a so called sharing violation). Good luck! Best regards, Roger PS If you want to copy to a simple USB-stick, destination drive might differ from e: Personally I ignored your post since it doesn't even come CLOSE to addressing the Original Poster's problem. |
|
| 7206. |
Solve : Redirecting in DOS BAT Files? |
|
Answer» I am running Windows XP, SP3. The output of the VER command from the Command Prompt window is Microsoft Windows XP [Version 5.1.2600]. |
|
| 7207. |
Solve : Mapping more than one folder to a drive using SUBST?? |
|
Answer» HELLO, I was wondering if there is a way to map two different folders to be in the same drive letter? For EXAMPLE, I have this folder: C:\dir1\dir2 And this folder: C:\dirA\dirB I would like to have the dir2 and the dirB directories SHOW up on a new virtual drive. Is this possible? I cannot seem to find any examples of it, so I am assuming it is not possible. Can I simply map them both to the virtual drive? Or will this create a major conflict? THANKS, K. It will not let you add a second folder to the SUBSTed drive. You will get an error message like the following: c:\>subst h: d:\folder c:\>subst h: c:\files Drive already SUBSTedWhat version of Windows are you using. You could possibly do it as a symbolic link if you are using Vista or 7. On XP you would need to install a 3rd party utility. Well not really THIRD party considering MS bought sysinternals a few years ago. You can download the Junction utility which will allow you to create links for directories. And just saw this for the first time. A shell extension for Explorer. http://schinagl.priv.at/nt/hardlinkshellext/hardlinkshellext.html |
|
| 7208. |
Solve : Copy Folders Within a Folder? |
|
Answer» Quote from: powlaz on December 05, 2013, 01:27:18 PM Salmon TROUT - I UNDERSTAND. And I'll be back. You've always helped me. And will CONTINUE to do so. PLEASE ask about anything and if I can help I will. |
|
| 7209. |
Solve : How to state directory in xcopy MS-DOS command? |
|
Answer» Hello guys.. |
|
| 7210. |
Solve : Batch file to Delete some files in a folder? |
|
Answer» Hi , |
|
| 7211. |
Solve : BAT file to copy last modified file? |
|
Answer» Below is a script I use to find the last modified file to copy it and put into another location. I will adjust the code in case somebody else is having a similar issue or looking to do the same thing. Thanks for sharing that ... I have generally just used xcopy /s/d/y to make a copy of contents to an alt location over network to another system and the newest, last modified file is transferred to the alt location when date/time stamp changes when its last saved/modified, and all files that haven't changed and are a match between source and destination are skipped from transfer. Neat that this just transfers that 1 file. *I may have a use for your batch to copy only the newest last modified file from one location to another, where this game called Poker Night 2 hosted by Steam, created by Tell Tale Games, has a corruption flaw in its code that many people are experiencing with no help from Steam or Tell Tale Games Co. And currently the only way to fix the problem is to uninstall and reinstall the game each time this happens. If I can detect what file was last written to before the crash occurred, I can then single out the one file that is getting corrupt and may find the one file that is causing the crash. I was going to perform a file compare between the normal install and known good replicated location to find what file was last altered between A and B and single out that way, but your batch LOOKS like a better method. Knowing which file is the cause... I can then make a bugfix for people to use since Steam and Tell Tale Games are ignoring requests for help on this flawed game. Some people are so mad about this when searching for a solution to this that they feel that legal action should be taken, over either a game that is poorly programmed and TROUBLED, or Steams client integration flaw that is causing the game to corrupt and fail. |
|
| 7212. |
Solve : Batch File Shutdown bug solution? |
|
Answer» I am new to computing forums. Please BARE with me if what I am about to tell you is common knowledge. |
|
| 7213. |
Solve : BAT file to move folders into current month folder? |
|
Answer» I am new to the forums and I have recently started working with bat files, so please bear with me. I am using Windows 7 and currently have a batch file that pulls reports and stores them in a directory that we will call "C:\My Document\Current Reports". Inside the Current Reports directory, I have another directory that is labeled Archives, and inside Archives are the folders labeled by months as shown below. Each day my batch file pulls new reports and moves yesterday's reports to the archive FOLDER. Rather than STOPPING there, I am wanting it to place the folder into the current month. I have a folder for each month labeled as follows: |
|
| 7214. |
Solve : DOS and the Web? |
|
Answer» Hi, |
|
| 7215. |
Solve : How to delete a file by searching for part of the file name?? |
|
Answer» I would like to delete a file by searching for part of the file name. (Example: Test.txt, test123.txt, testing123.txt) I would like to delete anything that has "test" in the file name.your examples show that the filename always starts with test but your description says "in" the filename. So does 123testing.txt qualify as well.Thank you for your reply. "123test" will qualify as well, but most likely won't have a file like that. This is just an example, but not the real file that I'm trying to remove. This is the script that I currently have, but I'm LOOKING for the variables that the file may have in it. There are certain cases where there is random text after "ALLDATA Repair - ". I need to search for "ALLDATA Repair - " on the desktop that is a .url file. Your help is much appreciated. There are certain cases where there is random text after "ALLDATA Repair - ". I need to search for "ALLDATA Repair - " on the desktop that is a .url file. Try this" del /Q "%userprofile%\Desktop\ALLDATA Repair - *.url" Thank you Foxidrive, this worked! |
|
| 7216. |
Solve : Need help with my BATCH file? |
|
Answer» The purpose of this batch file is to FTP (PUT) a file to the server, then (GET) the file back to the client machine, then do the a file COMPARE between the original file and the file that was just received from the server to ensure that the file is not corrupted. |
|
| 7217. |
Solve : Modifying Internet Shortcut URL Path? |
|
Answer» I have a .bat file that removes an existing shortcut, then creates a new shortcut. The problem is that the old URL path doesn't change. If there is no existing shortcut, the path is correct. I'm not sure why this is happening. |
|
| 7218. |
Solve : command to check file version in batch file??? |
|
Answer» Hi All, |
|
| 7219. |
Solve : How can I edit registry settings?? |
|
Answer» I'm able to remove options for Delete Browsing HISTORY settings, but I'm having issues with adding options in. I want to make sure that the following are checked: Temporary Internet Files, Cookies, History. I'm currently using a REGISTRY file that I exported, then using this SCRIPT. |
|
| 7220. |
Solve : How to know a service is running or not using DOS? |
|
Answer» HI, |
|
| 7221. |
Solve : Need help on CMD.. if your good enough? |
|
Answer» Im awful at CMD prompt, ok, basicly.. i need a cmd syntax that will ALLOW me to find a certain FILE type, under 10kb in size , then LOG that filename in WORD or notepad or whatever.. does anyone know how to do this or if its even possible?That kind of subject line isn't going to woo too many PEOPLE to help you. |
|
| 7222. |
Solve : Delete all lines with certain words in a .txt file? |
|
Answer» hey guys, |
|
| 7223. |
Solve : Major Goof? |
|
Answer» Hello all, I installed the lastest win 2000 service pack, and when I restarted, windows WOULD never boot, kept rebooting. NONE of the safe mode options would start windows. I mean none. So I used a recovery disk (purchased off the internet) and the goofball I am, deleted, everything except dos.(reformat, partition) All right, heres the question: is there any dos command that would enable me to restore, recover, or undelet ( I never backed up the system . Just for SEARCH sake for others looking for the same thing: win 2000 windows 2000 professional deleted windows OS system restore undelet.Restore, recover or undelete What?? If you have FORMATTED then you need to get a file recovery program something like RESTORATION which MAY be help. BUT by installing an OS on your current hdd you WILL overwrite some of the deleted files. Can you slave your disk in another pc and try file recovery from there? From what you SAY you will eventually have to re-intall your OS so you will have to Bite-the-bullet at some stage and re-install all your application progs etc... |
|
| 7224. |
Solve : file name with apostrophe? |
|
Answer» I have created an MS DOS batch file that backs up files in folders from one drive to another drive. I fear that if I rename the folder I will lose all of the information that I connected to the pictures from within Picassa. You might be able to alter the folder name in Picassa itself. Make a full backup first though.I think I got logged out before sending my reply so I'll try again... Thanks for your SUGGESTIONS. I had not thought of trying to change the name of the folder from within Picassa. Since that might be real simple I'll start there. Thanks again for your help. KeithI was able to change the folder name from within Picassa!!!! My batch backup program now works perfectly!!! Thank you very much for your help... KeithGood one Keith! Thanks for the followup |
|
| 7225. |
Solve : MsDos Command To Delete C Drive? |
|
Answer» I WANT To Change Operating System From Win95 ToWin98. I Need To DELETE C: What Is The MSDOS Command To Do This.format c:How to install Microsoft Windows 98 |
|
| 7226. |
Solve : More for loop help >. |
|
Answer» So I DECIDED to restart my program after DROPPING it for awhile. So for the problem I'm stuck on, I need to grab some strings from diffrent points in a text file (I now exactly where) and set a veriable equal to them. So basicly, I need to set everything on the right of the ':' to a veriable that is named something similar to the what is on the left of it. Here's an example of the text file: Name:LemonillaSo far I've got a for /f loop that isn't quite working the way I want it to , It seems to reset the same veriable all the diffrent values, so instead of setting %Name% equal to Lemonilla, It ends up being 1 (as that is the value for the last executed loop, Time). Here is my failed attemp, I feel like i'm just putting the wrong stuff in the "s. Code: [Select] ::ConfermSave.LoadSave.start for /f "tokens=1-6" %%D in (%save%.txt) do ( set a=%%D set name=!a:~5,100! set a=%%E set Urels=!a:~6,100! set a=%%F set Yuin=!a:~5,100! set a=%%G set Wenarduls=!a:~10,100! set a=%%H set location=!a:~9,100! set a=%%I set _Time=!a:~5,100! ) Where %save% = 1.Code: [Select]@echo off FOR /F "tokens=1,2 delims=:" %%G IN (1.txt) do set %%G=%%H echo %Name% echo %Urels% echo %Wenarduls% echo %Location% echo %Time% pauseOutput Code: [Select]C:\Users\Squashman\Batch\for_loops>loop.bat Lemonilla 50 0 Tipa 1 Press any key to continue . . . C:\Users\Squashman\Batch\for_loops>>.< I guess I was thinking too hard... Thanks for the help!I wouldn't say you were thinking to hard. You just were not understanding how for loops parse text files. Your code makes me think you thought the for loop parses th whole text file at once which it doesn't. It processes one line at a time.Quote from: Squashman on DECEMBER 01, 2012, 11:11:40 AM I wouldn't say you were thinking to hard. You just were not understanding how for loops parse text files. Your code makes me think you thought the for loop parses th whole text file at once which it doesn't. It processes one line at a time. From the FOR documentation (type FOR /? at the prompt:) FOR /F ["options"] %VARIABLE IN (file-set) DO command [command-parameters] FOR /F ["options"] %variable IN ('string') DO command [command-parameters] FOR /F ["options"] %variable IN (`command`) DO command [command-parameters] file-set is one or more file names. Each file is opened, read and processed before GOING on to the next file in file-set. Processing consists of reading in the file, breaking it up into individual lines of text and then parsing each line into zero or more tokens. The body of the for loop is then called with the variable value(s) set to the found token string(s). By default, /F passes the first blank separated token from each line of each file. Blank lines are skipped. ... No fair, I was really tired that day |
|
| 7227. |
Solve : Ping batch? |
|
Answer» I want to make a batch/command file that will ping multiple IPs and save , "time=" from each ping from each IP, into a .txt file. |
|
| 7228. |
Solve : An interesting link? |
| Answer» http://lists.gpick.com/pages/MS_DOS.htm | |
| 7229. |
Solve : setting STDIN for NET TIME command when running from a batch file.? |
|
Answer» I thought this WOULD work: |
|
| 7230. |
Solve : can´t edit autoexec.bat or cofig.sys? |
|
Answer» my problem is that I open the editor and modify the file but when I try to save a messaje appears . Something like unable to save because it might be protectd against writing. Is there any way to go arround this protections |
|
| 7231. |
Solve : Excel help with updating data? |
|
Answer» Hello, |
|
| 7232. |
Solve : Dynamic environment variable substring offset & length? |
|
Answer» I wrote the FOLLOWING, and am having trouble at the indicated location: |
|
| 7233. |
Solve : Global variable in batch file? |
|
Answer» Hi, |
|
| 7234. |
Solve : Batch code works in XP but not in Win7? |
|
Answer» The following line out of my backup batch, that saves 20 copies of a particularly important file, has worked well for years in XP. However it fails to work in Win7. Any Pointers please. The following line out of my backup batch, that saves 20 copies of a particularly important file, has worked well for years in XP. However it fails to work in Win7. Any Pointers please. It doesn't save 20 copies of a file. It deletes folders. What does it do in XP that it doesn't do in Win 7?Sorry, perhaps I should have described the whole batch file in full. Here goes When the whole file runs in XP, it backs up a folder in C:\ that contains what to me is important data about my website, that is constantly changing. First it copies the whole folder and sub folders, then it renames that copy to be file+date+time. Then it deletes more than 20 copies of those renamed folders, so my HDD doesn't get full. And it has worked well for quite some time. It is the last bit, the DELETING bit that is not working in Win7, where it runs though all the contained files in the folders to be deleted, and PIPES them as "Access is Denied" Any chance that you can help please - Mal Quote from: MalA on November 30, 2013, 04:45:02 AM It is the last bit, the deleting bit that is not working in Win7, where it runs though all the contained files in the folders to be deleted, and pipes them as "Access is Denied" "Access is denied" could be caused by Windows 7's UAC (User Account Control), the lack of administrative privileges, or the file you're trying to delete could still be in use.I would also set up the batch file to "run as admin" in preferences if its not a file in use issue."Access is Denied" comes also when another program has the file open. The below link shows it can happen even if you try bop open a folder. http://support.microsoft.com/kb/810881 NOTE: The issue is specific to XP and applies when you re-install XP. This is a must read for anyone wishing to continue using XP as their OS.Quote from: MalA on November 30, 2013, 04:45:02 AM When the whole file runs in XP, it backs up a folder in C:\ Later versions of Windows don't allow users access to c:\ without Admin perrmissions, even if UAC is turned off. Pick the "%userprofile%\desktop\tempfolder" and it should work fine.foxidrive, Thanks for correcting me.His problem is in Windows 7, not in XP. OOPS. Here is a general article on UAC in Windows. http://en.wikipedia.org/wiki/User_Account_Control Quote ... MALWARE should be kept from compromising the operating system. In other words, a user account may have ADMINISTRATOR privileges assigned to it, but applications that the user runs do not inherit those privileges unless they are approved beforehand or the user explicitly authorizeWriting to the root of the system drive is forbidden, just as foxdrive stated. |
|
| 7235. |
Solve : Can't install from path set in a variable. Must be wherever batch file is? |
|
Answer» I am creating an automated, silent installer for all of my programs. This installer will be executed before Windows DESKTOP loads (setupcomplete.cmd) |
|
| 7236. |
Solve : Single line code? |
|
Answer» Hello, It works fine for me. And me. And I have Win7 Home Premium 64-bit. Do you (the OP) have User Account Control turned on or off, and what WARNING level is it at?I tried it on my wife's machine (also 64bit win7 home premium) and also works. Both machines have the User Account control setting to minimum (never notify). So, there must be something in my machine's setting? ThanksFWIW, the only thing it does is change the titlebar to say NONADMIN, the color is actually the same as the defaults. What does bcdedit do when you execute it as non-admin?Also, saying it "doesn't work" is a bit vague- what actually happens?The color could be changed in the line to (color 07 && title NONADMIN) so that a non admin command prompt should change the background color to blue and the title to NOADMIN. On my machine this does not happen. The background color and title does not change (for a non admin command prompt). My wife's computer works fine. Try typing color 07 in cmd and see what happens... you must have meant color 17 if you WANTED blue. Change that and see what happens then.I did that and posted my previous post. My machine does not go that part of the code. If you run 'bcdedit' in a non admin command prompt you get a message: "'bcdedit' is not recognized as an internal or external command. Made some other test and in this case cames up with an errorlevel of 9009 on my machine. On an andmin command processor the errorlevel is 0. Now, for some reason my machine started to work. Ok, for the next step. In the registry, \HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Command Processor If you create a REG_SZ key, name it 'AutoRun' and the line bcdedit /enum >nul 2>nul && (color FC && title ADMIN) || (color 17 && title NONADMIN) as the value, the colours should come up as the white background for an admin command processor and blue for non admin command processor. Both my machines now behave the same. The admin command processor is white but the non admin command processor is black. I thought that if the code worked in a batch then it would work here also. I think I know what causes this latest problem. I LAUNCH the admin command processor from a shorcut to cmd.exe. I launch the non admin command processor using DropMyRights. Being launched by DropMyRights, the command processor probably doesn't go through the registry key. So the line of code is not processed. I think.1. You can use a number of commands that will fail if you are not in an admin prompt, for example reg query "HKU\S-1-5-19" 2. You don't need double ampersands like here (color FC && title ADMIN). A single ampersand is a command separator whereas a double ampersand or double pipe is an errorlevel test. Command1 && Command2 means "execute Command1 and if the errorlevel is zero, execute Command2". Command1 || Command2 means ""execute Command1 and if the errorlevel is not zero, execute Command2". So you can just use (color FC & title ADMIN). Color FC should ALWAYS return an errorlevel of zero, if it doesn't you have some problems to sort out! |
|
| 7237. |
Solve : Bat file issue with spaces? |
|
Answer» Hi, I'm pretty new to batch files, so I may not be doing it perfectly right, but anyway, I have this: |
|
| 7238. |
Solve : extract a string from multiple files? |
|
Answer» I'd like to extract a string (STARTING at pos 27, length 25 chrs) from MULTIPLE text FILES and log it to another file (log.txt). |
|
| 7239. |
Solve : Duplicate and rename single file in a large number of folders? |
|
Answer» In my music library, I have organized my folders in the FORMAT: Artist/Album/01 song title.mp3. Within each Album, I have a folder.jpg for the album art. I am upgrading my media server in my house, and the new system wants to have both a folder.jpg and cover.jpg in each album folder. My collection is fairly large (50,000 tracks), so manually duplicating each folder.jpg file and renaming it cover.jpg is impractical. |
|
| 7240. |
Solve : Files in a Folder? |
|
Answer» Hi All, |
|
| 7241. |
Solve : Game saving trouble? |
|
Answer» Okay, hello! New here, hope you can help. mkdir %~dp0\testfolder Quote apparently the %~dp0 makes it the drive, the path of the file and name of running file the location, but this seemed to glitch out, making a folder called 'stuff' (the parent folder of current folder is called 'game stuff') with a subfolder 'My' ('My game' is the folder with the batch in.) also a folder called %mylastname%. and the console window said something about problems with the folder C:\Users\%myfirstname%(confidentiality). which doesn't exist, plus some others of similar weirdness. Standard variable MODIFIERS documented in the FOR help (type FOR /? at the prompt) %~I - expands %I removing any surrounding quotes (") %~fI - expands %I to a fully qualified path name %~dI - expands %I to a drive letter only %~pI - expands %I to a path only %~nI - expands %I to a file name only %~xI - expands %I to a file extension only %~sI - expanded path contains short names only %~aI - expands %I to file attributes of file %~tI - expands %I to date/time of file %~zI - expands %I to size of file %~$PATH:I - searches the directories listed in the PATH environment variable and expands %I to the fully qualified name of the first one found. If the environment variable name is not defined or the file is not found by the search, then this modifier expands to the empty string The modifiers can be combined to get compound results: %~dpI - expands %I to a drive letter and path only %~nxI - expands %I to a file name and extension only %~fsI - expands %I to a full path name with short names only These work not only for FOR metavariables but also batch parameters %0 (which is special, being the batch file itself) and %1 to %9 (passed parameters) So you can see that %~dp0 is going to expand to the combination of: %~d0 the drive letter (with colon) on which the batch script is located (NOT necessarily the current directory) %~p0 the folder path to the batch script is located I believe the issue you have is not security, it is spaces in the path. If the batch script is located in a folder whose path has any spaces, you have to use quotes so try mkdir "%~dp0\testfolder" I see you USED quotes later on when echoing to testvar.txt 90% fixed! Stupid mistake that was! Problem now is that it doesn't read the file and just comes out with the random number again. The random number was just to test if it WOULD read the old one from the file and to make sure it wasn't just repeating what had just been entered instead of the file. Now I see that it doesn't read the file. Help? thanks again!This is one way to read line one of a file. Code: [Select]set /p "testvar="< "%~dp0\testfolder\testvar.txt" >nulChanged a bit. Somehow more broken than previous. code: Code: [Select]@echo off echo initializing.... mkdir "%~dp0\testfolder" set /p testvar = Enter test variable here: echo Will now save your variable to file. echo %testvar% > "%~dp0\testfolder\testvar.txt" echo Will now set active variable to random. set testvar = %random% echo variable is now %testvar% echo Will now load variable from file. pause set "testvar" < "%~dp0\testfolder\testvar.txt" >nul echo variable was: %testvar% pause The result: initializing.... Enter test variable here:sdfvgbh Will now save your variable to file. Will now set active variable to random. variable is now //Noteing that it isn't displaying the random number. Will now load variable from file. Press any key to continue . . . variable was: //Also blank Press any key to continue . . . Oh dear.... Remember if anyone knows an alternate way to save stuff to file and then read it when the game is next run tell me :L Just need it explaining well and simply. I posted just before you. You aren't reading the file correctly, and I posted one method. set testvar=and set testvar =two are two different variables.So, what would be the correct code? I inserted your line you posted and put spaces between the ='s and such. that's what I posted just then. set testvar=123 echo %testvar% Quote from: gogglebot on December 07, 2012, 12:56:25 PM I ... put spaces between the ='s This is what you should not do! Batch scripting language does not ignore spaces, unlike many other languages. Alright, Salmon you seem to better explain things rather than throw bits of code at me. What lines and such specifically need changing? Thanks@echo off echo initializing.... mkdir "%~dp0\testfolder" set /p testvar=Enter test variable here: echo Will now save your variable to file. echo %testvar% > "%~dp0\testfolder\testvar.txt" echo Will now set active variable to random. set testvar=%random% echo variable is now %testvar% echo Will now load variable from file. pause set /p testvar= < "%~dp0\testfolder\testvar.txt" echo variable was: %testvar% pause Quote from: gogglebot on December 07, 2012, 01:18:59 PM Alright, Salmon you seem to better explain things rather than throw bits of code at me. You, my friend, didn't say thanks to me for either post. If you want to learn to code, then expect to get lines of code in reply. It is up to you to study them. Quote from: foxidrive on December 07, 2012, 02:00:28 PM You, my friend, didn't say thanks to me for either post. I agree 100% with foxidrive. You can save one or more variable name/value pairs, separated by an equals sign, to one file (or create the file manually in an editor, or make a script generate them) and use FOR to retrieve them. c:\>echo animal=cat > datastore.txt c:\>echo colour=red >> datastore.txt c:\>echo country=Russia >> datastore.txt c:\>for /f "delims=" %A in (datastore.txt) do @set %A c:\>echo %animal% cat c:\>echo %colour% red c:\>echo %country% Russia This was done at the prompt; in the FOR line use double percent signs (e.g. %%A instead of %A) in a batch script. This is what datastore.txt contains animal=cat colour=red country=russia Handy tip: FOR skips lines starting with a semicolon. Actually the final line of datastore.txt is now country=Russia The name of Russia correctly starting with a capital R. (I edited the script but forgot to correct the earlier version I posted before) |
|
| 7242. |
Solve : New User Error? |
|
Answer» Hello All , |
|
| 7243. |
Solve : How to cmd into Firefox SQLite?? |
|
Answer» I know how to cmd into MS SQL by opening command and type cmdsql -S \(database name), but can I cmd into firefox's SQLite DB to add bookmarks to places.sqlite?Directly editing a web browser's db is *not* a GOOD idea... depending on the purpose you could export a bookmarks file and import it into the TARGET installation, or distribute a default profile with the necessary bookmarks. I'm sure firefox has APIs you can use, but i doubt that a script like that would (for example) work on all computers or future firefox versions.Smells slightly nefarious to me.Quote from: nfin8rider on December 10, 2012, 04:45:54 PM I know how to cmd into MS SQL by opening command and type cmdsql -S \(database name), but can I cmd into firefox's SQLite DB to add bookmarks to places.sqlite? Yes. use SQLite3. Specifically, the Command Line shell. Thanks for the [emailprotected] most situations, it would seem nefarious, but this is for my jobs website. We have these login loop issues caused by the url in the bookmarks or shortcuts. So I'm creating a .exe that will automatically change their settings so that our agents don't have to spend 30mins on each call walking them through setting up their browser. IE was very easy to MAKE changes to, but firefox is a beast for me. Any help would be appreciated!Thanx for the clarification...No problem, I love this forum, it has helped a whole lot since I've joined. I wouldn't want to jeopardize my privelages of being on here and RECEIVING the wornderful help from all of you. I definitely appreciate everyone on here, and hopefully one day I'll be able to reciprocate with helping others as all of you have helped me. Once again, I thank all of you very much!Hope you didn't take it the wrong way...we prefer to err on the side of caution.No, I didn't take it the wrong way. I completely understood your concern. I would have felt the same way as you did because I didn't elaborate further of my intensions of wanting the script. |
|
| 7244. |
Solve : Multiboot with different file systems & OS? |
|
Answer» Hi everyone, ... if you want to multi boot then one of the boot managers should be able to do it. This is a good Multiple Boot Loader. It's called OSL2000 Boot Manager. http://www.osloader.com/Thanks guys for all these ideas. I will try virtual PC at the weekend. I'm not sure why SATA drivers was mentioned. I have already partitioned 2GB with a FAT16 file system, formatted it and installed DOS 6.22. This was just as a test. My motherboard is actually a SBC - Single Board Computer - (a Robo 8779 AR2) in an industrial rack mounted system because I need to use a number of legacy 16 bit ISA cards simultaneously. The backplane in the rack is AT/ATX compatible and has 8 ISA slots and 6 PCI slots that are actively driven. Slot addressing is automatically set in BIOS. The SBC has the necessary SATA sockets and the hard drive, with DOS 6.22 installed, boots fine. I guess the SATA drivers were all loaded succesfully when I setup the chipset driver, audio, video etc with the manufacturer's supplied CD. My other main issue now, which has nothing to do with the partitioning question I asked about earlier, is communication with one of my 16 bit ISA interface cards that I want to install. This particular card is used to operate a spectrograph (Oriel MS125 with InstaSpec IV) under proprietary DOS software. When I installed the card, using default jumper settings (300H) and other defaults, the PC hung. I couldn't even get into BIOS ! I'm getting no support from the manufacturers Oriel Instruments (now Newport Instruments which became Thermo Corp. afew years ago) since it is a very old card and no longer supported. What I don't understand is why I can't even get into BIOS after pressing DELETE ?! Thanks Steve Steve .... just saw that this is related to your other ISA post for help. Knowing now the additional info, you might run into issues addressing those ISA cards with Virtual PC running a DOS environment. Reason why i say this is because the hardware in the virtual computer is mostly virtual, and I have used this environment successfully for running older software, BUT to address real physical hardware such as a real card in an ISA slot, that is all new territory and might not work out too well. In the past I have had to use redirection to get a virtual LPT1 printer port to PRINT over the network etc, and the stuff your working with is beyond redirection. You will need direct access to the cards in a real DOS environment I am guessing. I tried for example to run Ghost 2003 from within Virtual PC to address my Intel Pro 100 NIC in a PCI slot and it wasnt able to find the hardware, because Ghost with NDIS2 drivers was not able to connect with the hardware address of the physical NIC, so to the Virtual System running Windows XP Pro in which Ghost was running at the DOS level after a shutdown of windows and boot to Ghost, it was not able to see the real hardware of the computer and only its virtual hardware. ( most would wonder...why run Ghost within a virtual environment when you can SIMPLY just save a copy of the virtual machine as a backup for quick restoration. I was just bored one day had some time and was wondering if it would work, and it didnt. So I learned then that within the Virtual PC environment, it see's virtual hardware and the software bends it to work with whatever real hardware exists, but it cant bend it to address a NIC directly according to my experience at the DOS level. ) * If anything its good to get familiar with Virtual PC in case you need to run older software side by side windows, but when it comes to interfacing with real hardware, that is a weakness of Virtual PC unfortunately. Quote My other main issue now, which has nothing to do with the partitioning question I asked about earlier, is communication with one of my 16 bit ISA interface cards that I want to install. This particular card is used to operate a spectrograph (Oriel MS125 with InstaSpec IV) under proprietary DOS software. When I installed the card, using default jumper settings (300H) and other defaults, the PC hung. I couldn't even get into BIOS ! *Its best to keep the QUESTIONS located in the correct location. It was great though that you mentioned that this is related to the ISA issue post though since now I have additional info I didnt have when answering you earlier. If I would have known you had to address older cards, I wouldnt have suggested Virtual PC.Thanks Dave, I will bear in mind your advice in future regarding the location of posts - I am still quite new to the forum. I didn't get around to trying Virtual PC and actually I didn't believe it would solve my problem, which you have now confirmed. As you can see from the other post in the Hardware section, I have a tough problem to solve with this old ISA card. Computer_Commando and Lisa_Maree are helping me out with several suggestions and I will try their ideas at the weekend since I'm away from home and the problem PC right now. [ It's interesting in reading some of the comments how many people think that 16-bit ISA cards are obsolete dinosaurs that are gone forever. When you consider the mass consumer market these folks are absolutely right, of course. But what they do not realize is that there is a large secondary market for these cards, principally from industrial users but there are also private individuals like me, who still need support for these outdated interfaces. Brand new ISA cards are actually still manufactured today by several specialist companies who support industrial users who need these cards to keep their older industrial process control equipment and other machinery running. And dozens of these cards are available on sites such as eBay. ] Steve Quote It's interesting in reading some of the comments how many people think that 16-bit ISA cards are obsolete dinosaurs that are gone forever. From my background in service dept and manufacturing support as an ET in industrial controls with Allen-Bradley/Rockwell Automation/ Creonics as well as my current job with the USPS, while the majority of home computer users have left the older technology in the past in favor for faster computers with more bells and whistles. There are many businesses out there with older controls and systems etc that are running 15+ year old electronics. Reason being why fix what is not broken, as well as some businesses can not afford the money it would cost to upgrade to a newer PIECE of machinery. Usually you can update some of the older electronic components with newer ones such as when dealing with PLC's etc, but in some cases there are no replacement to the original electronics or the replacement to the original electronics to become modernized is too costly, so you end up running older hardware and either servicing it in house or sending it out for service as well as buying used parts/systems to keep your equipment going. At the USPS where I currently work we still use VMS OS and old DEC ALPHA systems as an example of using old hardware for modern day mission critical application. Sure this could be replaced with new, but what they are using is still working so it makes sense to keep running it vs spending millions of dollars to bring the system forward among all post offices and still end up with the same setup and nothing to gain. There is no advantage to moving the hardware forward for this application, the hardware is still running almost flawlessly on a daily basis, and because there is nothing to gain why replace it. About 75% of the machines out there that cancel your mail with wavy bars, ID Tag it, and take a snapshot of the send to address, are using 8 and 16 bit ISA cards with a mix of newer systems, newest being a DUAL CPU AthlonXP 2200+ CPUs running RedHat 6, and another system running also dual 10+ year old AMD CPU's with NT4, and then another system that is running Windows XP for the operator control interface. And the flat sorter that sorts BUBBLE mailers and magazines is run off of a Pentium III 866Mhz computer with 16bit ISA card used for the OCR and is running QNX OS. * BUT ... Fact of the matter is that most assume that problems and questions discussed here are home users, and standard home computers, unless information provided states otherwise. |
|
| 7245. |
Solve : help with batch script? |
|
Answer» Try LOADING different drivers in Win7 for the USB to serial interface.i tried both sets of drivers available on the companys website, windows doesn't have any generic that workQuote from: coolasice1999 on November 25, 2012, 04:23:31 AM I did take 64bit into consideration, but the NETBOOK i'm using is only 32bit and I have already tried to run it in compatibility mode and no luck there.Compatability mode is not XP Mode! XP Mode is a VM that allows you to run XP as a virtual OS or older application as Virtual Apps inside XP mode but can be launched from Windows 7.Quote from: Squashman on November 25, 2012, 01:15:28 PM Compatability mode is not XP Mode! XP Mode is a VM that allows you to run XP as a virtual OS or older application as Virtual Apps inside XP mode but can be launched from Windows 7. tried in xp mode (did not know about xp mode...i use virtual MACHINES all the time) does the same result, i'm in the process of procuring the original drivers I used on the winxp machine, possibility they are customized somehow which is not working for me here... I would think you would need to install the drivers inside the XP VM for it to work.Quote from: Squashman on November 26, 2012, 04:15:39 PM I would think you would need to install the drivers inside the XP VM for it to work. i did... STILL waiting on the guys at work to get me the original drivers to testQuote from: coolasice1999 on November 25, 2012, 06:29:21 AM I'm still perplexed why this would work perfectly under windows xp and in windows 7 via tera term and hyperterm but not in the batch program? Just a guess.. http://www.sevenforums.com/tutorials/783-elevated-command-prompt.html Quote from: Salmon Trout on November 27, 2012, 03:45:16 PM Just a guess.. nope, tried that already... still waiting on the original drivers... until them i'll just have to stick with terraterm |
|
| 7246. |
Solve : Comparing part of a filename in a windows batch file? |
|
Answer» Hi All, |
|
| 7247. |
Solve : freeDOS? |
|
Answer» If i press f8 i get the following: If i press f8 i get the following: You can keep pressing Y and when the error occurs, reboot and press N at that point. Note which line it is and REM it out. I SUSPECT it is a corrupted TSR and may not be needed. But to install Windows, you need an external USB DVD drive and just boot off the DVD and install Windows. It doesn't need freedos. See the steps here: note the boot menu which selects the DVD drive and then it will be a normal install. Note the option of changing the BIOS setting if needed. http://support.asus.com/Troubleshooting/detail.aspx?SLanguage=en&p=20&m=Eee%20PC%201015E&s=1&hashedid=n/a&os=&no=1718 I would put the install on a usb thumb drive and install from that. I do that all the time on netbooks without optical drives.I think I finally got this to work! In the bios under security I was able to unlock USB and now Windows is loading. Hopefully the install goes well. Thank you for your help. |
|
| 7248. |
Solve : Count Filenames Containing a User-Specified Extension? |
|
Answer» That's the reason - the shortname generation doesn't follow the rules on XP and earlier (and apparantly Win 7 and 8 32 bit). foxidrive, do you sleep during the day?Drat! My Vampire secret is out! (I have insomnia and sleep when I can.) Two replies are in so far - XP 64 bit and Win7 Pro 64 bit - and both show 'standard' 32 bit behaviour. On my Windows 7 x64 as well as Windows 8 x64 systems, Ultimate and Professional respectively (doubt that matters but it might), *.txt matches a .txtx file, and dir /x SHOWS the short FILENAME as having a .txt extension. So my x64 system is the odd one? Another Win7HP 64 bit machine also shows the 'usual' behaviour. It would seem just that the behaviour can't be predicted for short filename generation.Dunno if this sheds any light... D:\test-delete>for /l %A in (1,1,3) do @echo hello world > file%A.lex D:\test-delete>for /l %A in (1,1,3) do @echo hello world > file%A.lexi D:\test-delete>for /l %A in (1,1,3) do @echo hello world > file%A.lexicon D:\test-delete>dir Volume in drive D is SAT-D Volume Serial Number is E8B2-C5D7 Directory of D:\test-delete 20/12/2012 18:12 <DIR> . 20/12/2012 18:12 <DIR> .. 20/12/2012 18:12 14 file1.lex 20/12/2012 18:12 14 file1.lexi 20/12/2012 18:12 14 file1.lexicon 20/12/2012 18:12 14 file2.lex 20/12/2012 18:12 14 file2.lexi 20/12/2012 18:12 14 file2.lexicon 20/12/2012 18:12 14 file3.lex 20/12/2012 18:12 14 file3.lexi 20/12/2012 18:12 14 file3.lexicon 19/12/2012 20:01 43 test.bat 10 File(s) 169 bytes 2 Dir(s) 275,366,141,952 bytes free D:\test-delete>dir /x Volume in drive D is SAT-D Volume Serial Number is E8B2-C5D7 Directory of D:\test-delete 20/12/2012 18:12 <DIR> . 20/12/2012 18:12 <DIR> .. 20/12/2012 18:12 14 file1.lex 20/12/2012 18:12 14 FILE1~1.LE~ file1.lexi 20/12/2012 18:12 14 FILE1~2.LE~ file1.lexicon 20/12/2012 18:12 14 file2.lex 20/12/2012 18:12 14 FILE2~1.LE~ file2.lexi 20/12/2012 18:12 14 FILE2~2.LE~ file2.lexicon 20/12/2012 18:12 14 file3.lex 20/12/2012 18:12 14 FILE3~1.LE~ file3.lexi 20/12/2012 18:12 14 FILE3~2.LE~ file3.lexicon 19/12/2012 20:01 43 test.bat 10 File(s) 169 bytes 2 Dir(s) 275,366,141,952 bytes free D:\test-delete>dir *.lex Volume in drive D is SAT-D Volume Serial Number is E8B2-C5D7 Directory of D:\test-delete 20/12/2012 18:12 14 file1.lex 20/12/2012 18:12 14 file2.lex 20/12/2012 18:12 14 file3.lex 3 File(s) 42 bytes 0 Dir(s) 275,366,141,952 bytes free D:\test-delete>dir *.lexi Volume in drive D is SAT-D Volume Serial Number is E8B2-C5D7 Directory of D:\test-delete 20/12/2012 18:12 14 file1.lexi 20/12/2012 18:12 14 file2.lexi 20/12/2012 18:12 14 file3.lexi 3 File(s) 42 bytes 0 Dir(s) 275,366,141,952 bytes free D:\test-delete>dir *.lex* Volume in drive D is SAT-D Volume Serial Number is E8B2-C5D7 Directory of D:\test-delete 20/12/2012 18:12 14 file1.lex 20/12/2012 18:12 14 file1.lexi 20/12/2012 18:12 14 file1.lexicon 20/12/2012 18:12 14 file2.lex 20/12/2012 18:12 14 file2.lexi 20/12/2012 18:12 14 file2.lexicon 20/12/2012 18:12 14 file3.lex 20/12/2012 18:12 14 file3.lexi 20/12/2012 18:12 14 file3.lexicon 9 File(s) 126 bytes 0 Dir(s) 275,366,141,952 bytes free D:\test-delete>The short name generation is different - but short names can even be random hex numbers in some cases, so it's not an issue. Quote from: foxidrive on December 20, 2012, 02:23:34 PM short names can even be random hex numbers I noticed that when I WENT to 1000 of each extension. |
|
| 7249. |
Solve : How to send an already active program commands through a batch file?? |
|
Answer» I've been working on getting this server running all night, and I could spend the next several hours typing in each command I want it to do ONE at a time and would need to do that again the next time, however I FEEL that there's an easier way. I've spent about an hour looking through commands and other peoples advice, but I haven't seen anything close enough that I could USE. echo <command> It's very simple. I have it saved as a txt at the moment, but changing that to an ext isn't an issue.Sendkeys in a VBS script or AutoIt can both enter text into active program windows.Not sure if you can do that via .BAT... but I use AutoHotkey for that. http://www.autohotkey.com/docs/commands/Send.htm The scripts are really easy to write. I can paste a little sample if you'd like... or you can look in their archives I believe. - kyle_engineer |
|
| 7250. |
Solve : Excel data compilation using Comand Prompt. Possible. If yes, please help...? |
|
Answer» Request for help on being able to compile data from several workbooks. I've seen an example where the files can be compiled by converting them into CSV, but was wondering if it can be done on xls and xlsx version of excel 2007 using command prompt. Thanks Squashman. I would assume it also needs Excel to be installed to do so, as the VB script does.Yes. I believe so. It was a few years ago that I was playing around with it but haven't touched it in close to 3 years now. I got back from vacation that year and either my desire to keep working on it dwindle or my job duties changed. Either way I don't think my co-workers would use it anyways. I was working on a Powershell script that would take an excel file and extract to a flat text file because that is what we work with on the mainframe. I could actually go column by column and figure out what the longest cell was in each column and then extract each row to a fixed text file. I want to get back into it one of these days.Thanks to all - and I've saved the snippet for later use I don't have excel to test it out with. |
|