Jump to content

How to compare Environment settings for when I log in vs Task scheduler logs me in.


Recommended Posts

Guest Leonid L
Posted

[This may sound like a programming question, but it is actually

simpler than that.]

 

I have a Windows Server 2003 SP1 configured to run nightly tests of

software. That involves: A) Downloading them using tf.exe, B)

compiling them using devenv.exe, C) running an executable created

during compilation.

 

I've written a small C# App that performs steps 1) 2), and 3) in

order. I also created a local non-admin user, and configured the task

scheduler to run this App as that user (I supplied a password).

 

The App started in this way fails at step 2) The exact message is:

"Error spawning 'C:\Windows\System32\cmd.exe'"

 

Without getting into details of the build process, I need to tell you

that I do not have this same problem when I start the app myself (when

logged in to the computer over remote desktop). I think the

environment variables differ depending on how I log in to computer.

 

When I am actually logged in, I can capture the values of the

environment variables by running a .bat script, containing the

following line:

set > C:\<mypath>\set_out.txt

 

However, I could not get the same script to run successfully when I

schedule it to run and I myself am not logged in. I am specifying the

full output path, it exists, and permissions look OK. It must be

getting confused about the first part - the set command. I do not

think it is able to find it.

=========================================================================

 

Any suggestions on how I can capture the environment reliably when I

am not logged in ?

  • Replies 3
  • Created
  • Last Reply
Guest Pegasus \(MVP\)
Posted

Re: How to compare Environment settings for when I log in vs Task scheduler logs me in.

 

Re: How to compare Environment settings for when I log in vs Task scheduler logs me in.

 

 

"Leonid L" <parubok@gmail.com> wrote in message

news:1192571522.994970.79670@e34g2000pro.googlegroups.com...

> [This may sound like a programming question, but it is actually

> simpler than that.]

>

> I have a Windows Server 2003 SP1 configured to run nightly tests of

> software. That involves: A) Downloading them using tf.exe, B)

> compiling them using devenv.exe, C) running an executable created

> during compilation.

>

> I've written a small C# App that performs steps 1) 2), and 3) in

> order. I also created a local non-admin user, and configured the task

> scheduler to run this App as that user (I supplied a password).

>

> The App started in this way fails at step 2) The exact message is:

> "Error spawning 'C:\Windows\System32\cmd.exe'"

>

> Without getting into details of the build process, I need to tell you

> that I do not have this same problem when I start the app myself (when

> logged in to the computer over remote desktop). I think the

> environment variables differ depending on how I log in to computer.

>

> When I am actually logged in, I can capture the values of the

> environment variables by running a .bat script, containing the

> following line:

> set > C:\<mypath>\set_out.txt

>

> However, I could not get the same script to run successfully when I

> schedule it to run and I myself am not logged in. I am specifying the

> full output path, it exists, and permissions look OK. It must be

> getting confused about the first part - the set command. I do not

> think it is able to find it.

> =========================================================================

>

> Any suggestions on how I can capture the environment reliably when I

> am not logged in ?

>

 

The "set" command works regardless of the context it is

invoked in. Your problem is most likely caused by permissions:

The account you use for the scheduled command does not

have sufficient access rights to C:\<mypath>\set_out.txt. Make

it C:\set_out.txt and watch how it works immediately!

Guest Leonid L
Posted

Re: How to compare Environment settings for when I log in vs Task scheduler logs me in.

 

Re: How to compare Environment settings for when I log in vs Task scheduler logs me in.

 

On Oct 16, 6:10 pm, "Pegasus \(MVP\)" <I....@fly.com> wrote:

> "Leonid L" <paru...@gmail.com> wrote in message

>

> news:1192571522.994970.79670@e34g2000pro.googlegroups.com...

>

>

> > [This may sound like a programming question, but it is actually

> > simpler than that.]

>

> > I have a Windows Server 2003 SP1 configured to run nightly tests of

> > software. That involves: A) Downloading them using tf.exe, B)

> > compiling them using devenv.exe, C) running an executable created

> > during compilation.

>

> > I've written a small C# App that performs steps 1) 2), and 3) in

> > order. I also created a local non-admin user, and configured the task

> > scheduler to run this App as that user (I supplied a password).

>

> > The App started in this way fails at step 2) The exact message is:

> > "Error spawning 'C:\Windows\System32\cmd.exe'"

>

> > Without getting into details of the build process, I need to tell you

