Jump to content

Run() with variables


Recommended Posts

Hi :(

----------------------

I'm trying to use the Windows's netsh firewall syntax in AutoIt..

This is my script so far:

$ver = "v1.8.1"
$installdir = RegRead("HKLM\SOFTWARE\Inloggen bij Teletop", "")
$prog = $installdir & "\Inloggen bij Teletop " & $ver & ".exe"
Run("netsh firewall add allowedprogram program = " & $prog & " name = ""Inloggen bij Teletop"" mode = ENABLE")

Well this isn't working, it's hat got to do with the quotes ("), I don't know what's the right combination / order with the quotes...

When I do it like this, it works... but i want it with the vars :) :

Run("netsh firewall add allowedprogram program = ""D:\Program Files\Inloggen bij Teletop v1.8.1\Inloggen bij Teletop v1.8.1.exe"" name = ""Inloggen bij Teletop"" mode = ENABLE")

The prog var is the good var.. the only problem are the quotes...

Can somebody help me with this?

Cheers,

Andreas

Edited by AndreasVliegen
Link to comment
Share on other sites

  • Moderators

Did you try using "&" between the quotes?

$ver = "v1.8.1"
$installdir = RegRead("HKLM\SOFTWARE\Inloggen bij Teletop", "")
$prog = $installdir & "\Inloggen bij Teletop " & $ver & ".exe"
Run("netsh firewall add allowedprogram program = " & $prog & " name = " & "Inloggen bij Teletop" & " mode = ENABLE")

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Did you try using "&" between the quotes?

$ver = "v1.8.1"
$installdir = RegRead("HKLM\SOFTWARE\Inloggen bij Teletop", "")
$prog = $installdir & "\Inloggen bij Teletop " & $ver & ".exe"
Run("netsh firewall add allowedprogram program = " & $prog & " name = " & "Inloggen bij Teletop" & " mode = ENABLE")
That one isn't working :)
Link to comment
Share on other sites

  • Developers

Parameters need to be quoted .... this should be close (untested):

Run(@ComSpec & " /c netsh firewall add allowedprogram program = ""D:\Program Files\Inloggen bij Teletop v1.8.1\Inloggen bij Teletop v1.8.1.exe"" name = ""Inloggen bij Teletop"" mode = ENABLE")
oÝ÷ Øè®f¥*ky÷«¶¬Á¬¢ºÞiÖX²jëh×6Run(@ComSpec & ' /c netsh firewall add allowedprogram program = "D:\Program Files\Inloggen bij Teletop v1.8.1\Inloggen bij Teletop v1.8.1.exe" name = "Inloggen bij Teletop" mode = ENABLE')
Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Parameters need to be quoted .... this should be close (untested):

Run(@ComSpec & " /c netsh firewall add allowedprogram program = ""D:\Program Files\Inloggen bij Teletop v1.8.1\Inloggen bij Teletop v1.8.1.exe"" name = ""Inloggen bij Teletop"" mode = ENABLE")
I need it with variables,

and this works, i know that already:

Run("netsh firewall add allowedprogram program = ""D:\Program Files\Inloggen bij Teletop v1.8.1\Inloggen bij Teletop v1.8.1.exe"" name = ""Inloggen bij Teletop"" mode = ENABLE")

But that is without the vars :)

Link to comment
Share on other sites

  • Developers

Run(@ComSpec & ' /c netsh firewall add allowedprogram program = "' & $prog & '" name = "Inloggen bij Teletop" mode = ENABLE')

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Run(@ComSpec & ' /c netsh firewall add allowedprogram program = "' & $prog & '" name = "Inloggen bij Teletop" mode = ENABLE')
OK, give it up JdeB... how'd you get the syntax color coding to paste into your reply? :)
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

Just don't know.... I only know how SciTE does it...

Jon is the expert web syntax highlighter .. :(

I do all my AutoIT work in SciTE, and copy\paste to the forum from it all the time (like to hit the code with Tidy before posting it). I've never noticed the color coding preserved before. I also note your color coding was not preserved where I quoted it in my post... hmm... :)

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

  • Developers

I do all my AutoIT work in SciTE, and copy\paste to the forum from it all the time (like to hit the code with Tidy before posting it). I've never noticed the color coding preserved before. I also note your color coding was not preserved where I quoted it in my post... hmm... :)

The color coding is not preserved from SciTE but when pasted in the forum post and you surround it with [ autoit] ... [ /autoit] in stead of [ code] ... [ /code] it will now be color coded with another php script.

:(

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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...