hans_schwaebli Posted September 21, 2006 Share Posted September 21, 2006 I want to run a shortcut instead of the cmd file itself. I tried it with Run('C:/aProgram.lnk') But it says Error. How can I run shortcuts, .lnk files? Link to comment Share on other sites More sharing options...
CWorks Posted September 21, 2006 Share Posted September 21, 2006 (edited) I've done it a very long time ago so i might be wrong I think it requires the use of rundll32.exe and shell32.dll here you go Run(@ComSpec & " /c " & "C:\aProgram.lnk") Edited September 21, 2006 by CWorks Link to comment Share on other sites More sharing options...
hans_schwaebli Posted September 21, 2006 Author Share Posted September 21, 2006 I've done it a very long time ago so i might be wrongI think it requires the use of rundll32.exe and shell32.dllhere you goRun(@ComSpec & " /c " & "C:\aProgram.lnk")Thank you.But it does not work like I expected it.I tried to start a .cmd file. In the .lnk file I configured color and size of the dos box which appears when I double click the link. But when I start the link with your line, it uses the default colors and sizes.Any idea why that is or a solution? Link to comment Share on other sites More sharing options...
PsaltyDS Posted September 21, 2006 Share Posted September 21, 2006 I've done it a very long time ago so i might be wrong I think it requires the use of rundll32.exe and shell32.dll here you go Run(@ComSpec & " /c " & "C:\aProgram.lnk") I thing CWorks has it right on the Run() command. Since a .lnk file is not an executable itself, it needs a command interpreter to handle it, which you get by running it with @ComSpec. The console window need not be visible: Run(@ComSpec & " /c " & "C:\aProgram.lnk", @TempDir, @SW_HIDE) Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
jinxter Posted September 21, 2006 Share Posted September 21, 2006 Thank you. But it does not work like I expected it. I tried to start a .cmd file. In the .lnk file I configured color and size of the dos box which appears when I double click the link. But when I start the link with your line, it uses the default colors and sizes. Any idea why that is or a solution? Try using CMD with switches... and COLOR with switches... the size is another matter, so is the font... have to dig deeper for that one. -----------------------------8<--------------------------------- CMD [/A | /U] [/Q] [/D] [/E:ON | /E:OFF] [/F:ON | /F:OFF] [/V:ON | /V:OFF] [ [/C | /K] string] /T:fg Sets the foreground/background colors (see COLOR /? for more info) Sets the default console foreground and background colors. ------------------------------------------------------------------------------------------- COLOR [attr] attr Specifies color attribute of console output Color attributes are specified by TWO hex digits -- the first corresponds to the background; the second the foreground. Each digit can be any of the following values: 0 = Black 8 = Gray 1 = Blue 9 = Light Blue 2 = Green A = Light Green 3 = Aqua B = Light Aqua 4 = Red C = Light Red 5 = Purple D = Light Purple 6 = Yellow E = Light Yellow 7 = White F = Bright White -------------------------------------8<------------------------------------------ > there are 10 types of people in the world, those who understand binary and those who don't. Link to comment Share on other sites More sharing options...
hans_schwaebli Posted September 21, 2006 Author Share Posted September 21, 2006 I can set only some colors in the dos box. I cannot use the many colors which I can by configuring the link. And more important, I cannot change any other things like box size, buffer size and font. I didn't find any solution. So I simly try to start the link programatically so that I get the same effect as if I start it by double clicking the link. I know that I could configure a keyboard shortcut, but that would be another workaround. So is there any programatical solution for such a "simple" thing which everyone of us does dozens of times each day manually: starting a link? Link to comment Share on other sites More sharing options...
jinxter Posted September 21, 2006 Share Posted September 21, 2006 maybe try by using the command start ... start c:\aProgram.lnk /J > there are 10 types of people in the world, those who understand binary and those who don't. Link to comment Share on other sites More sharing options...
hans_schwaebli Posted September 21, 2006 Author Share Posted September 21, 2006 maybe try by using the command start ...start c:\aProgram.lnk/JIt does not work if I use: Run("start C:/my.lnk")If the link points to a .cmd file and I configured the link, the cmd file is started, but without the configuration from the lnk file (colors, fonts, buffers etc.) Link to comment Share on other sites More sharing options...
jinxter Posted September 21, 2006 Share Posted September 21, 2006 try: Run(@ComSpec & " /c " & 'start c:\aProgram.lnk', "", @SW_HIDE) but it might not work either :/ ... I'm trying to help out though > there are 10 types of people in the world, those who understand binary and those who don't. Link to comment Share on other sites More sharing options...
hans_schwaebli Posted September 21, 2006 Author Share Posted September 21, 2006 try:Run(@ComSpec & " /c " & 'start c:\aProgram.lnk', "", @SW_HIDE)but it might not work either :/ ... I'm trying to help out though Same effect. Link to comment Share on other sites More sharing options...
CWorks Posted September 21, 2006 Share Posted September 21, 2006 (edited) you need to use mode to set the extended attributes of the cmd window use mode in your batch file add this to the top of your batch file to see how it works @echo off& Color F8&MODE CON: COLS=73 LINES=20 or you can do it like this @echo off Color F8 MODE CON: COLS=73 LINES=20 to get color codes do this in cmd window color /? Edited September 21, 2006 by CWorks Link to comment Share on other sites More sharing options...
jinxter Posted September 21, 2006 Share Posted September 21, 2006 Dang... I just tried it, and it works for me with the comspec-code... it just doesn't bring the changes in the lnk file... strange... not as easy as I first thought > there are 10 types of people in the world, those who understand binary and those who don't. Link to comment Share on other sites More sharing options...
Xenobiologist Posted September 21, 2006 Share Posted September 21, 2006 HI, this should work Run(@ComSpec & ' /c camstudio.lnk', @DesktopCommonDir, @SW_HIDE) So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
hans_schwaebli Posted September 22, 2006 Author Share Posted September 22, 2006 HI, this should work Run(@ComSpec & ' /c camstudio.lnk', @DesktopCommonDir, @SW_HIDE) So long, MegaIt does not work. It starts the shortcut, but doesn't use its settings (colors, buffer and so on of the DOS box). Link to comment Share on other sites More sharing options...
Xenobiologist Posted September 22, 2006 Share Posted September 22, 2006 Hi, what app are you trying to start? It works for me. So long, Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
hans_schwaebli Posted September 22, 2006 Author Share Posted September 22, 2006 Hi,what app are you trying to start? It works for me. So long,MegaOkay, here is the recipe for failure:1. Create a new .cmd file and write just one line in it: pause2. Create a new shortcut for the new .cmd file.3. Modify the shortcut properties, changing DOS box' colors, font, size and so on.4. Try to start that .lnk shortcut file programatically and expect that it a) starts and that it displays the colors, font and size you configured. Link to comment Share on other sites More sharing options...
hans_schwaebli Posted September 22, 2006 Author Share Posted September 22, 2006 [codeMODE CON: COLS=73 LINES=20 It does not show a scroll bar if there are more characters than 73 in a line. Instead it breaks it to the next line, which I don't want. In the shortcut properties I can set a width and height buffer. Can I do this with a DOS command too? Link to comment Share on other sites More sharing options...
jinxter Posted September 22, 2006 Share Posted September 22, 2006 (edited) I can get a) working without problem. is another matter, it just doesn't read the .lnk fileattributes it seems... hmmmmm.... one way is to use a configuration file, although that is a bit harsh.... still looking. (btw, it reads the maximize attribute from the .lnk file so it is in fact running the lnk file) Edited September 22, 2006 by jinxter > there are 10 types of people in the world, those who understand binary and those who don't. Link to comment Share on other sites More sharing options...
jinxter Posted September 22, 2006 Share Posted September 22, 2006 (edited) This will change the Command prompt a bit safe I know, but it's just so it doesn't send in the dosbox. and this is probably not the solution, but it works at least. I will look further. Run(@ComSpec & " /k " & 'start c:\q.cmd.lnk', "", @SW_HIDE) WinWait("C:\WINNT\system32\cmd.exe","") If Not WinActive("C:\WINNT\system32\cmd.exe","") Then WinActivate("C:\WINNT\system32\cmd.exe","") WinWaitActive("C:\WINNT\system32\cmd.exe","") WinWait("""C:\WINNT\system32\cmd.exe"" Properties","") If Not WinActive("""C:\WINNT\system32\cmd.exe"" Properties","") Then WinActivate("""C:\WINNT\system32\cmd.exe"" Properties","") WinWaitActive("""C:\WINNT\system32\cmd.exe"" Properties","") Send("{ALTDOWN}{SPACE}{ALTUP}p{TAB}{RIGHT}{RIGHT}{SHIFTDOWN}{TAB}{SHIFTUP}{LEFT}{TAB}20") WinWait("Apply Properties","") If Not WinActive("Apply Properties","") Then WinActivate("Apply Properties","") WinWaitActive("Apply Properties","") Send("{ENTER}{ENTER}") You can set the values for all the cmd-prompts, but I guess that is not what you want. Edited September 22, 2006 by jinxter > there are 10 types of people in the world, those who understand binary and those who don't. Link to comment Share on other sites More sharing options...
Gideon Posted October 6, 2009 Share Posted October 6, 2009 does shellexecute command work? Many times you need to think like hobby-bob:') Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now