gunsmokingman Posted June 30, 2005 Posted June 30, 2005 (edited) I Have Changed A Couple Of Things So The Cmd Windows Is Smallerand the Background Is White And Green Text, Sorry If the Name Is WrongBut Using ö caused a wierd symbol to appear. I have it so it closes in about4 seconds. The letters are now Capitals.Thanks Nice code @echo off && Mode 55,3 && Color f2 && Title Script By Yzowlfor %%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 ( fsutil fsinfo drivetype %%a:|find "CD-ROM">nul 2>&1&&echo.&&echo Your Cd Is -^> %%a:\)ping -n 4 127.0.0.1>nul&goto :eof Edited June 30, 2005 by gunsmokingman
Yzöwl Posted June 30, 2005 Posted June 30, 2005 Just another slight change gunsmokingman, because if you have more than one cd-drive the first one will disappear before you have time to see it!@echo off&Mode 55,3&Color f2&Title Script By Yzöwlfor %%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 ( fsutil fsinfo drivetype %%a:|find "CD-ROM">nul 2>&1&&echo Your CD-ROM drive^(s^) -^> %%a:\)ping -n 4 127.0.0.1>nul&goto :eof
Synapse Posted July 1, 2005 Posted July 1, 2005 why not just use this?@echo offfor %%i in (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 %%i:\WPI.ico set CDROM=%%i:\echo Found CD-Rom as drive %CDROM%pauseSource: WPI.cmd from the WPI Projectsubstitute the WPI.ico for any file on the CD thats right off the root... such as autorun.inf or whatever. it scans through each drive letter looking for that file and when it finds it sets the variable %CDROM%
DarkShadows Posted July 1, 2005 Author Posted July 1, 2005 This one is for Windows XP It will tell you your CD-Drive letter(s), without the needing any disk in it@echo offfor %%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 ( fsutil fsinfo drivetype %%a:|find "CD-ROM">nul 2>&1&&echo/%%a:)pause&goto :eof<{POST_SNAPBACK}>Yzöwl I like that script. Very nice. (It's the first time I've even heard of fsutil.) Can you tell us if fsutil will be available when we are installing Windows XP from an Unattended Installation CD?I have 2 CD ROM drives and an Iomega Rev drive (which appears to the OS as a CD-ROM drive) So I end up seeing three drive letters when the script executes on my PC. If I where installing Windows unattended, this code would show me all the drive letters. So wouldn't I still have to make a human decision as to which one to use?However, it seems that this would be an excellent addition to my batch script which enables me to build my XPCDs (like to prompt the user which drive should be used).why not just use this?@echo offfor %%i in (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 %%i:\WPI.ico set CDROM=%%i:\echo Found CD-Rom as drive %CDROM%pauseSource: WPI.cmd from the WPI Projectsubstitute the WPI.ico for any file on the CD thats right off the root... such as autorun.inf or whatever. it scans through each drive letter looking for that file and when it finds it sets the variable %CDROM%<{POST_SNAPBACK}>One reason I do not like using file checks is that I try to write modular code so when I move to my next project, I copy and past code modules from my previous scripts. When you check for a specific file or a folder, then you must make damned sure that it is actually on the CD, and you must also make damned sure it is not on any other drive that you may have. What happens when you rebuild your PC, but you leave your other HDD partitions intact? The code you posted searches all drives looking for its check file--it does not stop when it has found the first instance. So if you had the same check file in more than one drive, you may not get the correct drive letter assigned to your %CDROM% variable. And sure, you could easily be careful enough to ensure that no two drives have the same check file. However, there is still more to deal with.Even more critical is something that could happen if you have more than one CD-ROM drive (which I do). Because the code you posted searches all drives, it will also search my second CD drive that I do not have CD in. At which time Windows will generate a dialog with a message stating that media is not ready in the drive (or something like that). I personally find this problematic.That's what makes the technique I started this topic with so powerful. It doesn't require a check file or folder, and it simply doesn't care how many drives you have--it's not looking for any of them. When any script withSet CDROM=%~d0 in it runs (again running from the CD ROM itself), that script will automatically and programmatically know which drive letter the script is running from; and since it runs from the CD-ROM, we automatically and programmatically know the CD-ROM drive letter that we are executing from. It's just sooo much simpler to type, takes less time to execute, and is much less problematic. All the upside in the world, and no downside.If you prefer to execute your scripts from %SystemDrive%, then you need only execute one short script from the CD-ROM to set the %CDROM% variable and then launch your %SystemDrive% scripts.Keep in mind, I posted my technique to be used from your XPCD when installing Windows and executing your Cmdlines.txt-launched (or other method-launched) batch scripts, not to create the XPCD itself.
Yzöwl Posted July 1, 2005 Posted July 1, 2005 (edited) @ DarkShadowsHere's a couple you may find more useful then:This one will only give the drive letter if there's a CD loaded@echo off&Mode 55,3&Color f2&Title Script By YzOwlfor %%a in (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 ( fsutil fsinfo volumeinfo %%a:|find "CDFS">nul 2>&1&&echo Your CD-ROM drive^(s^) -^> %%a:\)ping -n 4 127.0.0.1>nul&goto :eofThis one will only give the drive letter of a volume with a label of 'UWXPCD'@echo off&Mode 55,3&Color f2&Title Script By YzOwlfor %%a in (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 ( fsutil fsinfo volumeinfo %%a:|find "UWXPCD">nul 2>&1&&echo Your specified drive is -^> %%a:\)ping -n 4 127.0.0.1>nul&goto :eof<Edit>Changed description of second example to avoid confusion.</Edit> Edited July 1, 2005 by Yzöwl
Martin Zugec Posted July 1, 2005 Posted July 1, 2005 I am using this:@echo offFor /f "usebackq tokens=1,2 delims==" %%i IN (`WMIC CDROM Where "VolumeName='UACDROM'" list full`) DO If %%i EQU Drive Set strCdrom=%%jIt will search for cd label UACDROM and assign it to variable strCdrom
vcBlackBox Posted July 1, 2005 Posted July 1, 2005 Thanks Yzöwl. Appreciate it.Here's some additional info - fsutil is only available on XP/2003. 2000 does not recognize this command.@ DarkShadowsGood explanation. set CDROM=%~d0 is very simplistic and can be quite useful like you said.But a warning if you use Quick Batch File Compiler to compile your scripts -- set CDROM=%~d0 will not give you the correct drive. However, Yzöwl method will. Thanks y'all.
Yzöwl Posted July 1, 2005 Posted July 1, 2005 (edited) Here is a basic template utilising my CD Label method (XP /2003)@echo off&setlocal enableextensions:: enter your CD label below e.g. set lab=UWXPCD (case insensitive)set lab=call :findrive:: put your commands below here (%CDROM% variable is set):: do not add or replace anything below hereendlocal&goto :eof:findriveset drv=c d e f g h i j k l m n o p q r s t u v w x y zfor %%a in (%drv%) do ( fsutil fsinfo volumeinfo %%a:|find /i "%lab%">nul 2>&1&&set CDROM=%%a:)goto :eofHope this simplifies it for everyone! Edited July 1, 2005 by Yzöwl
DarkShadows Posted July 2, 2005 Author Posted July 2, 2005 But a warning if you use Quick Batch File Compiler to compile your scripts -- set CDROM=%~d0 will not give you the correct drive. However, Yzöwl method will. <{POST_SNAPBACK}>@vcBlackBox: I never compile my batch scripts, so this isn't an issue for me. However, this is really good information for people to know. Thanks for bringing it forward!fsutil fsinfo volumeinfo %%a:|find /i "%lab%">nul 2>&1&&set CDROM=%%a:<{POST_SNAPBACK}>@Yzöwl: I like this script to automatically find my unslipstreamed Windows XP CD when I'm running my slipstream.cmd. (This is an example scenario when using Set CDROM=%~d0 will simply not work.)@Yzöwl and/or Martin Zugec:Now I have a question. In the line above, I understand nearly every technique you two have applied in your code there except one segment. The "">nul 2>&1&&set" Portion. The ">nul" just redirects output to the Nul device correct? So how does the remaining portion of the code get executed?The "&" is usually used to concatenate another command to the command line. But why do you have two of them before your Set command?It's a little off topic, but could you break down this a little?
Yzöwl Posted July 2, 2005 Posted July 2, 2005 @ DarkShadowsIt redirects standard output, STDOUT, (1>nul), and standard error, STDERR, (2>nul), to nul.STDOUT, channel 1, is the default therefore doesn't require the channel number stipulating, (>nul).You can use>nul 2>nulwhich will redirect each channel to its own nulOr you can use>nul 2>&1which redirects STDERR to the same nul as the STDOUT channel.As for the (&), (&&)& separates multiple commands on one command line.&& causes the command following this symbol to run if the command preceding the symbol is successful.
Martin Zugec Posted July 2, 2005 Posted July 2, 2005 2vbBlackBox: fsutil AND wmic is only for XP and higher...If you want to use this method on w2k box, you must create vbscript, I can make it for you if you want
gunsmokingman Posted July 2, 2005 Posted July 2, 2005 Here is a 1 line Vbs script that deletes a file called test.vbs if the test.vbs is not there then it will say missing file it a long line of codeGreen is the file you can change it to txt, cmd or what everTested This Script From My Desktop And It was checking System drive That Is why the File Name Looks Like this "\Test.vbs" This lines runs from 0 - 192 in Notepad If CreateObject("Scripting.FileSystemObject").FileExists("\Test.vbs") Then CreateObject("Scripting.FileSystemObject").DeleteFile("\Test.vbs") Else MsgBox "Missing", 0 + 32,"Missing" End IfThis Is the same code In 2 LinesThe Longest Line runs from 0 - 113 in NotepadSet Fso = CreateObject("Scripting.FileSystemObject")If Fso.FileExists("\Test.vbs") Then Fso.DeleteFile("\Test.vbs") Else MsgBox "Missing", 0 + 32,"Missing" End IfThis Is The Biggest at 7 lines it reports the file been deleted or if it missingThe Longest Line runs from 0 - 98 in Notepad Set Fso = CreateObject("Scripting.FileSystemObject") Mlist = "\Test.vbs" Function DelMlist Fso.DeleteFile(Mlist) MsgBox "The File Been Deleted", 0 + 32,"Gsm Test" End FunctionIf Fso.FileExists(Mlist) Then DelMlist() Else Gsm = MsgBox ("Missing", 0 + 32,"Missing") End If
maxXPsoft Posted July 3, 2005 Posted July 3, 2005 Had to add this cause I needed it and had forgotten so I searched far and wideIf you want to answer a prompt AUTOmatically as I need occasionally.echo y| cacls <filename> /g <username>:<permission> NOTE: There is no space between the y and the | (pipe). Works with some things and not with others so TEST it.
Gee Posted July 3, 2005 Posted July 3, 2005 (edited) Here is a .vbs script that I wrote to allow users to change their User Name, Company, and Computer Name. Usefull if you want to change it without going into the Registry or something that you can run at the end of your XP installation during Cleanup.cmdOption ExplicitSet ws = WScript.CreateObject("WScript.Shell")Dim ws, t, p1, p2, n, g, cn, cg, o, cop1 = "HKLM\Software\Microsoft\Windows NT\CurrentVersion\"p2 = "HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName\"n = ws.RegRead(p1 & "RegisteredOwner")g = ws.RegRead(p1 & "RegisteredOrganization")o = ws.RegRead(p2 & "ComputerName")t = "Change Personal Info & Computer Name"cn = InputBox("Enter Your Full Name", t, n)If cn <> "" Then ws.RegWrite p1 & "RegisteredOwner", cnEnd Ifcg = InputBox("Enter Your Company Name", t, g)If cg <> "" Then ws.RegWrite p1 & "RegisteredOrganization", cgEnd Ifco = InputBox("Enter Computer Name", t, o)If co <> "" Then ws.RegWrite p2 & "ComputerName", coEnd If Edited July 5, 2005 by Gee
gunsmokingman Posted July 3, 2005 Posted July 3, 2005 (edited) That A Nice Script I Used It In This Hta That I Made, Of ItChangeUserInfo.exe Edited July 3, 2005 by gunsmokingman
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now