Jump to content











Photo
- - - - -

Add_Shortcut (problem with parameters)


  • Please log in to reply
10 replies to this topic

#1 u2o

u2o

    Frequent Member

  • .script developer
  • 257 posts
  • Location:Argentina
  •  
    Argentina

Posted 03 June 2012 - 07:28 AM

I need to send parameters to a CMD file, but can not find the proper way to do the shortcut.

This is the cmd SetRes.cmd (need 2 parameters eg. SetRes.cmd -r1280x720x32 -hide)
@ECHO OFF

SET SETRES="%windir%system32setresolution.exe"

SET BGINFO="%programfiles%BGInfobginfo.exe"

SET BGINFOPARAM="%programfiles%BGInfobginfo.bgi" /timer:0



TITLE Bypasser

color 0F

echo.



SET AllParams=%*

SET Param1=%1

SET Param2=%2



IF "%Param1%" == "" GOTO _ERR1

IF "%Param2%" == "" GOTO _ERR1



echo. Param: OK



IF NOT EXIST "%SETRES%" GOTO _exit



Start "" /B %SETRES% %AllParams%

Sleep.vbs 3000

Start "" /B Taskkill.exe /IM setresolution.exe



IF NOT EXIST "%BGINFO%" GOTO _exit



Start "" /B %BGINFO% %BGINFOPARAM%



EXIT





:_ERR1

	echo. Param: ERROR

	echo.

	echo. Required Param: "2" Your params: [%AllParams%]

	echo.

	pause.



:_exit


I've tried with

Add_Shortcut,StartMenu,%SMProgramDir%,#$pSystemroot#$psystem32SetRes.cmd,"%ProgramTitle% 1280x720x32",#$pSystemRoot#$pSystem32,"-r1280x720x32 -hide","#$pSystemroot#$psystem32SetResolution.exe",2,"SetRes 1280x720x32"
or
Add_Shortcut,StartMenu,%SMProgramDir%,#$pSystemroot#$psystem32SetRes.cmd,"%ProgramTitle% 1280x720x32",#$pSystemRoot#$pSystem32,"#$q-r1280x720x32#$s-hide#$q","#$pSystemroot#$psystem32SetResolution.exe",2,"SetRes 1280x720x32"


I tried other ways and does not work...

What am I doing wrong?

#2 ChrisR

ChrisR

    Silver Member

  • .script developer
  • 784 posts
  •  
    France

Posted 03 June 2012 - 08:42 AM

Hi u2o

I do not know what you're doing wrong ;)
but the parameters works well, I tried with this (Add_Shortcut, AddAutoRun)
for info StartMode=(1,2,3)#$cHotKey,ToolTipText in Add_Shortcut is not taken into account, but unrelated to work or not.

Set AllParams=%*

Set Param1=%1

Set Param2=%2

echo AllParams %AllParams% >>x:WindowsTempSetRes.log

echo Param1 %Param1% >>x:WindowsTempSetRes.log

echo Param2 %Param2% >>x:WindowsTempSetRes.log



IF "%Param1%" == "" GOTO _Exit

IF "%Param2%" == "" GOTO _Exit

echo Param: OK>>x:WindowsTempSetRes.log  

echo. >>x:WindowsTempSetRes.log

:_Exit

Add_Shortcut,StartMenu,SetResFolder,#$pSystemroot#$psystem32SetRes.cmd,SetResName,#$pSystemroot#$psystem32,"-r1280x720x32 -hide",#$pSystemroot#$psystem32dccw.exe

AddAutoRun,"AutorunSetRes",#$pSystemroot#$psystem32SetRes.cmd,"-r1024x768x32 -open",1

:cheers:
  • Brito likes this

#3 u2o

u2o

    Frequent Member

  • .script developer
  • 257 posts
  • Location:Argentina
  •  
    Argentina

Posted 03 June 2012 - 09:16 AM

