MSFN Forum: A mega easy to get the CDROM variable set - MSFN Forum

Jump to content



  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

A mega easy to get the CDROM variable set Rate Topic: -----

#1 User is offline   tim 

  • Junior
  • Pip
  • Group: Members
  • Posts: 95
  • Joined: 28-August 01

Posted 16 July 2004 - 10:47 AM

Here is how:

SET CDROM=%CD:~0,2%


That's it.
Do this at the top of any .CMD file(s) that run from the install CD.

:)

To find out how this works, start a CMD.EXE session and type SET /?


#2 User is offline   Alanoll 

  • CODE tags people, CODE tags!
  • Group: Patrons
  • Posts: 5,496
  • Joined: 25-September 03

Posted 16 July 2004 - 02:23 PM

this will only work from CMDLINES.TXT if the CMD file is on CD. Won't work from SVCPACK or GUIRUNONCE.

So you know.

#3 User is offline   tim 

  • Junior
  • Pip
  • Group: Members
  • Posts: 95
  • Joined: 28-August 01

Posted 16 July 2004 - 03:09 PM

Quote

this will only work from CMDLINES.TXT if the CMD file is on CD


From reading the many post here, that is what most people want it for.
e.g. setting RunOnce keys and the like.

#4 User is offline   Alanoll 

  • CODE tags people, CODE tags!
  • Group: Patrons
  • Posts: 5,496
  • Joined: 25-September 03

Posted 16 July 2004 - 03:25 PM

some people also use a normal batch file with ECHO commands to tell them what's going on (the "basic" method, where as RunOnceEX is the "advanced" method) and so they use GUIRunOnce. Thought i should post that it won't there as expected so they don't complain later on. :)

Though this does simplify all those IF EXIST lines for people using CMDLINES.TXT to install something from ONE cd. :rolleyes: It won't work with two CDs if they are in different drives however. (I'm just listing possibilities that people may try to use this with)

#5 User is offline   tim 

  • Junior
  • Pip
  • Group: Members
  • Posts: 95
  • Joined: 28-August 01

Posted 16 July 2004 - 04:27 PM

Ok, just trying to help.

For what I need it does me fine.
and it's neat , I like that :)

#6 User is offline   zippy 

  • Newbie
  • Group: Banned
  • Posts: 49
  • Joined: 18-May 04

Posted 16 July 2004 - 04:44 PM

1 thread/per month about sharing %CDROM%...
%CD%, %0, SourcePath...etc... depends on how/where you use it...

#7 User is offline   my2001 

  • Member
  • PipPip
  • Group: Members
  • Posts: 260
  • Joined: 31-May 04

Posted 17 July 2004 - 03:42 AM

tim, on Jul 16 2004, 10:47 AM, said:

SET CDROM=%CD:~0,2%

How's that working? I just mean: it's really neat :) , but what kind of command is that? I've never seen it before.

#8 User is offline   DarkPhoenix 

  • Codename: Kirby
  • PipPip
  • Group: Members
  • Posts: 201
  • Joined: 30-May 04

Posted 17 July 2004 - 03:49 AM

%CD% is your Current Directory, and since the RunOnceEx file will be run off the CD (Compact Disk this time :rolleyes:) the drive letter of the %CD% will be the CD. So.. what that command does, is to pull out the two first letters from the %CD% variable, so that if %CD% for instance is

"F:\$OEM$", then %CD:~0,2% will return "F:" only. (0,2 means begin at position 0 and read the next two letters. 2,6 would return "\$OEM$", if you understand? :))

#9 User is offline   my2001 

  • Member
  • PipPip
  • Group: Members
  • Posts: 260
  • Joined: 31-May 04

  Posted 17 July 2004 - 06:37 AM

DarkPhoenix, on Jul 17 2004, 03:49 AM, said:

0,2 means begin at position 0 and read the next two letters. 2,6 would return "\$OEM$", if you understand? :))

Cool, thx! :rolleyes:

Sure I understand ... but what I didn't know just seconds ago is that syntax. Haven't seen it before and didn't know it exists. Thx again! :D

#10 User is offline   tim 

  • Junior
  • Pip
  • Group: Members
  • Posts: 95
  • Joined: 28-August 01

Posted 17 July 2004 - 11:46 AM

Quote

Sure I understand ... but what I didn't know just seconds ago is that syntax. Haven't seen it before and didn't know it exists. Thx again!
Oh good, at least my post was some use to somebody :)

Quote

To find out how this works, start a CMD.EXE session and type SET /?


#11 User is offline   prathapml 

  • Follow the rules please :-)
  • Group: Patrons
  • Posts: 6,791
  • Joined: 14-November 03
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 17 July 2004 - 12:43 PM

@tim

that's simply fantastic.
You da' wizard, dude!


Quote

Oh good, at least my post was some use to somebody
Somebody? Well, make that lots of buddies :)

#12 User is offline   neophyte 

  • *Purrrr*
  • PipPipPip
  • Group: Members
  • Posts: 395
  • Joined: 20-August 03

Posted 17 July 2004 - 10:20 PM

You could actually use that to set a permanent variable of %CDROM%

#13 User is offline   enuffsaid 

  • Friend of MSFN
  • PipPipPipPipPip
  • Group: Members
  • Posts: 862
  • Joined: 26-December 03

Posted 18 July 2004 - 05:36 AM

That's a good find, Tim. And thanks for sharing it, too! Sorry about the people giving you a hassle for posting something interesting. They're just jealous of you, as they probably never have something to contribute themselfves. :)

Plenty people are grateful!

Thanks!
eNuffSaid

EDIT: Typos

