JRSmile Posted November 17, 2005 Share Posted November 17, 2005 (edited) Hi there, I've written some small functions to register applications into the registry. BUT i want to make my app console compatible. it is very easy to help me, but i can't see my mistakes... please help me expandcollapse popup#cs command promt compatibility if $CmdLine[0] > 0 then select case $CmdLine[1] = "file" if $CmdLine[2] <> 0 then _AppFromFile($CmdLine[2]) Else help() EndIf case $CmdLine[1] = "init" if $CmdLine[2] <> 0 then _AppInit($CmdLine[2]) Else help() EndIf case $CmdLine[1] = "deploy" if $CmdLine[2] <> 0 or $CmdLine[3] <> 0 then _AppDeploy($CmdLine[2],$CmdLine[3]) Else help() EndIf case $CmdLine[1] = "execute" _AppExecute() case Else help() EndSelect Else help() EndIf func help() MsgBox(0,"Help","install.exe [MENU] [TITLE/FILE] [PATH]" & @CRLF & "to install from file:" & @CRLF & "install.exe file C:\install.conf" & @CRLF & "to install with batch script:" & @CRLF & "first make a install.exe init TITEL_OF_THE_INSTALLATION" & @CRLF & 'then a install.exe deploy "PROGRAM_NAME" "PROGRAM_PATH" as often as you want' & @CRLF & "and if you want to start the installation and don't want to wait until the next login, write install.exe execute") EndFunc ;==>help #ce ;_AppFromFile("install.conf") ;_AppInit("JRSmile Application installation");please activate only AppFromFile OR AppInit and AppDeploy ;_AppDeploy("Test1","C:\test.exe") ;_AppExecute(); if you want to schedule the installation to the next login just disable this line with a ";" func _AppFromFile($path) if not FileExists($path) then FileWrite($path,"") $file = FileOpen($path, 0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open config file.") Exit EndIf ; Read in lines of text until the EOF is reached $stop = 0 While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop $aConf = StringSplit($line,"|") if $stop = 0 then _AppInit($aConf[2]) $stop = 1 Else _AppDeploy($aConf[1],$aConf[2]) EndIf Wend FileClose($file) EndFunc ;==>_AppFromFile func _AppInit($title) if not RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx", "TITLE") <> 0 Then RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx", "TITLE", "REG_SZ", $title) EndIf EndFunc ;==>_AppInit func _AppDeploy($title,$path) if $title = "" or $path = "" then Exit $inc = 0 while 1 $inc = $inc + 1 $len = StringLen ($inc) $final_len = 5 - $len $devstr = "" for $i = 1 to $final_len $devstr = $devstr & "0" Next if not RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\" & $devstr & $inc,"") <> 0 then ExitLoop if $devstr & $inc = "99999" then Exit wend RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\" & $devstr & $inc,"","REG_SZ",$title) $path = StringReplace($path,"\","\\") RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx\" & $devstr & $inc,"2","REG_SZ",$path) EndFunc ;==>_AppDeploy func _AppExecute() Run("rundll32.exe iernonce.dll,RunOnceExProcess") EndFunc ;==>_AppExecute ok.... were is the error the part which has be excluded with #cs and #ce makes me trouble. how can i get the right parameters to execute the functions. kind regards, JRSmile EDIT: atached the stable here ... Edited November 22, 2005 by JRSmile $a=StringSplit("547275737420796F757220546563686E6F6C75737421","") For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4) Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI" Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile; MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-) Link to comment Share on other sites More sharing options...
MHz Posted November 17, 2005 Share Posted November 17, 2005 Check the parameter count each time with $CmdLine[0]. Checking by $Cmdline[?] may incur errors as you do not know if they have been used to check against. ? represents 1 or 2...if $CmdLine[0] then select case $CmdLine[1] = "file" if $CmdLine[0] = 2 then _AppFromFile($CmdLine[2]) Else help() EndIf case $CmdLine[1] = "init" if $CmdLine[0] = 2 then _AppInit($CmdLine[2]) Else help() EndIf case $CmdLine[1] = "deploy" if $CmdLine[0] = 3 then _AppDeploy($CmdLine[2],$CmdLine[3]) Else help() EndIf case $CmdLine[1] = "execute" _AppExecute() case Else help() EndSelect Else help() EndIf Link to comment Share on other sites More sharing options...
JRSmile Posted November 17, 2005 Author Share Posted November 17, 2005 thx $a=StringSplit("547275737420796F757220546563686E6F6C75737421","") For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4) Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI" Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile; MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-) Link to comment Share on other sites More sharing options...
JRSmile Posted November 22, 2005 Author Share Posted November 22, 2005 (edited) find the stable in the first thread... Edited November 22, 2005 by JRSmile $a=StringSplit("547275737420796F757220546563686E6F6C75737421","") For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4) Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI" Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile; MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-) 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