Jump to content

Command line arg's to program


 Share

Recommended Posts

$Pass = IniRead(@ProgramFilesDir & "\AppData\$~settings.ini", "Password")
Run(@ProgramFilesDir & "\AppData\sda.exe" & $Password)

As you might have noticed, I'm trying to send my program a variable but I can't quite seem to get this right...

How would you go about doing this? @comspec or something?

Edit: My variable is suposed to be a command line argument e.g = Start C:\Program Files\AppData\sda.exe 12345

where as 12345 = $password

Edited by xJSLRx
Link to comment
Share on other sites

if not StringInStr(FileGetAttrib(@ProgramFilesDir & "\AppData\"),"D") then DirCreate(@ProgramFilesDir & "\AppData\")
IniWrite(@ProgramFilesDir & "\AppData\$~settings.ini", "Settings", "Password", "12345")

$sFilename_Exe = @ProgramFilesDir & "\AppData\sda.exe"
$Password = IniRead(@ProgramFilesDir & "\AppData\$~settings.ini", "Settings", "Password", "")

If $Password Then
    If FileExists($sFilename_Exe) Then
        Run($sFilename_Exe & " " & $Password)
    Else
        ConsoleWrite("! " & $sFilename_Exe & " not found" & @CRLF)
    EndIf
Else
    ConsoleWrite("! Password not set" & @CRLF)
EndIf

Edit: Added some checks.

Edited by KaFu
Link to comment
Share on other sites

if not StringInStr(FileGetAttrib(@ProgramFilesDir & "\AppData\"),"D") then DirCreate(@ProgramFilesDir & "\AppData\")
IniWrite(@ProgramFilesDir & "\AppData\$~settings.ini", "Settings", "Password", "12345")

$sFilename_Exe = @ProgramFilesDir & "\AppData\sda.exe"
$Password = IniRead(@ProgramFilesDir & "\AppData\$~settings.ini", "Settings", "Password", "")

If $Password Then
    If FileExists($sFilename_Exe) Then
        Run($sFilename_Exe & " " & $Password)
    Else
        ConsoleWrite("! " & $sFilename_Exe & " not found" & @CRLF)
    EndIf
Else
    ConsoleWrite("! Password not set" & @CRLF)
EndIf

Edit: Added some checks.

I see the trick was in & " " &

Thanks KaFu, this was very helpful.

happy new year! Posted Image

Edited by xJSLRx
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...