In my tests, all times, is well written:
Add_Shortcut,StartMenu,%SMProgramDir%,#$pSystemroot#$p\system32\SetRes.cmd,"%ProgramTitle% 1024x768x32",#$pSystemRoot#$p\System32,"-r1024x776x32 -hide","#$pSystemroot#$p\system32\SetResolution.exe",2,"SetRes 1024x768x32"

  Add_Shortcut,StartMenu,%SMProgramDir%,#$pSystemroot#$p\system32\SetRes.cmd,"%ProgramTitle% 1280x720x32",#$pSystemRoot#$p\System32,"-r1280x720x32 -hide","#$pSystemroot#$p\system32\SetResolution.exe",2,"SetRes 1280x720x32"

  Add_Shortcut,StartMenu,%SMProgramDir%,#$pSystemroot#$p\system32\SetRes.cmd,"%ProgramTitle% 1280x720x32 b",#$pSystemRoot#$p\System32,"-r1280x720x32 -hide","#$pSystemroot#$p\system32\SetResolution.exe",2

  Add_Shortcut,StartMenu,%SMProgramDir%,#$pSystemroot#$p\system32\SetRes.cmd,"%ProgramTitle% 1280x720x32 c",#$pSystemRoot#$p\System32,"-r1280x720x32 -hide","#$pSystemroot#$p\system32\SetResolution.exe"


Start On=%systemroot%\system32

Start Mode=Minimized

comment=SetRes xxxx
But Target is only
%systemroot%\system32\SetRes.cmd


#4 u2o

u2o

    Frequent Member

  • .script developer
  • 257 posts
  • Location:Argentina
  •  
    Argentina

Posted 03 June 2012 - 09:21 AM

Chris, this works...


Add_Shortcut,StartMenu,%SMProgramDir%,#$pSystemroot#$p\system32\SetRes.cmd,"%ProgramTitle% 1280x720x32 d",#$pSystemRoot#$p\System32,"-r1280x720x32 -hide"


Will this be a problem of the CommonApi?

#5 ChrisR

ChrisR

    Silver Member

  • .script developer
  • 784 posts
  •  
    France

Posted 03 June 2012 - 10:49 AM

I copied the same lines in my test (with my same SetRes.cmd of test and SetResolution)

Add_Shortcut,StartMenu,%SMProgramDir%,#$pSystemroot#$psystem32SetRes.cmd,"%ProgramTitle% 1280x720x32 a",#$pSystemRoot#$pSystem32,"-r1280x720x32 -hide","#$pSystemroot#$psystem32SetResolution.exe",2,"SetRes 1280x720x32"

Add_Shortcut,StartMenu,%SMProgramDir%,#$pSystemroot#$psystem32SetRes.cmd,"%ProgramTitle% 1280x720x32 b",#$pSystemRoot#$pSystem32,"-r1280x720x32 -hide","#$pSystemroot#$psystem32SetResolution.exe"

Add_Shortcut,StartMenu,%SMProgramDir%,#$pSystemroot#$psystem32SetRes.cmd,"%ProgramTitle% 1280x720x32 c",#$pSystemRoot#$pSystem32,"-r1280x720x32 -hide"

gives in Win7PE.cfg

SetResFolder|MyTitle 1280x720x32 c|%Systemroot%system32SetRes.cmd||-r1280x720x32 -hide

SetResFolder|MyTitle 1280x720x32 b|%Systemroot%system32SetRes.cmd|%Systemroot%system32SetResolution.exe|-r1280x720x32 -hide

SetResFolder|MyTitle 1280x720x32 a|%Systemroot%system32SetRes.cmd|%Systemroot%system32SetResolution.exe|-r1280x720x32 -hide

The 3 shortcuts works well for me !!!
I do not understand why the first 2 lines do not work for you

In the API, the Parameters #8 (StartMode=(1,2,3)#$cHotKey) and #9 (ToolTipText) in Add_Shortcut work only for PE1, no problem for PE2/3, they're just not used (no writing in the config file and not used also in shortcuts.exe).

:cheers:

#6 u2o

u2o

    Frequent Member

  • .script developer
  • 257 posts
  • Location:Argentina
  •  
    Argentina

