Sign in to follow this  
Followers 0
JenK

Using the RUN command

6 posts in this topic

Hoping that someone could help out with this. I do not use AutoIT that often and am trying to reference a variable or built-in macro from within the Run command. The problem is that the Run command is calling an executable with command line parameters following it. The Command line then contains the variable that is trying to be referenced. Because the Run command is using quotes ("") the variable is not being referenced as its value from the registry but rather the variable code itself ($CNAME).

Here's my code (some editing done on the command line but you should be able to see what I'm trying to do):

Global $CName=RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName", "ComputerName")

Run("c:\temp\dsmod.exe group CN=Wireless_Group -addmbr CN=$CName")

I have also tried to use the built-in macro (@ComputerName) in exchange for my variable $CName but it doesn't seem to work either. The dsmod.exe needs the computer name of the local system.

Any help would be greatly appreciated.

Br,

Jen

Share this post


Link to post
Share on other sites



Run("c:\temp\dsmod.exe group CN=Wireless_Group -addmbr CN="&$CName)

:)

Share this post


Link to post
Share on other sites

AutoIt doesn't render variables in quotes like PHP does.

$variable = "oranges"

MsgBox(0,"", "I like " & $variable)

You can also use StringFormat():

$result = StringFormat("I like %s", $variable)

MsgBox(0,"",$result)

Share this post


Link to post
Share on other sites

Sorry that I omitted this but there are actually commands following the referenced variable:

$CName,OU=OL...

Share this post


Link to post
Share on other sites

Sorry that I omitted this but there are actually commands following the referenced variable:

$CName,OU=OL...

Whats the problem? Just add them on.

$a = "A"

$b = "B"

$c = "C"

$var = $a & $b & $c
$var = StringFormat("%s%s%s", $a,$b,$c)

$var = $a & " " & $b & " " $c
$var = StringFormat("%s %s %s", $a,$b,$c)

Share this post


Link to post
Share on other sites

Thanks for the help! I got it to work flawlessly.

Share this post


Link to post
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
Sign in to follow this  
Followers 0