Jump to content

using variables in file.cmd


Recommended Posts


I would do something like this

FOR /F "tokens=1,2,3 skip=4" %%I IN ('REG.EXE QUERY "HKLM\Software\Microsoft\Windows\CurrentVersion\Setup" /v SourcePath') DO SET CDROM=%%K


XCOPY %CDROM%directory\file.exe %systemdrive%\patch\

Hope this will help you

Link to comment
Share on other sites

Sure there is many ways to get %CDROM% and I think this one is the best for 1 reason... it doesn't require CD.TXT or something not include on XP CD

and I don't understand why this line is not on "http://unattended.msfn.org/xp/runonceex_cd.htm" instead of

IF EXIST D:\CD.txt set CDROM=D:

IF EXIST E:\CD.txt set CDROM=E:

...

..

.

%CDROM%

FOR /F "tokens=3" %%I IN ('REG QUERY HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup /v SourcePath ^| FIND "SourcePath"') DO SET CDROM=%%~dI

Link to comment
Share on other sites

what's the difference betwen

FOR /F "tokens=3" %%I IN ('REG QUERY HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup /v SourcePath ^| FIND "SourcePath"') DO SET CDROM=%%~dI

and

FOR /F "tokens=1,2,3 skip=4" %%I IN ('REG.EXE QUERY "HKLM\Software\Microsoft\Windows\CurrentVersion\Setup" /v SourcePath') DO SET CDROM=%%K


XCOPY %CDROM%directory\file.exe %systemdrive%\patch\

???

Link to comment
Share on other sites

@beppemito

I've wrote this one from memory just to give you something to work with

%CDROM% = D:\

FOR /F "tokens=1,2,3 skip=4" %%I IN ('REG.EXE QUERY "HKLM\Software\Microsoft\Windows\CurrentVersion\Setup" /v SourcePath') DO SET CDROM=%%K

This is the good one (drive used for Windows installation)

%CDROM% = D:

FOR /F "tokens=3" %%I IN ('REG QUERY HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup /v SourcePath ^| FIND "SourcePath"') DO SET CDROM=%%~dI

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...