Thiersee Posted September 18, 2015 Posted September 18, 2015 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 Quote
ianymaty Posted September 19, 2015 Posted September 19, 2015 Hi Thiersee,I didn't test this method but I find people using this.Set a distinguishable file in the ISO (ex: myfile.txt) than ad this to the code @echo offfor %%a in (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:\myfile.txt" set "drv=%%a:" alfreire 1 Quote
Thiersee Posted September 19, 2015 Author Posted September 19, 2015 Thanks ianymaty, this sets only the variable, if the file is present, but I do need on the desktop a link to this program too! Quote
alfreire Posted September 19, 2015 Posted September 19, 2015 (edited) 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, ThierseeI 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%" & exitI 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.vbsexitTested:WPI.rar Edited September 19, 2015 by alfreire Quote
Thiersee Posted September 19, 2015 Author Posted September 19, 2015 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 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%" & exityou set here USB, I need DVD, how can I modify it? alfreire 1 Quote
alfreire Posted September 19, 2015 Posted September 19, 2015 (edited) 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 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%" & exityou 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.vbsexitWPI.rar Edited September 19, 2015 by alfreire Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.