Need script to query OU and remote shutdown the PC contained in that OU.

Hi,

I'm looking for a script that query an OU for a list of computers and remotely shutdown those machine if no one are loged on them.

OU = Domain.bogue.ca/Ordinateurs/Odinateur sans synchronisation/Écoles/Salle de Classe/ESDLV

that script would be ran on the domain controller every night.

Greatly appreciated.

Thanks
L_LevesqueAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jagadeesh_motamarriCommented:
I believe you are bascially asking for code for Remote Shutdown....

Here is some code for you in C#

http://www.codeproject.com/csharp/remoteshutdownsubmission.asp


and code using VB Script

Shutting Down a Remote Computer Using VB Script


And may be the link below helps to find out the list of local users...

http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=64803&lngWId=1



You might want to combine these to get your work done...
0
L_LevesqueAuthor Commented:
I was hoping for a vbscript or a wscript that can be run on the domain controller and that I wouldn't have to install additional software or application on the windows xp clients.

I have tried with a shutdown.exe command through vbs that shutdown all computers in the subnet. This doesn't work well for the simple reason that it forces users to shutdown. Aslo there are some computers that have to stay on for the night. I was hoping to query the AD and shutdown the selected computers and give the user the option not to shutdown.

Thanks.
0
jagadeesh_motamarriCommented:
Try this...


'/'|| RemoteShutdown.vbs
'||
'|| Created by Harvey Hendricks, MCP, MCSE, A+
'|| March 2001
'|| email: Harvey.Hendricks@aramcoservices.com
'||
'||
'|| Based on techniques and ideas from:
'|| SMS admin, SMS Installer, & WMI forums ->
'|| http://www.myITforum.com/forums
'|| Win32 Scripting -> http://cwashington.netreach.net/
'|| Microsoft Windows Script Technologies ->
'|| http://msdn.microsoft.com/scripting
'|| Microsoft Online Library ->
'|| http://msdn.microsoft.com/library/default.asp
'|| Microsoft VBScript 5.5 documentation and Microsoft WMI SDK
'||
'||~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'|| SCRIPT LOGIC FLOW:
'|| Collects computername from user, calls function to ping the computername
'|| to determine if it is accessible, if not then display message and exit
'|| otherwise continue.
'|| Collects desired action to perform from the user, does error checking on
'|| the input to determine if it is acceptable, if not then display message
'|| and exit otherwise continue.
'|| Set variables and output messages based on the action chosen. Calls
'|| Win32Shutdown with the appropriate variable. Displays success message
'|| and exits
'||
'|| Uses WMI Win32Shutdown method from the Win32_OperatingSystem class
'|| to perform different logoff / powerdown / reboot functions
'||
'|| Testing found the following values to be effective on Win32Shutdown:
'|| Action decimal binary
'|| Logoff 0 0000
'|| Force Logoff 4 0100
'|| Reboot 2 0010
'|| Force Reboot 6 0110
'|| Powerdown 8 1000
'|| Force Powerdown 12 1100
'||
'|| Notice that the third bit from the right appears to be the "FORCE" bit.
'||
'|| A value of 1 will do a shutdown, ending at the "It is safe to turn
'|| off your computer" screen. I have no use for this and did not test it.
'||
'||
'||NOTES: - tested under Windows 2000 Pro. with ACPI compliant systems -
'|| SHOULD work under Windows NT4 without modification IF the
'|| system has compatible versions of WSH / WMI / VBscripting
'||
'||Logoff / Powerdown / Reboot:
'|| Does not work if a password protected screen saver is active or
'|| there is data to save. Either way the system waits for user input.
'||
'||Force Logoff / Force Powerdown / Force Reboot:
'|| Does not work if a password protected screen saver is active, will wait
'|| for user input. Otherwise will close open applications without saving
'|| data.
'||
'\/~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

'/\/\/\/\/\/\/\/\/\/\/\/\/\/\ start function
function Ping(byval strName)
dim objFSO, objShell, objTempFile, objTS
dim sCommand, sReadLine
dim bReturn

set objShell = WScript.CreateObject("Wscript.Shell")
set objFSO = CreateObject("Scripting.FileSystemObject")

'Set default return value
bReturn = false

