Jump to content

Hints needed for %DVD% variable


Thiersee

Recommended Posts

Hi,

 

I need to build in my Win7-ISO (WinToolkit) a function setting a link on the desktop to start a program (WPI.exe).

The WPI-Folder is in the ISO and I want that the final user has to start only this link.

 

After the Win installation the ISO is still mounted (VM) or the DVD ist still in the drive.

 

My problems are: I don't know, how can I make the variable %DVD% available to Windows during the installation and which command in a .BAT or .CMD file I need.

 

Can somebody give me some hints?

 

TNX, Thiersee

Link to comment
Share on other sites

Hi,

I need to build in my Win7-ISO (WinToolkit) a function setting a link on the desktop to start a program (WPI.exe).

The WPI-Folder is in the ISO and I want that the final user has to start only this link.

After the Win installation the ISO is still mounted (VM) or the DVD ist still in the drive.

My problems are: I don't know, how can I make the variable %DVD% available to Windows during the installation and which command in a .BAT or .CMD file I need.

Can somebody give me some hints?

TNX, Thiersee

I use this from a long time ago to start WPI from %windir%\temp folder : (not fail with empty devices as card readers)

@ECHO OFFSETLOCAL(SET USB=)FOR /F "USEBACKQ TOKENS=2 DELIMS==" %%# IN (`WMIC DATAFILE WHERE^ "PATH='\\WPI\\' AND FILENAME='WPI' AND EXTENSION='exe'"^ GET Name /VALUE^|FIND "="`) DO SET "USB=%%~d#"&SET "FPATH=%%#"START "" "%FPATH%" & exit

I run this cmd from Autounattend.xml

 

<FirstLogonCommands>

             <SynchronousCommand wcm:action="add">

                 <CommandLine>cmd /q /c start %windir%\Temp\WPI.cmd</CommandLine>

                 <Description>Run WPI</Description>

                 <Order>1</Order>

                 <RequiresUserInput>false</RequiresUserInput>

             </SynchronousCommand>

 </FirstLogonCommands>

 

Regards... ;-)

 

To only create shortcut in Desktop use this: (I found script here http://superuser.com/questions/392061/how-to-make-a-shortcut-from-cmd)

@ECHO OFFSETLOCAL(SET USB=)FOR /F "USEBACKQ TOKENS=2 DELIMS==" %%# IN (`WMIC DATAFILE WHERE^ "PATH='\\WPI\\' AND FILENAME='WPI' AND EXTENSION='exe'"^ GET Name /VALUE^|FIND "="`) DO SET "USB=%%~d#"&SET "FPATH=%%#"::START "" "%FPATH%" & exitecho Set oWS = WScript.CreateObject("WScript.Shell") > CreateShortcut.vbsecho sLinkFile = "%HOMEDRIVE%%HOMEPATH%\Desktop\WPI.lnk" >> CreateShortcut.vbsecho Set oLink = oWS.CreateShortcut(sLinkFile) >> CreateShortcut.vbsecho oLink.TargetPath = "%FPATH%" >> CreateShortcut.vbsecho oLink.Save >> CreateShortcut.vbscscript CreateShortcut.vbsdel CreateShortcut.vbsexit

Tested:

XojJrJ2.png

WPI.rar

Edited by alfreire
Link to comment
Share on other sites

Thanks a lot alfreire!

 

I don't want to start it from the autoexec,xml, so I would need only the last part, but

 

 

@ECHO OFF

SETLOCAL

(SET USB=)
FOR /F "USEBACKQ TOKENS=2 DELIMS==" %%# IN (`WMIC DATAFILE WHERE^
"PATH='\\WPI\\' AND FILENAME='WPI' AND EXTENSION='exe'"^
GET Name /VALUE^|FIND "="`
) DO SET "USB=%%~d#"&SET "FPATH=%%#"

::START "" "%FPATH%" & exit

you set here USB, I need DVD, how can I modify it?

Link to comment
Share on other sites

Thanks a lot alfreire!

 

I don't want to start it from the autoexec,xml, so I would need only the last part, but

 

 

@ECHO OFF

SETLOCAL

(SET USB=)

FOR /F "USEBACKQ TOKENS=2 DELIMS==" %%# IN (`WMIC DATAFILE WHERE^

"PATH='\\WPI\\' AND FILENAME='WPI' AND EXTENSION='exe'"^

GET Name /VALUE^|FIND "="`) DO SET "USB=%%~d#"&SET "FPATH=%%#"

::START "" "%FPATH%" & exit

you set here USB, I need DVD, how can I modify it?

Anyway, works for USB & DVD indistinctly... you can change USB to DVD if you want...

@ECHO OFFSETLOCAL(SET DVD=)FOR /F "USEBACKQ TOKENS=2 DELIMS==" %%# IN (`WMIC DATAFILE WHERE^ "PATH='\\WPI\\' AND FILENAME='WPI' AND EXTENSION='exe'"^ GET Name /VALUE^|FIND "="`) DO SET "DVD=%%~d#"&SET "FPATH=%%#"::START "" "%FPATH%" & exit

%DVD% is drive letter

%FPATH% is full path to WPI.exe (%DVD%\WPI\WPI.exe)

 

You can delete ::START "" "%FPATH%" & exit if not want start WPI from cmd...

 

Regards... ;-)

 

I think you need only this:

@ECHO OFFSETLOCAL(SET DVD=)FOR /F "USEBACKQ TOKENS=2 DELIMS==" %%# IN (`WMIC DATAFILE WHERE^ "PATH='\\WPI\\' AND FILENAME='WPI' AND EXTENSION='exe'"^ GET Name /VALUE^|FIND "="`) DO SET "DVD=%%~d#"&SET "FPATH=%%#"echo Set oWS = WScript.CreateObject("WScript.Shell") > CreateShortcut.vbsecho sLinkFile = "%HOMEDRIVE%%HOMEPATH%\Desktop\WPI.lnk" >> CreateShortcut.vbsecho Set oLink = oWS.CreateShortcut(sLinkFile) >> CreateShortcut.vbsecho oLink.TargetPath = "%FPATH%" >> CreateShortcut.vbsecho oLink.Save >> CreateShortcut.vbscscript CreateShortcut.vbsdel CreateShortcut.vbsexit

WPI.rar

Edited by alfreire
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...