How do I open an interactive application, such as cmd.exe or Windows Explorer, running as NETWORK SERVICE? There are ways to do it for the SYSTEM account, but NETWORK SERVICE is proving to be a challenge. I need this to work on Windows 7, but would be interested in solutions for other Windows versions as well.
Have you tried PsExec, a couple of interesting links with more information:
http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx
https://social.technet.microsoft.com/Forums/en-US/381df759-af7f-4523-a2fd-b17e8c68db9e/how-to-start-cmdexe-as-network-service?forum=pstools
Here is how you would use PsExec to run cmd.exe under "NETWORK SERVICE" user context:
psexec -i -u "nt authority\network service" cmd.exe
Related
Is it possible to send Powershell commands to a computer that can only be reached by RDP? If yes, how?
the help about_remoting topic covers various remote command options
https://msdn.microsoft.com/en-us/powershell/reference/5.1/microsoft.powershell.core/about/about_remote
also to configure winRM for powershell you can open a local Powershell session and run the Following command Enable-PSremoting
https://msdn.microsoft.com/en-us/powershell/reference/5.1/microsoft.powershell.core/enable-psremoting
server 2012 and newer already have it enabled.
We have a server that is on the same LAN as my work computer. I know you can use "net stop" and "net start" in a batch file to restart a service on the local machine, but is it possible to do that for a remote machine?
I know you can use \computer to browse a networked machine, for example, so is there some syntax that would be something like \computer net stop service or so on?
Right now I have to Remote Desktop into the machine, restart the service, then log off, which is a hassle.
Create a Desktop shortcut
in the cmd to run enter :
sc \\server stop service
sc is the service management tool
server is your remote server name or IP
and finally service is the name of the service you target
I figured it out - for anyone else wondering: you can use this command:
C:\Windows\System32\runas.exe /savecred /user:[domain\user] "C:\windows\system32\cmd.exe /c C:\Test.bat" Where your batch file with the sc \server stop service is in C:\Test.bat. (You can move that around obviously)
I have a file system monitoring PowerShell script using System.IO.FileSystemWatcher events.
The script works great, but it requires an open PowerShell window.
Thus, I need to run it as a Windows Service at Windows startup (without logon). Is there a way to do this?
To execute your script at windows startup (without logon) you could create a windows service for it (using srvany.exe).
Steps:
Get the windows 2003 resource kit (which contains srvany.exe)
Install the resource kit
Create the service using sc and srvany.exe
sc create PSService binPath= "C:\Program Files\Windows Resource Kits\Tools\srvany.exe" DisplayName= "PSService"
Parametrize your service
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\PSService]
"Type"=dword:00000010
"Start"=dword:00000003
"ErrorControl"=dword:00000001
"DisplayName"="PSService"
"ObjectName"="LocalSystem"
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\PSService\Parameters]
"Application"="C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -noExit -ExecutionPolicy RemoteSigned -File C:\\PSService\\psservice.ps1"
Some remarks:
Srvany.exe is not available for Windows Vista and up. It might work, but it's probably not supported
You might want to run it with other credentials (for security reasons)
You might want to save your script in a directory where only administrators have write access (for security reasons)
Ive got a java app which needs to execute a driver installer exe file. On Linux we type "gksudo myCommand". Is there a way to elevate permissions from Windows command line?
You may run every application in windows with a different user e.g. Administrator. But the user who executes this command needs to have the credentials to do so.
Edit.:
In advance you can lookup the User Account Control (UAC) which is available in Windows 7 and Vista if it is possibly an alternative for you.
I decided to deploy an executable binary onto the system which calls the jar. This way the user can right click and run as administrator... That didn't work... SO I kept looking... Check this out..
Elevate.exe.. It's basically like Windows GKSudo!!!!
http://www.robotronic.de/elevate.html
So... I packaged the 32bit exe into my program and deploy it, then run it as necessary.
You can use runas command like runas /user:Administrator myCommand (it requires the users to type password).
You can also use Start-Process cmdlet like Start-Process -Verb runas myCommand in PowerShell (it requires the users to click the UAC dialog).
see: http://satob.hatenablog.com/entry/2017/06/17/013217
Step 1). log into local windows xp (sp3) machine as system account
Step 2). execute psexec test as follows on remote xp (sp3) machine
psexec \\nnn.nnn.nnn.nnn ipconfig /all
RESULT:
Couldn't access nnn.nnn.nnn.nnn
Access is denied.
Question: Why?
I am logged on as windows System user, the system user is all powerfull
i should be able to do anything, with no access restrictions at all
This doesnt work either
psexec \\nnn.nnn.nnn.nnn -s ipconfig /all
why doesnt being logged onto a local xp machine as SYSTEM give me the power to run
anything on a remote machine?
The SYSTEM account is all powerfull when it comes to the local system, but not on remote systems. Use -u to specify a username...