'Create command line to ping and save results to a temp file
sCommand = "cmd /c ping.exe -n 3 -w 1000 " & strName & " > C:\temp.txt"

'Execute the command
objShell.run sCommand, 0, true

'Get the temp file
set objTempFile = objFSO.GetFile("C:\temp.txt")
set objTS = objTempFile.OpenAsTextStream(1)

'Loop through the temp file to see if "reply from" is found,
'if it is then the ping was successful
do while objTs.AtEndOfStream <> true
sReadLine = objTs.ReadLine
if instr(lcase(sReadLine), "reply from") > 0 then
bReturn = true
exit do
end if
loop

'Close temp file and release objects
objTS.close
objTempFile.delete
set objTS = nothing
set objTempFile = nothing
set objShell = nothing
set objFSO = nothing

'Return value
Ping = bReturn
end function
'/\/\/\/\/\/\/\/\/\/\/\/\/\/\ end function

'/\/\/\/\/\/\/\/\/\/\/\ Start Main body of script
'Get computer name to operate on
ComputerName=InputBox("Enter the Machine name of the computer" & vbCRLF _
& "you wish to Shutdown / Reboot / Logoff", _
"Remote Shutdown / Reboot / Logoff", _
"ComputerName")

'if Cancel selected - exit
If (ComputerName = "") Then Wscript.Quit

'change the name to uppercase
ComputerName=UCase(ComputerName)

'ping the computername to see if it is accessible
bPingtest = ping(Computername)

If bPingtest = FALSE Then
y = msgbox ("'" & ComputerName & "' is not accessible!" & vbCRLF _
& "It may be offline or turned off." & vbCRLF _
& "Check the name for a typo." & vbCRLF, _
vbCritical, ComputerName & " NOT RESPONDING")
Wscript.Quit
end IF

'Get the action desired
Action=InputBox( _
"Select Action to perform on " & ComputerName & vbCRLF & vbCRLF _
& " 1 - Logoff" & vbCRLF _
& " 2 - Force Logoff ( NO SAVE )" & vbCRLF _
& " 3 - Powerdown" & vbCRLF _
& " 4 - Force Powerdown ( NO SAVE )" & vbCRLF _
& " 5 - Reboot" & vbCRLF _
& " 6 - Force Reboot ( NO SAVE )" & vbCRLF & vbCRLF _
& "NOTE:" & vbCRLF _
& " Using Force will close windows" & vbCRLF _
& " without saving changes!", _
"Select action to perform on " & ComputerName, "")

'if Cancel selected - exit
If (Action = "") Then Wscript.Quit

'error check input
If (INSTR("1234567",Action)=0) OR (Len(Action)>1) then
y = msgbox("Unacceptable input passed -- '" & Action & "'", _
vbOKOnly + vbCritical, "That was SOME bad input!")
Wscript.Quit
end if

'set flag to disallow action unless proper input achieved, 1 => go 0 => nogo
flag = 0

'set variables according to computername and action
Select Case Action
Case 1 'Logoff
x = 0
strAction = "Logoff sent to " & ComputerName
flag = 1
Case 2 'Force Logoff
x = 4
strAction = "Force Logoff sent to " & ComputerName
flag = 1
Case 3 'Powerdown
x = 8
strAction = "Powerdown sent to " & ComputerName
flag = 1
Case 4 'Force Powerdown
x = 12
strAction = "Force Powerdown sent to " & ComputerName
flag = 1
Case 5 'Reboot
x = 2
strAction = "Reboot sent to " & ComputerName
flag = 1
Case 6 'Force Reboot
x = 6
strAction = "Force Reboot sent to " & ComputerName
flag = 1
Case 7 'Test dialog boxes
y = msgbox("Test complete", vbOKOnly + vbInformation, "Dialog Box Test Complete")
flag = 0
Case Else 'Default -- should never happen
y = msgbox("Error occurred in passing parameters." _
& vbCRLF & " Passed '" & Action & "'", _
vbOKOnly + vbCritical, "PARAMETER ERROR")
flag = 0
End Select

