Hi, Since i have no knowledge of programming, i would like to ask your help! what im trying to do is , when i click a bat file, it creates a desktop shortcut to a exe in the same directory , but with a commandline added to the shortcut filepath. so the end result will look like this The script im using is one i picked from the web and ive added a line but its not adding the command line. (the \Iso\ssx3.iso part) Code: @echo off set MYPATH=%CD% set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs" echo Set oWS = WScript.CreateObject("WScript.Shell") >> %SCRIPT% echo sLinkFile = "%USERPROFILE%\Desktop\SSX3.lnk" >> %SCRIPT% echo Set oLink = oWS.CreateShortcut(sLinkFile) >> %SCRIPT% echo oLink.TargetPath = "%mypath%/pcsx2.exe" >> %SCRIPT% echo oLink.TargetPath = oLink.TargetPath & "\Iso\ssx3.iso" >> %SCRIPT% echo oLink.Save >> %SCRIPT% cscript /nologo %SCRIPT% del %SCRIPT% Does anyone have a idea whats wrong ? or maybe have another solution ? thanks!
Try insert space between exe and its commang line arguments (and why in two lines?) : Code: echo oLink.TargetPath = "%mypath%/pcsx2.exe \Iso\ssx3.iso" >> %SCRIPT% Double quotes around exe path and around command line arguments needed only when there are spaces in them. And also you should aware of "/" at the end of all paths stored in variables (%mypath%) because wrong path (with double "//" for example) can prevent from creating shortcut. Edit: If you will not succeed in creating shortcut, I will try tomorrow...
Thanks for the reply and your line of code. I just tried it. It added the path straight after the exe, so before the " it shows like this "D:\Install\Emulators\Games\SSX3\pcsx2.exe \Iso\ssx3.iso" while i want it to be D:\Install\Emulators\Games\SSX3\pcsx2.exe "Iso\ssx3.iso" I guess this way it wont be seen as a commandline ? so its pretty close, but not working. Do you maybe have another suggestion ?
You need to embed double quote character into string (I will search for VBS syntax and write here how). But those two command lines are identical from OS point of view, because \Iso\ssx3.iso has no spaces. Another side note: \Iso\ssx3.iso is so called relative root path as it has no drive letter - are you sure pcsx2.exe will find iso file from such command line parameter? (And Iso\ssx3.iso is just relative path...) Edit: Ok, I found WshShortcut object reference. Here we go: Code: @echo off set MYPATH=%CD% set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs" echo Set oWS = WScript.CreateObject("WScript.Shell") >> %SCRIPT% echo sLinkFile = "%USERPROFILE%\Desktop\SSX3.lnk" >> %SCRIPT% echo Set oLink = oWS.CreateShortcut(sLinkFile) >> %SCRIPT% echo oLink.TargetPath = "%mypath%/pcsx2.exe" >> %SCRIPT% [U]echo oLink.Arguments = """\Iso\ssx3.iso""" >> %SCRIPT%[/U] echo oLink.Save >> %SCRIPT% cscript /nologo %SCRIPT% del %SCRIPT% If you must include a quotation mark as one of the characters in the string, you use two contiguous quotation marks (""). http://msdn.microsoft.com/en-us/library/594k4c67(v=vs.84).aspx http://msdn.microsoft.com/en-us/library/yf7kaky2(v=vs.84).aspx
Hi thanks for the reply, didnt notice it before sorry about that. I tried the script , and ive just tried it, the shortcut isnt working properly yet. didnt know windows could be so anal. Ive found out it doest work before this gets filled in (its blanc) but thanks to your link i solved it with adding echo oLink.WorkingDirectory = "%mypath%" >> %SCRIPT% now for the strange things, somehow it doesnt work with the quotes anymore in arguments (did format windows, maybe that had something to do with it ??) , but all i had to do is remove the double "" from the argument folder. so the script is now Code: @echo off set MYPATH=%CD% set SCRIPT="%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%.vbs" echo Set oWS = WScript.CreateObject("WScript.Shell") >> %SCRIPT% echo sLinkFile = "%USERPROFILE%\Desktop\SSX3.lnk" >> %SCRIPT% echo Set oLink = oWS.CreateShortcut(sLinkFile) >> %SCRIPT% echo oLink.TargetPath = "%mypath%/pcsx2.exe" >> %SCRIPT% echo oLink.Arguments = "Iso\ssx3.iso" >> %SCRIPT% echo oLink.WorkingDirectory = "%mypath%" >> %SCRIPT% echo oLink.Save >> %SCRIPT% cscript /nologo %SCRIPT% del %SCRIPT% If i click that the shortcut on the desktop will be created So if i click that pcsx2 is launched and the SSX3 iso is automaticly mounted and booted. Thanks al lot for your help! its Solved :banana:
I was ready for writing the PowerShell script which would create shortcut... :nerd: Both bat and vbs are respectable, but PowerShell is much more flexible and much more programmers'.