Posted 04 June 2012 - 05:31 AM

I'm testing it on LiveXP. CommonApi Date=06-09-2009 and Version=16

If I use
Add_Shortcut,StartMenu,%SMProgramDir%,#$pSystemroot#$p\system32\SetRes.cmd,"%ProgramTitle% 1024x768x32",#$pSystemRoot#$p\System32,"-r1024x776x32 -hide","#$pSystemroot#$p\system32\SetResolution.exe",2,"SetRes 1024x768x32"
The lnk get the icon of the application exe. But do not assign parameters.

This works (without set the icon)
Add_Shortcut,StartMenu,%SMProgramDir%,"#$q#$pSystemroot#$p\system32\SetRes.cmd#$q","%ProgramTitle% 1280x720x32","#$q#$pSystemRoot#$p\System32#$q","-r1280x720x32 -hide",,2

Done, problem solved for me ... but something strange is that no quotation marks in the fields of lnk.

In the shorcut
Target=%systemroot%\system32\SetRes.cmd -r1280x720x32 -hide

StartOn=%systemroot%\system32

and these should be
Target="%systemroot%\system32\SetRes.cmd" -r1280x720x32 -hide

StartOn="%systemroot%\system32"


#7 u2o

u2o

    Frequent Member

  • .script developer
  • 257 posts
  • Location:Argentina
  •  
    Argentina

Posted 14 June 2012 - 07:41 AM

After several tests, I think the problem is between CommonApi and shortcutParse.

Command1

Add_Shortcut,StartMenu,%SMProgramDir%,"%Windir%\system32\SetRes.cmd","%ProgramTitle% 800x600x32","%Windir%\System32","-r800x600x32 -hide",,2,"%ProgramTitle% 800x600x32"


File: SetRes 800x600x32_2012-Jun-14 043345875.shc

[Created]

Program=shortcutParse

Version=1.1.2

Copyright=(C) 2007 Peter Schlang

Date=2012-Jun-14 043345875

[Shortcut]

targetDir=

modelDir=

shortCutName=SetRes#$s800x600x32

shortCutType=SM

shortCutLocation=Herramientas#$sdel#$sSistema

shortCutExe=%Windir%\system32\SetRes.cmd

shortCutToolTip=SetRes#$s800x600x32

shortCutParameters=-r800x600x32#$s-hide

shortCutShow=SW_SHOWMINNOACTIVE

shortCutDir=%Windir%\System32

shortCutHotKey=

shortCutIconFile=

shortCutIcon=0


Command2

Add_Shortcut,StartMenu,%SMProgramDir%,"%Windir%\system32\SetRes.cmd","zz %ProgramTitle% a 800x600x32","%Windir%\System32","-r800x600x32 -hide","%Windir%\system32\SetResolution.exe",2


File: zz SetRes a 800x600x32_2012-Jun-14 043348500.shc

[Created]

Program=shortcutParse

Version=1.1.2

Copyright=(C) 2007 Peter Schlang

Date=2012-Jun-14 043348500

[Shortcut]

targetDir=

modelDir=

shortCutName=zz#$sSetRes#$sa#$s800x600x32

shortCutType=SM

shortCutLocation=Herramientas#$sdel#$sSistema

shortCutExe=%Windir%\system32\SetRes.cmd

shortCutToolTip=

shortCutParameters=

shortCutShow=SW_SHOWMINNOACTIVE

shortCutDir=%Windir%\System32

shortCutHotKey=

shortCutIconFile=%Windir%\system32\SetResolution.exe

shortCutIcon=0



#8 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12707 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 14 June 2012 - 10:39 AM

Thanks, u2o!

I'll have a look into shortcutParse and fix when possible.

Peter

#9 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12707 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 14 June 2012 - 12:49 PM

After several tests, I think the problem is between CommonApi and shortcutParse.

I tested in the multiPE project:

[main]

Title=My Program

Description=my Program description

Selected=True

Level=5

Version=1

[variables]

%ProgramTitle%=myProgram

%ProgramEXE%=myProgram.exe