'check flag
' if equal 1 (TRUE) then perform Win32Shutdown action on remote PC
' and display a confirmation message
' if not equal 1 (FALSE) then skip the action and script ends
if flag then
Set OpSysSet=GetObject("winmgmts:{(Debug,RemoteShutdown)}//" _
& ComputerName & "/root/cimv2").ExecQuery( _
"Select * from Win32_OperatingSystem where Primary=true")
for each OpSys in OpSysSet
OpSys.Win32Shutdown(x)
y = msgbox(strAction,vbOKOnly + vbInformation,"Mission Accomplished")
next
end If

'Release objects
set OpSys = nothing
set OpSysSet = nothing
..............................................................................................................................................................................................................................
another script....

http://www.tek-tips.com/viewthread.cfm?qid=1213413&page=1




0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

jagadeesh_motamarriCommented:
Even this looks pretty good...

'=========================================================================
' VBScript Source File -- Shutdown PC with Options
'
' AUTHOR: Ernie Coldwell
' DATE: 11/18/2004
' VERSION: 02
' SCRIPT LANGUAGE: VBScript
' LAST UPDATE: 11/18/2004
' KEYWORDS: VBScript,
' DESCRIPTION: Shutdown, logoff, reboot or whatever, a remote PC or server.
'
' REQUIREMENTS: Windows Script Encoder if script is security sensitive.
'
' KNOWN ISSUES:
'
' COMMENT: We have been doing a lot of security type work lately and some one
' asked about a user that was terminated being able to access his PC
' before leaving. So, I threw this script together that would allow
' an admin, to force a log off or reboot or whatever and while that
' was inprocess, he could change the users password, thus preventing
' the user an opportunity to do some damage before leaving.
' Actually didn't like the thoughts off having to do this to someone
' or worse, having someone use this script against me. Oh well,
' it's my job.
'=========================================================================
'
' Below starts the encode section for the encoder if this script is security sensitive.
' **Start Encode**
'
'=========================================================================
Const SHUTDOWN = 1
Const LOGOFF = 0
Const Reboot = 2
Const ForcedLogoff = 4
Const ForcedShutdown = 5
Const ForcedReboot = 6
Const PowerOff = 8
Const ForcedPowerOff = 12
strOption = InputBox ("Please select action to perform by number." & VBCR & "0 = logoff" & VBCR & "1 = Shutdown" & VBCR & "2 = Reboot" & VBCR & "4 = Forced LogOff" & VBCR & "5 = Forced Shutdown" & VBCR & "6 = Forced Reboot" & VBCR & "8 = Power Off" & VBCR & "12 = Forced Power Off" & VBCR, "Action to Perform")
strComputer = InputBox ("Please specify the computer name to be shutdown without the leading backslashes.","Computer Name")
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate,(Shutdown)}\\" & strComputer & "\root\cimv2")
Set colOperatingSystems = objWMIService.ExecQuery ("SELECT * FROM Win32_OperatingSystem")
For Each objOperatingSystem In colOperatingSystems
ObjOperatingSystem.Win32Shutdown(strOption)
Next
......................................................
0
L_LevesqueAuthor Commented:
Thanks for the shutdown part.

Now to query Active Directory and generate a list of computers to shutdown???

Regards....
0
jagadeesh_motamarriCommented:
Listing all Computer in Active Directory: should be a perfect link...

http://www.c-sharpcorner.com/Code/2002/Aug/ListAllComps.asp




0
jagadeesh_motamarriCommented:
0
grayeCommented:
I've got an application called ShutdownAll_ST that will do 90% of what you're asking for....

It will take a list of PCs from an OU
It will allow for additional filtering by wildcards (if needed)
It supports an "exception list", so you can exempt some PCs (like servers)
It will shutdown the remote PCs without having to install anything on them
It will record it's activity in a logfile
It was written to be run as a scheduled task

However, it's not a script... it's a VB.Net application.  The only part of the puzzle it will *not* do, is the part about "if no one is logged on them".   However, if you decide to go this way, I can help you modify the program to add this feature.

If you're interested, take a look at the VB.Net source at http://home.hot.rr.com/graye/AdminTools.htm
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
L_LevesqueAuthor Commented:
Cool,

I have looked at the app.config file and I think il will work for me.

Can you help me install it? Do I have to compile it. I'm not familliar with vb.net

Thanks
0
grayeCommented:
Yes, that means you'll have to compile it...

