admin priveles for batch file

Frankie566 February 14, 2009 at 10:46:51
Specs: Windows XP
Is there a way to put in code within the batch file itself to run this command as admin rather that whatever user opens it?
I have a btach file to remote shutdown a pc on the LAN it only works if I'm logged on with LAN Admin privliges. I want other staff member to be able to run it too without having to do the Run As

See More: admin priveles for batch file

Report •

February 15, 2009 at 00:59:21
Batch file? No.

I think WMI can shutdown a PC, and it can provide a different set of credentials.

Report •

February 15, 2009 at 05:59:40
Good news: it can. So here's a VBScript:
With CreateObject("WbemScripting.SWbemLocator").ConnectServer _
                 ("computer", "root\cimv2", "domain\user", "password")
  '12 = Force shutdown. Get the entire 
  'list @
  For Each com In .InstancesOf("Win32_OperatingSystem")
    If com.Win32Shutdown(12, 0) = 0 Then
      WScript.Echo "Shutdown command sent"
      WScript.Echo "Shutdown failed"
    End If
  Next 'com
End With

Report •

Related Solutions

Ask Question