Environment: -
OS: Windows 7 32/64 bit, Windows 2008 Server 64 bit/ Windows 2012 Server 64 bit
.
Priority: - Critical
.
Requirement: - Since the Windows Service is running under the Local System Account, we would like to emulate this same behaviour.
Basically, we would like to run CMD.EXE under the Local System Account. So that we can map a network drive to be used by a service using following command
net use z: \\servername\sharedfolder /persistent:yes.
Already Attempt: -
.
- We tried to launch the CMD.exe using the DOS Task Scheduler AT command. Heres a sample command:
AT 10:36 /interactive cmd.exe
But I received a warning that due to security enhancements, this task will run at the time excepted but not interactively.
It turns out that this approach will work for XP, 2000 and Server 2003 but due to session isolation Interactive services no longer work on Windows 7, Windows Server 2008 and above.
.
2. We tried to create a secondary Windows Service via the Service Control (sc.exe) which merely launches CMD.exe.
<Drive>:\sc create RunCMDAsLSA binpath= "cmd" type=own type=interact <Drive>:\sc start RunCMDAsLSA
In this case the service fails to start and results it the following error message:
FAILED 1053: The service did not respond to the start or control request in a timely fashion.
.
3. One suggestion, we found to launch CMD.exe via a Scheduled Task, but it is not giving any option to launch CMD.exe in interactive mode; so that I can map network drive using net command.
.
4. I read an article, which demonstrates the use of PSTools from SysInternals. I launched the command line and executed following command
psexec -i -s cmd.exe
PSTools worked fine, but It seems that in scope of Sysinternals Software License Terms. You may not "use the software for commercial software hosting services."
Application will deploy on client, which will be like commercial, so we are not able to use PSTools.
Kindly assist us for achieving the requirement. We have tried all the ways, but nothing is working for us. Kindly suggest.
I will be really thankful.