If you don't already have a copy of Visual Basic .Net, you can download a free copy of the Visual Basic 2005 Express Edition at http://msdn.microsoft.com/vstudio/express/vb/download/default.aspx.   BTW: The application was written with VB.Net 2003, so it might complain a wee bit when compiled with the 2005 edition (but you can safely ignore those warnings).

There is also a very good on-line/dowloadable video training at http://msdn.microsoft.com/vstudio/express/vb/learning/default.aspx.  It's about 8-10 hours of video instruction.  I recommend those videos to anyone... they are great!

After compiling, you'd have to configure the text-based XML configuration file (the app.config file you saw is the "prototype" for this configuration file).  Then you'd copy the EXE file (the compiled program) and the CONFIG file to the server/PC.  Then you'd setup a scheduled task on that PC using the suitable credentials (like Domain Administrator, or equivalent).

I'd recommend that you download the stuff, take the time to view the videos (again, they are great!), and then "report back" here when you're ready to compile and setup the application on the server.   At that time, we can discuss making additional changes you mentioned in your original posting.
0
L_LevesqueAuthor Commented:
You mention TermService in your Readme.txt, do you mean Telnet or Remote Desktop . I can turn on Telnet in the GPO but I'm not sure about Remote Desktop.

Thanks
0
grayeCommented:
No, I really meant the "Terminal Services" service.

The "Terminal Services" service in WinXP is poorly named... it should have been named "DCOM Services".   Distributed Common Object Model (DCOM) is the underlying communication feature that allows you to execute a command on a  remote PC.  It is typically enabled by default (I think), but some organizations disabled it as a security precaution (if no application is using it).

Enabling the "Terminal Services" service does NOT imply that the remote PC is now enabled for either Telnet or Remote Desktop.
0
L_LevesqueAuthor Commented:
Sorry, I manage a French network. The service is name differently. It is on manual but it is started. Should I force it automatic with a GPO?

