Jump to content

Recommended Posts

Posted

Hi, I am used to AHK and I have spent an hour or two on just this, so please throw me a bone.. :)

OK, trying to get a the current minute + 30 seconds to a variable to go into a line of code to be run in dos... Just like the example in help, but I added "$VAR" to guess,,,(I hope I am right)LOL ,

Run(@ComSpec & " /c " & 'commandName$VAR', "", @SW_HIDE)

Anyways, here is what I am having trouble with, got the below code to add 30 sec, but I can not figure out this stuff.. MsgBox(0,$x,$MyTime[$x]) and I plan on switching the correct one for the $VAR above...

#include <Date.au3>



$sNewDate = _DateAdd( 's',30, _NowCalc())

MsgBox( 4096, "", "Date: " & $sNewDate )

Dim $MyDate
Dim $MyTime
_DateTimeSplit($sNewDate,$MyDate,$MyTime)


For $x = 1 to $MyTime[0]
    [b]MsgBox(0,$x,$MyTime[$x])[/b]
Next

Thank you, first impressions are I like it. ;)

Posted

Hi,

Welcome to the forums :)

First off,

This is how you should run the DOS command.

Run(@ComSpec & " /c " & $VAR, "", @SW_HIDE)

Command$var, isn't something that will do anything in CMD... ;) Also, you cannot call varibles in strings with the current way you are doing it. You could like:

Opt ("ExpandVarStrings", 1)
$VAR = "Netstat -a"
Run(@ComSpec & " /c $VAR$", "", @SW_HIDE)

MsgBox (0, "", "$var$")

It is way eaiser to just do that the first way mentioned.

Now for the last part, it appears you are calling the wrong varible? I'm not sure, but thats what it appears to be... :P

It should be:

#include <Date.au3>

$sNewDate = _DateAdd('s', 30, _NowCalc())

MsgBox(4096, "", "Date: " & $sNewDate)

Dim $MyDate
Dim $MyTime
_DateTimeSplit($sNewDate, $MyDate, $MyTime)

For $x = 1 To $MyDate[0]
    MsgBox(0, $x, $MyDate[$x])
Next
Posted (edited)

Encapsulate the entire string in single quotes and you won't have to use double-double quotes within it.

Run('schtasks.exe /create /sc once /ru system /tn somename /Tr "c:\program files\911 pc fix . com\utils1\blabla.exe" /st ' & $var, "", @SW_MAXIMIZE)

Edited by weaponx
Posted

Don't hate programming, love programming. It's a much more gratifying teacher of patience than children.

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

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
×
×
  • Create New...