|
For one, a service must be able to interact with the Desktop. There is an option for this in the SCM (service control manager). Also, the server must run as a user or other problems are likely to happen.
Why in the world are you trying to start notepad from a service, though? It's important to do things in the way they were intended. Services are programs that run without a user being logged in, or for global access by programs on your machine or other machines (like the Event Log service, for example).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
starting notepad.exe was only an example.
the "interact with desktop" flag was the right answer.
i want to access a network-shares (as local system-service) to load notepad.exe from e.g. \\server1\share1\notepad.exe.
the guest-access is activated for that server and "Everybody" has the right to read that share, but my service cannot access this share. why?
|
|
|
|
|
thilol wrote:
i want to access a network-shares (as local system-service) to load notepad.exe from e.g. \\server1\share1\notepad.exe.
the guest-access is activated for that server and "Everybody" has the right to read that share, but my service cannot access this share. why?
When you say "everybody", it is actually everybody recognized by "server1", i.e. everybody with an account in the domain. You need to change your service to run under a regular domain account instead of "Local System". This can be done via the "Administrative Tools - Services" menu, just double click your service and select the "Log On" tab (you can use the browse button to find a domain user).
Good luck.
P.S. You won't be able to see the GUI of your program started by the service if your service no longer uses the "Local System" logon.
My articles and software tools
|
|
|
|
|
Because the local SYSTEM account is just that - local. When connecting to other services, the SYSTEM account is not the same - not the SID and not the same password (one or the other depends on the authentication used). To access a share on another system, you have to run the service as a domain account - not a local account. Either use or create a domain account (or two local account named the same thing with the same password - works in most cases) and run the service as that user. Make sure that user account has the permissions to run as a service. You can set this in the domain or local security policy for the computer on which the service is being run.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
my service have to run as LocalSystem!
can my service start a secondary process (which run's not as LocalSystem) to access a network share?
regards thilo.
|
|
|
|
|
1. Why does your server have to run as LocalSystem? This is changable both programmatically and via the SCM UI.
2. You can use impersonation and start another process on the local machine that starts a process on another machine.
3. One more option is to use remoting and have two services running on each machine that communicate through remoting. Then the remote system would be responsible for starting a local application - which would be the remote application to the sending service.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
my service should start a program which MUST run in LocalSystem-Account and not in a user-account.
i fixed that problem! i activated the network-share on my server for NullSession-access; and so my LocalSystem-account can access that share.
thanks.
regards, thilo.
|
|
|
|
|
Great, but you just opened your system up for anonymous attacks. Make sure you have security tight if you're going to do this. Still, the easiest way is to make sure that the SYSTEM account on both machines has the same password. This works in most cases.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I am an extreme newbie (or n00b for the elite) and I REALLY want to learn how to program in C#. I have Herb Schildt's book call 'C#: A Beginner's Guide' and it's very good. However, I like to have a ton of websites to turn to when I have questions. So, could everyone please reply with their best C# referrence websites? It would be much appreciated!
|
|
|
|
|
Well, for starters, CodeProject!
Other good ones:
Some of these links are for .NET in general. Remember that C# is just a language that targets the CLR (see below).
And never forget the important of research skills. Taking a glance at the .NET BCL (base class library) is very important: http://msdn.microsoft.com/library/en-us/cpref/html/cpref_start.asp[^]
All language that target the Common Language Runtime (CLR) have equal access to the BCL. They just use different syntaxes (and shortcuts based on various keywords).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I've noticed a lot of people around here call it the ".NET BCL" instead of the ".NET Framework". I'm curious why that is. Did I miss a memo?
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
The term "BCL" means Base Class Library, and refers to the base classes in the .NET Framework. ".NET Framework" refers to both these classes and the runtime and VM.
|
|
|
|
|
That makes sense, and I can see the need to differentiate. I've just never seen MS refer to it as that and was wondering if it's sort of a defacto term.
I, for one, do not think the problem was that the band was down. I think that the problem may have been that there was a Stonehenge monument on the stage that was in danger of being crushed by a dwarf.
-David St. Hubbins
|
|
|
|
|
Blame Microsoft's marketing department - everyone else does! Fonrtunately, the ".NET" was removed from their server product names and some of their services because everyone was confused!
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
My picks are
thecodeproject.com
codeproject.com [the eeeeevil twin]
c-sharpcorner.com
csharphelp.com
msdn.microsoft.com/vcsharp
dotnet247.com
dotnetjunkies.com
Those'll keep ya busy.
The graveyards are filled with indispensible men.
|
|
|
|
|
hi...
based on the inherritance issue i have one more problem. if you see the code below
class base1<br />
{<br />
public virtual void f( )<br />
{<br />
Console.WriteLine ( "In base1" ) ;<br />
}<br />
}<br />
class d1 : base1<br />
{<br />
public void f( )<br />
{<br />
Console.WriteLine ( "In d1" ) ;<br />
}<br />
}<br />
<br />
class Class1<br />
{<br />
static void Main ( string[ ] args )<br />
{<br />
base1 b = new d1( ) ;<br />
b.f( ) ;<br />
}<br />
}<br />
which yeailds In base1
it says base1 b = new d1()
1)why did it mix 2 classes??can we do that?why would we wanan do that??
when called b.f() - f of base1 is called!
2)why is that so?
tks a lot for any help..appreciate it..
Have a Super Blessed Day!
-------------------------
For God has not given us a spirit of fear, but of power and of love and of a sound mind.
2 Timothy 1:7
"For God so loved the world that He gave His only begotten Son, that whoever believes in Him should not perish but have everlasting life."
John 3:16
"Therefore you also be ready, for the Son of Man is coming at an hour you do not expet."
Luke 12:40
|
|
|
|
|
You forgot the keyword "override"
class d1 : base1
{
public override void f( )
{
Console.WriteLine ( "In d1" ) ;
}
}
|
|
|
|
|
tks for the help....but that didn't answer my question!
Have a Super Blessed Day!
-------------------------
For God has not given us a spirit of fear, but of power and of love and of a sound mind.
2 Timothy 1:7
"For God so loved the world that He gave His only begotten Son, that whoever believes in Him should not perish but have everlasting life."
John 3:16
"Therefore you also be ready, for the Son of Man is coming at an hour you do not expet."
Luke 12:40
|
|
|
|
|
Sorry, didn't read your question well enough.
To understand these concepts you need a book on classes and OOP. It takes too long to explain it well here.
Basically "base1 b = new d1()" says "Create a d1 type of object but treat it as a base1 type of object". This is only possible because d1 inherits base1.
|
|
|
|
|
It's a very simple concept of object oriented programming.
Why can you call .ToString on a Windows Form? Because it's a System.Object AND a System.Windows.Forms.Form. It inherits from System.Object - and when a class inherits from another class, it instanciates the base class; you're essentially creating 2 objects as 1.
The graveyards are filled with indispensible men.
|
|
|
|
|
hi..i am stuck with this problem..its very very confusing and even after reading book i cannot figure it out...can u pls help me?tks a lot
please consider the code :
class base1<br />
{<br />
public void call ( base1 b )<br />
{<br />
b.f( ) ;<br />
}<br />
<br />
public virtual void f( )<br />
{<br />
Console.WriteLine ( "In base1" ) ;<br />
}<br />
}<br />
<br />
class d1 : base1<br />
{<br />
public override void f( )<br />
{<br />
Console.WriteLine ( "In d1" ) ;<br />
}<br />
}<br />
class d2 : base1<br />
{<br />
public override void f( )<br />
{<br />
Console.WriteLine ( "In d2" ) ;<br />
}<br />
}<br />
class Class1<br />
{<br />
static void Main ( string[ ] args )<br />
{<br />
base1 b = new base1( ) ;<br />
d1 o1 = new d1( ) ;<br />
d2 o2 = new d2( ) ;<br />
<br />
b.call ( b ) ;<br />
b.call ( o1 ) ;<br />
b.call ( o2 ) ;<br />
}<br />
}
which yeilds :
In base1
In d1
In d2
prob : i dont understand how this result is generated... confused:
allthe calls i see are thru b..but d gets called???
could u pls explain why this is happing??
tks a lot for any help..
really appreciate it..
tks a lot
Have a Super Blessed Day!
-------------------------
For God has not given us a spirit of fear, but of power and of love and of a sound mind.
2 Timothy 1:7
"For God so loved the world that He gave His only begotten Son, that whoever believes in Him should not perish but have everlasting life."
John 3:16
"Therefore you also be ready, for the Son of Man is coming at an hour you do not expet."
Luke 12:40
|
|
|
|
|
Its the f() that does the printing, and the b.f() in base1 that calls the different implementations of the virtual f method, one for each type. If you have a good book on classes and polymorphism, this will be explained.
|
|
|
|
|
hi..i have another prob. would be glad if you could help..please consider the following code :
class sample<br />
{<br />
public void foo( )<br />
{<br />
Console.Write ( "In sample.foo" ) ;<br />
}<br />
}<br />
<br />
class sampleD : sample<br />
{<br />
protected void foo( )<br />
{<br />
Console.Write ( "In sampleD.foo" ) ;<br />
}<br />
}<br />
<br />
class Class1<br />
{<br />
static void Main ( string[ ] args )<br />
{<br />
sampleD s = new sampleD( ) ;<br />
s.foo( ) ;<br />
}<br />
} which yeilds : In sample.foo
my prob is : how can this happen?? the instance belongs to sampleD and the foo is called of sample...
can u pls help me and tell me why this happens...
tks a lot..
Have a Super Blessed Day!
-------------------------
For God has not given us a spirit of fear, but of power and of love and of a sound mind.
2 Timothy 1:7
"For God so loved the world that He gave His only begotten Son, that whoever believes in Him should not perish but have everlasting life."
John 3:16
"Therefore you also be ready, for the Son of Man is coming at an hour you do not expet."
Luke 12:40
|
|
|
|
|
Open Visual Studio, open the Help menu, select "Index".
Look up "protected keyword" and you will get the full explanation.
|
|
|
|
|
good answer...
but if you read my question its a bit different...isn't it?
Have a Super Blessed Day!
-------------------------
For God has not given us a spirit of fear, but of power and of love and of a sound mind.
2 Timothy 1:7
"For God so loved the world that He gave His only begotten Son, that whoever believes in Him should not perish but have everlasting life."
John 3:16
"Therefore you also be ready, for the Son of Man is coming at an hour you do not expet."
Luke 12:40
|
|
|
|