Solved

Setting an environment variable in NT using Kix32

Posted on 1998-03-12
5
693 Views
Last Modified: 2013-12-19
I am using the Kix32 scripting language (comes with the NT Resource Kit) to set an environment variable in NT to today's date.  The script will be run automatically by the Scheduler Service at 12:01am every day to allow the variable %today% to be used in various ways by other command scripts, batch files, etc. throughout the day.

There are three different commands to do this in Kix32.  The variables are set in Current Environment (SET), Local User (SETL) and Local Machine (SETM).

I cannot get the variable to be seen in a Command Prompt started by the scheduler service.  Even when I schedule an interactive command prompt (using CMD.EXE /K) and then manually run the script in that window, the variable will not show up in the current window.  It will also not show up in any subsequently started "CMD.EXE /K" windows started by the Scheduler service.  It will show up in the System Properties/Environment window under System Variables and User Variables and it will show up in any new Command Prompt windows started from the Start Menu.

My questions are these:

1.  Is there a way to have the local system account (the one required to be used by the Scheduler Service for interactive jobs) read the current system variables if you have changed them since bootup?  If not, is there a registry area that can be modified to make this happen?

2.  Does anyone have another suggestion as to a method of setting environment variables in NT Scheduler command prompt windows?

3.  Is there a way to auto-update other already open windows with the new environment variables when you set them?

4.  Does anyone know of additional references for Kix32 on the Internet or elsewhere?
0
Comment
Question by:jzanette
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 

Expert Comment

by:mbeitz
ID: 1571321
Logon with the service account of the scheduler service and configure your environment variables. Then they should be there, if you restart the scheduler service.

Environments are user specific.
0
 

Author Comment

by:jzanette
ID: 1571322
Mbeitz is not correct.  Setting environment variables while logged in to the user account of the scheduler service works only if you actually LOG IN as that user and open a command prompt.  Then you will see the variables you have set.

When the scheduler service logs in and runs a command prompt (i.e., "at 10:00 /interactive cmd /k", variables that you have set for that user DO NOT appear in the command prompt window.  Also, even though global system variables do appear, any changes that have been made since the last reboot do not.  The only way that I have found to get global system variable changes to appear in the scheduler service command prompt window is to reboot.  Restarting the scheduler service does not work either.

That's why I am thinking there is a registry area or somewhere in system memory that the environment for the scheduler service is being stored.  It appears to only get updated at bootup.

Once more, my specific problem is:

I need to set an environment variable called "today" to mmddyy for use in some very extensive command scripts that run every day but need to find, place and rename files based on date.

C'mon experts, help me.  It's worth 250 points now.
0
 
LVL 5

Expert Comment

by:heiko
ID: 1571323
why you dont calculating entire environment each time starting your script? with perl (from NTRESKIT) and its subset of time functions you can set necessary environment.

please ask for more detailed informations.
0
 

Accepted Solution

by:
pbryden earned 250 total points
ID: 1571324
Place the following lines at the beginning of any script where you would like to set and use the today variable.

date/t >date.txt
For /f "tokens=2" %%i in (date.txt) do (set TODAY=%%i)

This variable will exist during the execution of the script only.

General comment:

I prefer to have the schedule service login as a user account instead of the system account (the above procedure will work either).  The system account can't map network drives, etc where a login is required.

Good Luck
0
 

Author Comment

by:jzanette
ID: 1571325
Thanks.
0

Featured Post

Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Sometimes you might need to configure routing based not only on destination IP address, but also on a combination of destination IP address (or hostname) and destination port number. I will describe a method how to accomplish this with free tools. …
Downtime reduced, data recovered by utilizing an Experts Exchange Business Account Challenge The United States Marine Corps employs more than 200,000 active-duty Marines with operations in four continents, all requiring complex networking system…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question