Jump to content
Macro Express Forums

Including Explicit System Environment Variables


Recommended Posts

I am writing a macro that will output technical instructions to an email to be sent to a customer. One of my steps has the user change to the Windows directory at a command prompt. Because I don't know in advance what the Windows directory will be, I want my step to appear as follows.

 

3. Enter the following to change into the Windows directory.

 

cd %windir%

 

No matter how I try to avoid it, Macro Express is always evaluating this and outputting "cd c:\Windows" instead of just outputting the literal text. I have tried checking the "Don't process embedded variables" checkbox, but it has no effect. I tried changing my literal value to "%%windir%%", but that just causes ME to output "%c:\Windows%" which is still not what I want.

 

Does anyone have any ideas?

 

Thanks!

 

Jim

Link to comment
Share on other sites

Is this in the eMail send command message body?

 

Hi, Cory. No, it's not. I am setting a string variable that includes the literal value "%windir%" and then I am using the Text Type command to output the variable to an open email message.

 

Thanks.

 

Jim

Link to comment
Share on other sites

That was a challenge but I found a solution. Problem is we have an option not ot process embedded variables in other places like Set Variable but not here. And even if you make the message body a variable first it’s still evaluated. So what I did was to temporarily change my environmental variable’s name to "Windirr" (two Rs), send the email, then set it back.

 

I’m guessing there’s a way you could automate that with a VBScript or command line.

Link to comment
Share on other sites

That was a challenge but I found a solution. Problem is we have an option not ot process embedded variables in other places like Set Variable but not here. And even if you make the message body a variable first it’s still evaluated. So what I did was to temporarily change my environmental variable’s name to "Windirr" (two Rs), send the email, then set it back.

 

I’m guessing there’s a way you could automate that with a VBScript or command line.

 

Very clever, Cory. Thank you. I can take care of it using that technique.

 

Jim

Link to comment
Share on other sites

Well, easier said that done. As it turns out, the Macro Express process has its own environment block, so even if I modify the environment variable via script, the environment block that ME has still contains the original variable. The only around that (that I know of) is to restart the ME process after modifying the variable with my script.

 

I'm still working on a solution to this, but it may not be possible.

 

Jim

Link to comment
Share on other sites

I just tested it and it works fine. Sent myself an email and got c:\windows. Changed the environmental var and ran again and this time it came out %Windir%.

 

If you are using the SET command in a command prompt don't forget that changes there only persist for that session and might even be limited to that session.

 

Try this just as an experiment. Control Panel > System > Advanced System Settings > Then in the Advanced tab of the System Properties click the Environmental Variables... > and go down into the System Variables section and edit and rename Windir. I bet your macro will work that way.

Link to comment
Share on other sites

I just tested it and it works fine. Sent myself an email and got c:\windows. Changed the environmental var and ran again and this time it came out %Windir%.

 

If you are using the SET command in a command prompt don't forget that changes there only persist for that session and might even be limited to that session.

 

Try this just as an experiment. Control Panel > System > Advanced System Settings > Then in the Advanced tab of the System Properties click the Environmental Variables... > and go down into the System Variables section and edit and rename Windir. I bet your macro will work that way.

 

Hi, Cory. Yeah, I tested that exact scenario. In my macro, I have this in a Text Type command.

 

"Enter %windir%\System32"

 

When that runs, it outputs "Enter C:\Windows\System32" to the focused window. Even if I rename my windir system environment variable, I get the same thing. I'm not sure if this might not be a subtle OS difference. I'm testing this on Windows Server 2008 R2 x64.

 

I attached a debugger to the macexp.exe process and dumped the process environment block. In that, I can see that there's still a windir variable set to C:\Windows. I suspect that's why it's still not working. If I close Macro Express and relaunch it, the new PEB contains the renamed variable.

 

So much trouble that really may not even be worth it, but I do appreciate your help.

 

Jim

Link to comment
Share on other sites

The macros I'm working on are for a Macro Express Pro pilot for a very large computer software company. The reliability of the macros is extremely important, and instead of convoluting the macro to get this done and risking failure in some environments, I've decided to simply add wording that says, "The location of your Windows directory may differ from these instructions." That ought to cover it. :)

 

Thanks for the help, Corey.

 

Jim

Link to comment
Share on other sites

I don't think that will work Paul because he's using the message box in the Email Send command.

 

You might use a substitute character like ampersand and instruct them to replace the ampersand with a percent sign.

Link to comment
Share on other sites

I don't think that will work Paul because he's using the message box in the Email Send command.

 

You might use a substitute character like ampersand and instruct them to replace the ampersand with a percent sign.

I must have missed something! He said earlier he was using the text type command

... and then I am using the Text Type command to output the variable to an open email message.

and since my code is also using the Text Type command, it looked straight-forward to me.

Link to comment
Share on other sites

I must have missed something! He said earlier he was using the text type command

 

and since my code is also using the Text Type command, it looked straight-forward to me.

 

Paul,

 

You are correct. I am using Text Type, and the steps that you gave me solved the problem. Thank you! It took a bit of retooling since my steps were defined in a variable and the "%windir%" instance was about half way through them, but it's all working fine now.

 

Thanks to both of you for the assistance.

 

Jim

Link to comment
Share on other sites

I must have missed something! He said earlier he was using the text type command

He never said he was using text type command in the first message but rather that he was sending an email. I mistakenly assumed that meant he was using the Email Send command. He used the word "Output" which could be taken either way. Later he mentioned using text type and I must have missed that.
Link to comment
Share on other sites

  • 1 month later...

As Patrick said, it's easily done by a simple substitution and a command I rarely use. This solution goes back a few years to Joe.

 

Variable Set to ASCII Char 37 to %Percent%

Text Box Display: Message

 

<VARIABLE SET TO ASCII CHAR Value="37" Destination="%Percent%"/>
<TEXT BOX DISPLAY Title="Message" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang2057{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\qc\\b\\f0\\fs24 Enter the following to change into the Windows directory\r\n\\par \r\n\\par cd \\f1 %Percent%\\f0 windir\\f1 %Percent%\\b0\\fs16 \r\n\\par }\r\n" Left="696" Top="238" Width="548" Height="200" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>

 

TBD details:

MEProPercent-2.jpg

 

 

Result:

MEProPercent-1.jpg

 

--

Terry, East Grinstead, UK

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...