%ProgramFolder%=myProgramFolder

[process]

Add_Shortcut,StartMenu,%SMProgramDir%,"%Windir%system32SetRes.cmd","%ProgramTitle% 800x600x32","%Windir%System32","-r800x600x32 -hide",,2,"%ProgramTitle% 800x600x32"

Add_Shortcut,StartMenu,%SMProgramDir%,"%Windir%system32SetRes.cmd","zz %ProgramTitle% a 800x600x32","%Windir%System32","-r800x600x32 -hide","%Windir%system32SetResolution.exe",2

Results:

[Created]

Program=shortcutParse

Version=1.2.2

Copyright=(C) 2007 Peter Schlang

Date=2012-Jun-14 144409718

Command="-C:V:MULTI TESTWORKBENCHMULTIPE_XPUSERDATAPROJECTINFO.INI" "-O:V:MULTI TESTTEMPMULTIPE_XPSHCTEMP.INI" -ST:STARTMENU%SMPROGRAMDIR% -SE:%WINDIR%SYSTEM32SETRES.CMD "-SL:MYPROGRAM 800X600X32" "-SP:-R800X600X32 -HIDE  2 MYPROGRAM 800X600X32" -SW:%WINDIR%SYSTEM32

Position=SystemDrive

[Shortcut]

targetDir=V:multi TestWorkbenchmultiPE_XPUserData

modelDir=V:multi TestWorkbenchmultiPE_XPUserData

shortCutType=SM

shortCutName=myProgram#$s800x600x32

shortCutExe=%Windir%system32SetRes.cmd

shortCutLocation=%SMProgramDir%

shortCutToolTip=

shortCutParameters=-r800x600x32#$s-hide#$s#$s2#$smyProgram#$s800x600x32

shortCutShow=

shortCutDir=%Windir%System32

shortCutHotKey=

shortCutIconFile=

shortCutIcon=0


[Created]

Program=shortcutParse

Version=1.2.2

Copyright=(C) 2007 Peter Schlang

Date=2012-Jun-14 144409906

Command="-C:V:MULTI TESTWORKBENCHMULTIPE_XPUSERDATAPROJECTINFO.INI" "-O:V:MULTI TESTTEMPMULTIPE_XPSHCTEMP.INI" -ST:STARTMENU%SMPROGRAMDIR% -SE:%WINDIR%SYSTEM32SETRES.CMD "-SL:ZZ MYPROGRAM A 800X600X32" "-SP:-R800X600X32 -HIDE %WINDIR%SYSTEM32SETRESOLUTION.EXE 2 " -SW:%WINDIR%SYSTEM32

Position=SystemDrive

[Shortcut]

targetDir=V:multi TestWorkbenchmultiPE_XPUserData

modelDir=V:multi TestWorkbenchmultiPE_XPUserData

shortCutType=SM

shortCutName=zz#$smyProgram#$sa#$s800x600x32

shortCutExe=%Windir%system32SetRes.cmd

shortCutLocation=%SMProgramDir%

shortCutToolTip=

shortCutParameters=-r800x600x32#$s-hide#$s%Windir%system32SetResolution.exe#$s2#$s

shortCutShow=

shortCutDir=%Windir%System32

shortCutHotKey=

shortCutIconFile=

shortCutIcon=0

This issue seems to bei either in "Common" API, or in the older version of shortcutParse.

IMHO no reason to change anything in shortcutParse.

Peter

#10 u2o

u2o

    Frequent Member

  • .script developer
  • 257 posts
  • Location:Argentina
  •  
    Argentina

Posted 14 June 2012 - 04:54 PM

I tested in the multiPE project:
...
This issue seems to bei either in "Common" API, or in the older version of shortcutParse.
IMHO no reason to change anything in shortcutParse.


Peter: Thanks for wasting your time on this issue :thumbsup:

I will try to find a solution among the tangle of CommonApi :book:

#11 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12707 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 14 June 2012 - 05:59 PM

When you come to the result, that "Common"_API should be completelly redesigned, you have the first helper for that!

Peter




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users