Jump to content

dos command in autoit


Recommended Posts

I'm sure this is very simple

I am trying to do a dos command but it doesn't change

Is %programfiles% in dos the same as @ProgramFilesDir in autoit ?

$rc = _RunDos('set programfiles=e:\backups')

MsgBox(0, "program files (should be e:\backups):", @ProgramFilesDir)

"set programfiles=e:\backups" works in dos "changedirectorys.cmd"

Thanks

Link to comment
Share on other sites

I'm sure this is very simple

I am trying to do a dos command but it doesn't change

Is %programfiles% in dos the same as @ProgramFilesDir in autoit ?

Yes. But not the same as @ProgramsDir and @ProgramsCommonDir, which are annoyingly similar. I really wish those had been named @ProfileProgramsDir, or something to be more clear, but it's too late to change it now without breaking legacy code.

$rc = _RunDos('set programfiles=e:\backups')

MsgBox(0, "program files (should be e:\backups):", @ProgramFilesDir)

"set programfiles=e:\backups" works in dos "changedirectorys.cmd"

Thanks

From inside AutoIt, you could just use EnvSet(). If you want to set System Environment variables, then you are better off writing to the registry at:

HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

:)

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

I tried EnvSet but it didnot change "@ProgramFilesDir"

Am I missing something

;$rc = _RunDos('set programfiles=e:\backups')

EnvSet("Programfiles", "e:\backups")

MsgBox(0, "program files (should be e:\backups):", @ProgramFilesDir)

Link to comment
Share on other sites

I tried EnvSet but it didnot change "@ProgramFilesDir"

Am I missing something

;$rc = _RunDos('set programfiles=e:\backups')

EnvSet("Programfiles", "e:\backups")

MsgBox(0, "program files (should be e:\backups):", @ProgramFilesDir)

You have gotten into the maze of twisty little passages that is "Shell Environments" and how they inherit environment variables. When you run EnvSet() you have only changed the value for any NEW shells that you spawn from that script. Reading the @ProgramFilesDir macro does not go out to the shell, but GetEnv() does. Try this:

ConsoleWrite("Debug: @ProgramFilesDir = " & @ProgramFilesDir & @LF)
ConsoleWrite("Debug: %ProgramFiles% = " & EnvGet("ProgramFiles") & @LF)
EnvSet("ProgramFiles", "G:\Bogus Value\")
ConsoleWrite("Debug: @ProgramFilesDir = " & @ProgramFilesDir & @LF)
ConsoleWrite("Debug: %ProgramFiles% = " & EnvGet("ProgramFiles") & @LF)

Run(@ComSpec & " /k SET")

:)

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

I think I am over my head :)

envset appears to work but @ProgramFilesDir must look elsewhere

Does anyone know what @ProgramFilesDir looks at or is there another autoit command I can use

I need to change several environment setting, run a program, then set them back where they were

I can do it with batch file but need to be able get environment from the computor i'm on

Edited by dancer58
Link to comment
Share on other sites

I think I am over my head ;)

envset appears to work but @ProgramFilesDir must look elsewhere

Does anyone know what @ProgramFilesDir looks at or is there another autoit command I can use

I need to change several environment setting, run a program, then set them back where they were

I can do it with batch file but need to be able get environment from the computor i'm on

The @ProgramFilesDir macro reflects what %ProgramFiles% was when AutoIt started. If you do EnvUpdate() it will get a new value, but not what you set with EnvSet(). It will get entirely new environment variable values as though AutoIt had exited and be restarted in a new shell. This new value will reflect what is stored in the System Environment Variable keys, not what you changed with EnvSet().

Like I said, twisty maze of passages... :)

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

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