Thanks.
0
L_LevesqueAuthor Commented:
I have encountered one error while compiling. It doesn`t like french characters. I'll try to find out what is the conversion code for é. Also you were mensionning that I could modify your code to check if a user is logged in. Can we do that? Thanks for you help.
0
grayeCommented:
The "Terminal Services" service (or what ever it's called) should probably be on "Manual", so that means that your PCs are already set up correctly and you won't have to do anything.

Hummmm...  I'd be curious as to where the problem is for foreign (at least to me!) character sets.   Does it correctly create the list of PCs in the OU, and then fail when the PC name is used in the actual Shutdown module?

Here is a class that I often use to determine the name of the person who is logged into a remote PC.  We can add this to the project to see if anybody is logged in or not.

Imports Microsoft.Win32
Public Class LoggedOnUser

    Public Function GetUser(ByVal PC As String) As String
        Dim reg, key As RegistryKey
        Dim user, temp, keyname, CurKey As String

        reg = RegistryKey.OpenRemoteBaseKey(RegistryHive.Users, PC)

        ' Find the User key that has "Volatile Environment"... that's either
        ' the current user or the last user logged in.
        For Each keyname In reg.GetSubKeyNames()
            key = reg.OpenSubKey(keyname, False)
            If Not IsNothing(key) Then
                For Each temp In key.GetSubKeyNames()
                    If temp = "Volatile Environment" Then
                        CurKey = keyname
                        Exit For
                    End If
                Next
                If CurKey <> "" Then
                    Exit For
                End If
                key.Close()
            End If
        Next
        user = "Nobody!"
        key = reg.OpenSubKey(CurKey & "\Software\Microsoft\Windows\CurrentVersion\Explorer", False)
        If Not IsNothing(key) Then
            user = key.GetValue("Logon User Name", "Error")
            key.Close()
        End If

        Return user
    End Function

End Class
0
L_LevesqueAuthor Commented:
Thanks

Offortunatly I'm not a programmer. Where do I insert the code. Aslo I have a couple question about the application.

1. How do I remove the exception list. I do not need that feature. Can I leave it blank?
2. Does the log file have to use UNC, can it use local file paths?
3. Does the app.config file have to be modified before compilation?

If I run the exe, here is what I get and it doesn't shutdown the pc.

C:\Shutdown>ShutdownAll_ST.exe
ShutdownAll
Starting: 4/20/2006 10:48:17 AM
Opening the exception list...

C:\Shutdown>

Once again, Thanks for your help.

0
L_LevesqueAuthor Commented:
Hope I didn`t scare you off with my questions. I haven`t heard from you for a while.

Hope we can finish this up.

Thanks.
0
grayeCommented:
Sorry...

Let's start by looking that the Event logs to find the error message associated with ShutdownAll_ST.   From what you've told me, it's most likely a problem with the Exception list.   When I wrote the program, I didn't consider a situation where you wouldn't need an exception list...  so the program fails if it doesn't find one.

To solve that problem, just create a text file with just a single semi-colon (ie, ";") ,  put that file somewhere on your system, and then edit the ShutdownAll_ST.exe.config file to reflect the location of that file.
0
L_LevesqueAuthor Commented:
I have tried multiple values in the config file.

\\server\share\exceptions.txt
c:\shutdown\exceptions.txt
.\exceptions.txt

everytime I get "Yikes, couldn't find the exception list!"

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

app.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
      <appSettings>
            <add key="DOMAIN" value="bogus.on.ca" />
            <add key="OU" value="OU=test,OU=Ordinateurs,DC=bogus,DC=on,DC=ca" />
            <add key="FILTER" value="" />
            <add key="EXCEPTION_LIST" value="\\server\sd\exceptions.txt" />
            <add key="LOG_FILE" value="\\server\sd\shutdown_log.txt" />
            <!-- 0=none, 1=summary, 2=failures only, 3=all -->
            <add key="LOG_LEVEL" value="3" />
            <!-- choices are "Browse", "NT_Domain", or "AD_Domain" -->
            <add key="LIST_METHOD" value="AD_Domain" />
      </appSettings>
</configuration>


exceptions.txt

nopc;
0
L_LevesqueAuthor Commented:
I thinks the problem lies with the compiler. I'll try to find an older compiler to see if those fonction are not obsolete. unless you want to compile one for me and send it by email. llevesque at gmail.com

Thanks.




Warning      1      Variable 'ServerInfo' is used before it has been assigned a value. A null reference exception could result at runtime. Make sure the structure or all the reference members are initialized before use      D:\ShutdownAll_ST\GetNetList.vb      76      53      ShutdownAll_ST
Warning      2      'Public Shared ReadOnly Property AppSettings() As System.Collections.Specialized.NameValueCollection' is obsolete: 'This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings'      D:\ShutdownAll_ST\Module1.vb      19      18      ShutdownAll_ST
Warning      3      'Public Shared ReadOnly Property AppSettings() As System.Collections.Specialized.NameValueCollection' is obsolete: 'This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings'      D:\ShutdownAll_ST\Module1.vb      20      18      ShutdownAll_ST
Warning      4      'Public Shared ReadOnly Property AppSettings() As System.Collections.Specialized.NameValueCollection' is obsolete: 'This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings'      D:\ShutdownAll_ST\Module1.vb      21      14      ShutdownAll_ST
Warning      5      'Public Shared ReadOnly Property AppSettings() As System.Collections.Specialized.NameValueCollection' is obsolete: 'This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings'      D:\ShutdownAll_ST\Module1.vb      22      26      ShutdownAll_ST
Warning      6      'Public Shared ReadOnly Property AppSettings() As System.Collections.Specialized.NameValueCollection' is obsolete: 'This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings'      D:\ShutdownAll_ST\Module1.vb      23      20      ShutdownAll_ST
Warning      7      'Public Shared ReadOnly Property AppSettings() As System.Collections.Specialized.NameValueCollection' is obsolete: 'This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings'      D:\ShutdownAll_ST\Module1.vb      24      23      ShutdownAll_ST
Warning      8      'Public Shared ReadOnly Property AppSettings() As System.Collections.Specialized.NameValueCollection' is obsolete: 'This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings'      D:\ShutdownAll_ST\Module1.vb      25      26      ShutdownAll_ST
Warning      9      Variable 'net_list' is used before it has been assigned a value. A null reference exception could result at runtime.      D:\ShutdownAll_ST\Module1.vb      92      19      ShutdownAll_ST
Warning      10      Variable 'sw' is used before it has been assigned a value. A null reference exception could result at runtime.      D:\ShutdownAll_ST\Module1.vb      130      29      ShutdownAll_ST
Warning      11      'Public Shared Function GetHostByName(hostName As String) As System.Net.IPHostEntry' is obsolete: 'GetHostByName is obsoleted for this type, please use GetHostEntry instead. http://go.microsoft.com/fwlink/?linkid=14202'      D:\ShutdownAll_ST\Ping.vb      117      71      ShutdownAll_ST
0
grayeCommented:
Those are just warnings from the newer "version 8" compiler... you can safely ignore that

Lets' concentrate on the contents of the exception list file (I think you've got the location of the file figured out)

Just put some names in the text file...

TestMachine1
TestMachine2
0
L_LevesqueAuthor Commented:
now I get these errors.

EventType clr20r3, P1 shutdownall_st.exe, P2 1.0.2312.16569, P3 44561b7f, P4 microsoft.visualbasic, P5 8.0.0.0, P6 4333d6d8, P7 799, P8 22, P9 system.argumentnullexception, P10 NIL.

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

Yikes, couldn't find the exception list!

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

almost there...!!
0
grayeCommented:
I completely baffled....

This is almost too simple to not be working.   The line in the program that's causing the issue is:

        If File.Exists(EXCEPTION_LIST) Then
            .....
        Else
            Environment.ExitCode = 1
            el.Source = "ShutdownAll_ST"
            el.WriteEntry("Yikes, couldn't find the exception list!", EventLogEntryType.Warning)
            Exit Sub
        End If

Which simply means... if the exception list file does not exist, then write to the event log and exit.

I can only think of a few ways this could fail:

1)  You didn't create a exception list file (the file doesn't exist)
2)  You created it, but didn't tell the program where you put it (the EXCEPTION_LIST variable in the *.config file is wrong)
3)  You don't have read permission on the exception list file.
0
L_LevesqueAuthor Commented:
Sorry,

1) I created the exeption list.
2) I tested the path were the exception list is located. Double checked spelling and everything. this is rediculus. I've worked with lots of application and UNC, none have given me that much trouble.
3)I run the application under domain administrator, the share is everyone Full . I simply don`t get it.