#14 User is offline   enuffsaid 

  • Friend of MSFN
  • PipPipPipPipPip
  • Group: Members
  • Posts: 862
  • Joined: 26-December 03

Posted 18 July 2004 - 05:44 AM

zippy, on Jul 16 2004, 04:44 PM, said:

1 thread/per month about sharing %CDROM%...

Thanks for this vital information, zippy :)

#15 User is offline   killerbee 

  • Senior Member
  • PipPipPipPip
  • Group: Members
  • Posts: 500
  • Joined: 22-April 03

Posted 18 July 2004 - 06:24 AM

hi,

nice one, thank you

cya

Killer Bee

#16 User is offline   evilvoice 

  • Ditchy McAbandonpants
  • PipPipPipPipPip
  • Group: Members
  • Posts: 946
  • Joined: 27-January 04

Posted 18 July 2004 - 10:31 AM

here is a batch, it is not mine, but I did change a little thing...first, this is only for 2k/xp instead of the whole batch consisting of 98/nt/2k/xp. I also have it set instead of all cdroms, to the first one it finds...this means that if youre not using the master cdrom drive to install or whatever, then you need to change this...

it came from http://www.robvander.../amb_cdrom.html

@ECHO OFF
:: For Windows 2000
:W2K
SETLOCAL
SET CDROMS=
SET Temp1=%Temp%.\%~n0%Random%1.reg
SET Temp2=%Temp%.\%~n0%Random%2.reg
START /WAIT REGEDIT /E %Temp1% "HKEY_LOCAL_MACHINE\SYSTEM\MountedDevices"
TYPE %Temp1% > %Temp2%
TYPE %Temp2% | FIND "\\DosDevices\\" | FIND /V "\\DosDevices\\A:" | FIND "=hex:5c," > %Temp1%
FOR /F "tokens=3 delims=\:" %%A IN (%Temp1%) DO CALL :ParseW2K %%A
SET CDROMS
DEL %Temp1%
DEL %Temp2%
ENDLOCAL & SET CDROMS=%CDROMS:~0,2%
GOTO:EOF

:ParseW2K
IF DEFINED CDROMS (SET CDROMS=%CDROMS%,%1:) ELSE (SET CDROMS=%1:)
GOTO:EOF


see where I use

Quote

%CDROMS:~0,2%
, if youre not using the first cdrom, change it accordingly.

#17 User is offline   zippy 

  • Newbie
  • Group: Banned
  • Posts: 49
  • Joined: 18-May 04

Posted 19 July 2004 - 03:51 AM

I'm glad that so many people find this useful. I use it a lot after cyberdiamond told how/why a month ago.
When some noob like me posting a newbie question on this board, what we got is only a reply "Do a search". Why dont you?

Another method leanred from sleepnmojo "%~d0" and "%~dp0" refers to current drive/directory where your cmd file is when it been called from cd. It's also useful on cmd files on cd when called from RunOnceEx/GuiRunOnce.

\$OEM$\RunOnceEx.cmd:
...
REG ADD %KEY%\050 /V 1 /D "%CD%\install\MSN.cmd" /f
...


\$OEM$\install\MSN.cmd:
@ECHO OFF
cmdow @ /HID
CD /D "%~dp0"
START /WAIT msiexec /I MsnMsgs.msi /QB
START /WAIT regedit /s .\MSN.reg
EXIT


We sometimes put application install cmd file on cd. Some additional command needs current working directory to be on the same drive/directory for some .ini/.cfg.
CD /D "%~dp0"
will chage drive/directory to there.
That's what my last post said. %CD%, %0, SourcePath...etc... depends on how/where you use it...
Dont put "jealous" or something on me. I'm noob & nobody.

DarkPhoenix's post on this thread, that's sharing, told us how/why he do this.

#18 User is offline   tim 

  • Junior
  • Pip
  • Group: Members
  • Posts: 95
  • Joined: 28-August 01

Posted 19 July 2004 - 12:34 PM

Quote



I actually worked this out for myself, I didn't rip it off from anywhere.

I spent ages playing with VBScript and BAT/CMD files before I came across this solution to my problem.

BTW thanks for the nice comments everyone.

#19 User is offline   sleepnmojo 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 472
  • Joined: 02-March 04

Posted 19 July 2004 - 03:59 PM

evilvoice, on Jul 18 2004, 10:31 AM, said:


I've never seen anything done like that. Thats is just plain awesome. Over the top, but awesome.

#20 User is offline   CoffeeFiend 

  • Coffee Aficionado
  • Group: Super Moderator
  • Posts: 5,260
  • Joined: 14-July 04
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 19 July 2004 - 04:06 PM

There has been a couple methods listed already but neither work for me.

I use GUIRunOnce for a main installer script that launches more scripts. Using GUIRunOnce, the first method won't work, and somehow, the other method in this thread doesn't return the right drive for me... So even if it might work sometimes, I don't trust it, and to be honest, I never thought of doing it that way.

There is a much simpler way. Have a unique file on your CD, and look for it:

@echo off
for %%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 if exist %%a:\path\to\yourfile.xyz set CDROM=%%a

(where \path\to\yourfile.xyz is the path to your uniquely named file called yourfile.xyz or whatever it might be, with no drive letter of course)

I GUIRunOnce to start command.cmd, after that, command.cmd uses that code to find the CD Rom drive letter, and starts %CDROM\whatever.cmd that does the installs directly from the CD (Actually, a DVD-R but that's besides the point). Simple to do and works reliably at every stage.

Might not be news to most people, some people might like other methods better, it might have been posted 150x before... But anyways. I hope it helps someone... Just "contributing" hoping to make someone else's life easier. :)

Share this topic:


  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy