+ Post New Thread
Page 3 of 3 FirstFirst 123
Results 31 to 33 of 33
Windows Thread, How Can I Make This VB Script Loop?? in Technical; Originally Posted by farquea Thats brilliant, could i ask that you rewrite the original script for WMI. That would be ...
  1. #31

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,702
    Thank Post
    335
    Thanked 517 Times in 485 Posts
    Rep Power
    180
    Quote Originally Posted by farquea View Post
    Thats brilliant, could i ask that you rewrite the original script for WMI. That would be brilliant if you could.
    Can't actually test it, so might take a few attempts :P But try this please:

    Code:
    Dim objNetwork, strUserName, strComputer, WshShell
    
    strComputer = "."
    Const EWX_LOGOFF = 0
    
    Set objNetwork = WScript.CreateObject("WScript.Network")
    Set WshShell = WScript.CreateObject("WScript.Shell")
    Set ObjFSO = CreateObject("Scripting.FileSystemObject")
    
    WScript.Sleep 5000
    
    strUserName = objNetwork.UserName
    
    if strUserName = "Administrator" then
     else
      strDomain = objNetwork.userdomain
    
    if strdomain = "MLZ" then 
     else
    
    if ObjFSO.DriveExists("h:") then 
     else
              
            Set OpSysSet = GetObject("winmgmts:{(Shutdown)}//" & strComputer & "/root/cimv2").ExecQuery("select * from  Win32_OperatingSystem where Primary=true")
    
    for each OpSys in OpSysSet
    	OpSys.Win32Shutdown EWX_LOGOFF
    next
      
      End if
     End if
    End if

    Steve

  2. #32

    Join Date
    Jun 2009
    Posts
    372
    Thank Post
    14
    Thanked 3 Times in 3 Posts
    Rep Power
    20
    Quote Originally Posted by Steve21 View Post
    Can't actually test it, so might take a few attempts :P But try this please:

    Code:
    Dim objNetwork, strUserName, strComputer, WshShell
    
    strComputer = "."
    Const EWX_LOGOFF = 0
    
    Set objNetwork = WScript.CreateObject("WScript.Network")
    Set WshShell = WScript.CreateObject("WScript.Shell")
    Set ObjFSO = CreateObject("Scripting.FileSystemObject")
    
    WScript.Sleep 5000
    
    strUserName = objNetwork.UserName
    
    if strUserName = "Administrator" then
     else
      strDomain = objNetwork.userdomain
    
    if strdomain = "MLZ" then 
     else
    
    if ObjFSO.DriveExists("h:") then 
     else
              
            Set OpSysSet = GetObject("winmgmts:{(Shutdown)}//" & strComputer & "/root/cimv2").ExecQuery("select * from  Win32_OperatingSystem where Primary=true")
    
    for each OpSys in OpSysSet
    	OpSys.Win32Shutdown EWX_LOGOFF
    next
      
      End if
     End if
    End if

    Steve
    Just tested it and works like a beauty. thank you so much for everything, been a life saver. i owe you big time!

  3. #33

    Steve21's Avatar
    Join Date
    Feb 2011
    Location
    Swindon
    Posts
    2,702
    Thank Post
    335
    Thanked 517 Times in 485 Posts
    Rep Power
    180
    Quote Originally Posted by farquea View Post
    Just tested it and works like a beauty. thank you so much for everything, been a life saver. i owe you big time!
    Accepting brown envelopes of cash, huge cakes, or vodka!

    No problem :P If you get anymore problems just shout, but as you can see not much to change to update things

    Steve

SHARE:
+ Post New Thread
Page 3 of 3 FirstFirst 123

Similar Threads

  1. Replies: 16
    Last Post: 14th September 2010, 06:48 AM
  2. Replies: 4
    Last Post: 28th July 2010, 11:46 AM
  3. How can I make a virtualbox disk image read only?
    By reggiep in forum Thin Client and Virtual Machines
    Replies: 13
    Last Post: 29th April 2009, 06:42 PM
  4. How can I make bootable ghost (image) CDís
    By chrisreed in forum O/S Deployment
    Replies: 4
    Last Post: 9th February 2009, 08:24 PM
  5. How can I add this code?
    By kerlj001 in forum EduGeek Joomla 1.0 Package
    Replies: 0
    Last Post: 10th December 2008, 08:43 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •