Scripts run with elevated priviledges so that should not be a problem. Just verify in your GPO that you have selected to always run with elevated priviledges. Here is the code you need.
set WSHShell = wscript.createObject("wscript.shell"
Call WSHShell.Run("cmd.exe /C Net Stop " & Chr(34) & "Print Spooler" & Chr(34))
If the service name is only one word, there is no need for the &Chr(34) which simply tells the script to add quotes around the service name. For example the Messenger service would just need:
Call WSHShell.Run("cmd.exe /C Net Stop Messenger"
Hmmm. Are you referring to scripts that run somehow specially? Because if you just do start, run, wscript script.vbs it runs as you I thought. At least, that's what username is displayed when you view taskmgr to see who owns which processes.
No, I am referring to scripts run from the network via GPO.
If you need to execute them locally, then you could always script using the runas command and encrypt the script so the passwords can't be seen. You should be aware however that the encrypted scripts can be unencrypted fairly easily by anyone who really wants to see it.
In fact, there are some GPO on the PC's user that remove the right to the user to change or modify the services.
So I need to launch a program under the user login, to start a service.
But when I execute your command (that I have already try), I have a message which says me that I don't have the good rights.
I could use the command "runas" but I don't want that the user enter the administrator's password.
Can you show me how to crypt this password and enter this password when the "runas" ask it me ?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.