> > that I do not have this same problem when I start the app myself (when

> > logged in to the computer over remote desktop). I think the

> > environment variables differ depending on how I log in to computer.

>

> > When I am actually logged in, I can capture the values of the

> > environment variables by running a .bat script, containing the

> > following line:

> > set > C:\<mypath>\set_out.txt

>

> > However, I could not get the same script to run successfully when I

> > schedule it to run and I myself am not logged in. I am specifying the

> > full output path, it exists, and permissions look OK. It must be

> > getting confused about the first part - the set command. I do not

> > think it is able to find it.

> > =========================================================================

>

> > Any suggestions on how I can capture the environment reliably when I

> > am not logged in ?

>

> The "set" command works regardless of the context it is

> invoked in. Your problem is most likely caused by permissions:

> The account you use for the scheduled command does not

> have sufficient access rights to C:\<mypath>\set_out.txt. Make

> it C:\set_out.txt and watch how it works immediately!

 

Thanks for the suggestion.

 

It did not work for me, however. I tried various directories including

C:\, but the task scheduler would say "unable to start" when I would

check for the status some time later.

The task runs under the same user name, whether I am logged in or not.

I tried both ways: executing a .bat script containing the "set >

<path>/<out_file>" and executing the "set > <path>/<out_file>" command

without creating a .bat script.

 

Any ideas?

 

Thanks.

Guest Pegasus \(MVP\)
Posted

Re: How to compare Environment settings for when I log in vs Task scheduler logs me in.

 

Re: How to compare Environment settings for when I log in vs Task scheduler logs me in.

 

 

"Leonid L" <parubok@gmail.com> wrote in message

news:1192724975.924516.36720@e34g2000pro.googlegroups.com...

> On Oct 16, 6:10 pm, "Pegasus \(MVP\)" <I....@fly.com> wrote:

>> "Leonid L" <paru...@gmail.com> wrote in message

>>

>> news:1192571522.994970.79670@e34g2000pro.googlegroups.com...

>>

>>

>> > [This may sound like a programming question, but it is actually

>> > simpler than that.]

>>

>> > I have a Windows Server 2003 SP1 configured to run nightly tests of

>> > software. That involves: A) Downloading them using tf.exe, B)

>> > compiling them using devenv.exe, C) running an executable created

>> > during compilation.

>>

>> > I've written a small C# App that performs steps 1) 2), and 3) in

>> > order. I also created a local non-admin user, and configured the task

>> > scheduler to run this App as that user (I supplied a password).

>>

>> > The App started in this way fails at step 2) The exact message is:

>> > "Error spawning 'C:\Windows\System32\cmd.exe'"

>>

>> > Without getting into details of the build process, I need to tell you

>> > that I do not have this same problem when I start the app myself (when

>> > logged in to the computer over remote desktop). I think the

>> > environment variables differ depending on how I log in to computer.

>>

>> > When I am actually logged in, I can capture the values of the

>> > environment variables by running a .bat script, containing the

>> > following line:

>> > set > C:\<mypath>\set_out.txt

>>

>> > However, I could not get the same script to run successfully when I

>> > schedule it to run and I myself am not logged in. I am specifying the

>> > full output path, it exists, and permissions look OK. It must be

>> > getting confused about the first part - the set command. I do not

>> > think it is able to find it.

>> > =========================================================================

>>

>> > Any suggestions on how I can capture the environment reliably when I

>> > am not logged in ?

>>

>> The "set" command works regardless of the context it is

>> invoked in. Your problem is most likely caused by permissions:

>> The account you use for the scheduled command does not

>> have sufficient access rights to C:\<mypath>\set_out.txt. Make

>> it C:\set_out.txt and watch how it works immediately!

>

> Thanks for the suggestion.

>

> It did not work for me, however. I tried various directories including

> C:\, but the task scheduler would say "unable to start" when I would

> check for the status some time later.

> The task runs under the same user name, whether I am logged in or not.

> I tried both ways: executing a .bat script containing the "set >

> <path>/<out_file>" and executing the "set > <path>/<out_file>" command

> without creating a .bat script.

>

> Any ideas?

>

> Thanks.

>

 

Aha! Your problem is therefore not the "set" command but the

scheduled task. That's something completely different! Have a

look at the Event Logger and remember that scheduled tasks

must be run with an account that has a non-blank password.

And please don't do all your tests with one and the same account.

Be flexible and create another account for your tests!


×
×
  • Create New...