I wonder why you get different results (something like that always makes me curious).ispy wrote: ↑17 Feb 2021 07:11Anyway - @ Penpen tried your script in XP it very briefly opened the command prompt then disappeared even with a pause command within it as you mentioned. Then as you stated, tried it with %temp%\ as well same result. Tried enclosing in "" quotes same result.
Then I went to 98SE and it worked with the double quotes and the %temp%\ addition with and without quotes. It reported back: Your drive is C: press any key to continue... So I then removed the %temp%\ & quotes it still works in 98SE. If you are wondering about the colon after "C" I added it just as a test within "prompt set drive=$N:$_" line. You could also add the colon after the echo Your Drive is %drive%: line but the variable would read "C" only so its a visual not actual effect.
My result on Win98 SE, when called from within command.com:
Code: Select all
Z:\with space>test
Z:\with space>echo exit | "C:\WINDOWS\COMMAND.COM" /k prompt set drive=$N:$_ | f
ind "set" >"C:\WINDOWS\TEMP\Tempdrv.bat"
Z:\with space>echo.>>"C:\WINDOWS\TEMP\Tempdrv.bat"
Z:\with space>Call "C:\WINDOWS\TEMP\Tempdrv.bat"
Z:\with space>set drive=Z:
Z:\with space>
Z:\with space>
Z:\with space>echo Z:
Z:
Z:\with space>pause
Weiter mit beliebiger Taste . . .
Code: Select all
Z:\WITHSP~1>test
Z:\WITHSP~1>echo exit | "C:\WINDOWS\system32\cmd.exe" /k prompt set drive=$N:$_
| find "set" 1>"C:\WINDOWS\TEMP\Tempdrv.bat"
Z:\WITHSP~1>echo.1>>"C:\WINDOWS\TEMP\Tempdrv.bat"
Z:\WITHSP~1>Call Tempdrv
Z:\WITHSP~1>set drive=Z:
Z:\WITHSP~1>Echo Z:
Z:
Z:\WITHSP~1>pause
Drücken Sie eine beliebige Taste . . .
Code: Select all
Z:\with space>test
Z:\with space>echo exit | "C:\WINDOWS\system32\cmd.exe" /k prompt set drive=$N:$
_ | find "set" 1>"C:\DOKUME~1\TEST\LOKALE~1\Temp\Tempdrv.bat"
Z:\with space>echo.1>>"C:\DOKUME~1\TEST\LOKALE~1\Temp\Tempdrv.bat"
Z:\with space>Call Tempdrv
Z:\with space>set drive=Z:
Z:\with space>Echo Z:
Z:
Z:\with space>pause
Drücken Sie eine beliebige Taste . . .
Then i thought about clicking on the icon and got pretty similar results, except for windows 98SE, where i got:
Code: Select all
Befehl oder Dateiname nicht gefunden.
That error is probably a bug in Win 98 SE and not caused by the script, even the following "test2.bat" gave the same result:
Code: Select all
echo test2
So in Windows 98 you probably use links/shortcuts to batch files and avoid double clicking on batch files which are located in pathes with spaces.
Because you probably have to recreate the link/shortcut, whenever you change the location (for example the volume name, when using a usb-stck), that is not a good option - so you probably should avoid using path names with spaces.
But the odd thing is, that for you, the xp execution doesn't work properly, which works perfectly fine for all my system (native and vbox, without a difference).
That is somehow puzzling to me !
Could you open a "cmd.exe"-window, start that batch file there and copy paste the content of the screen (you might also want to anonymize private data like your username in pathes, if they show up)?
Sidenote: I just noticed, that you could remove the "echo.>>..."-line:
Code: Select all
echo exit | "%ComSpec%" /k prompt set drive=$N:$_ |find "set" >"%temp%\Tempdrv.bat"
Call "%temp%\Tempdrv.bat"
Echo %drive%
pause
penpen