I have tried multiple name and methods. UNC and local paths. I really tried to make it work by myself. I`v even took out the code that looks for the execption list. It still gave me problems. Something about a variable not allowed to be null.

I think the problem is with the compiler. When I compile the app, it gives me warning that the way app.config is queried is absolete. that would explain why it cannot find the file. To test this out, could you compile one for me and email it to my gmail account.

Thanks.
0
grayeCommented:
One last thing to check...

1) Compile the program as usual
2) Close Visual Studio .Net completely
3) Use Windows Explorer to navigate to where the executable file is (probably the project's directory, under bin/debug)
4) Use Notepad to view the contents of the *.config file

Does the path for the Exception_List look correct?
0
L_LevesqueAuthor Commented:
the file is named "ShutdownAll_ST.exe.config" Do I keep it at that name?

Your instructions says that it should be named app.config. Unless this is my mistake.

I`ll try to keep the filename intact and try it again.


<?xml version="1.0" encoding="utf-8" ?>
<configuration>
      <appSettings>
            <add key="DOMAIN" value="YourDomain.com" />
            <add key="OU" value="OU=YourOU,DC=YourDomain,DC=com" />
            <add key="FILTER" value="" />
            <add key="EXCEPTION_LIST" value="\\YourServer\YourShare\shutdown_exceptions.txt" />
            <add key="LOG_FILE" value="\\YourServer\YourShare\shutdown_log.txt" />
            <!-- 0=none, 1=summary, 2=failures only, 3=all -->
            <add key="LOG_LEVEL" value="2" />
            <!-- choices are "Browse", "NT_Domain", or "AD_Domain" -->
            <add key="LIST_METHOD" value="AD_Domain" />
      </appSettings>
</configuration>

0
L_LevesqueAuthor Commented:
Never mind... I'm an idiot...

It works fine.

Part 2...

I'm looking for code that would permit the user that is loged on, to cancel the shutdown. I still want to shutdown the computers with users that have not logged off. I just want the user that is working to have an option to keep working.

Thanks.
0
jagadeesh_motamarriCommented:
no points for the shutdown......part
:-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Languages-Other

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.