Running DOS command Using Relevance Results

(imported topic written by Edj)

I am currently attempting to use the “DOS md” command using the results from a relevance.

The following relevance will return a directory path and I would like to use the “DOS md” command to create the directory using the resulting value:

(if (exists key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall{B36AEE2C-FD01-4A4A-A822-A36C78E58B3D}” whose (exists value “InstallSource” of it ) of registry) then (value “InstallSource” of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall{B36AEE2C-FD01-4A4A-A822-A36C78E58B3D}” of registry as string) else “C:\SourceDir”)

Can anyone assist in accomplishing this task?

Thanks,

Edj

(imported comment written by BenKus)

Hey Ed,

Make an action that looks like this:

dos md “{(if (exists key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall{B36AEE2C-FD01-4A4A-A822-A36C78E58B3D}” whose (exists value “InstallSource” of it ) of registry) then (value “InstallSource” of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall{B36AEE2C-FD01-4A4A-A822-A36C78E58B3D}” of registry as string) else “C:\SourceDir”)}”

Let me know if that works for you.

Ben

(imported comment written by Edj)

Ben,

That statement looks exactly like the statment that I attempted to use. I will give it a try and let you know.

Thanks,

Edj

(imported comment written by Edj)

Ben,

The Relevance substitution failed.

Thanks,

Edj

(imported comment written by BenKus)

Hey Ed,

Oops! My mistake…

The curly braces are causing the issue in the relevance… You need to escape them by adding two open curly braces:

dos md “{(if (exists key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall{{B36AEE2C-FD01-4A4A-A822-A36C78E58B3D}” whose (exists value “InstallSource” of it ) of registry) then (value “InstallSource” of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall{{B36AEE2C-FD01-4A4A-A822-A36C78E58B3D}” of registry as string) else “C:\SourceDir”)}”

Note the double open curly braces in the two places (you don’t need to change the closing curly braces).

Ben

(imported comment written by Edj)

Got it!!! Thanks Ben.

Edj

(imported comment written by Edj)

Ben,

I am getting the same results using the double open curly braces in the two spaces. Any Ideas?

Thanks

Edj

(imported comment written by BenKus)

Sorry… I screwed it up again…

But I got it this time…

  • When you have an action that uses curly braces but is not using relevance substitution, you escape the open curly braces “{”.

Example:

regset “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall{{B36AEE2C-FD01-4A4A-A822-A36C78E58B3A}” “Test”=“Booyah”

Note that there is no relevance substitution occuring here which is why you escape the open braces.

  • When you have an action that uses curly braces and is using relevance substitution, you escape the close curly brackets “}”.

Back to your example:

dos md “{(if (exists key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall{B36AEE2C-FD01-4A4A-A822-A36C78E58B3D}}” whose (exists value “InstallSource” of it ) of registry) then (value “InstallSource” of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall{B36AEE2C-FD01-4A4A-A822-A36C78E58B3D}}” of registry as string) else “C:\SourceDir”)}”

Note that there is relevance substitution and the braces exists in the relevance block so I need to make sure to escape the closing curly brace.

I tested this and it seems to work… Sorry I didn’t get it right the first time.

Ben

(imported comment written by Edj)

Ben,

Thanks…I will give it a try.

Edj

(imported comment written by Edj)

Ben,

That did it … It worked perfectly!

Thanks,

Edj