title: Script to remote lock a screen under Windows 7
body: <p>I was pointed in this direction by the author of a script I've been using for a couple of years now.</p>
  
  <p>It allows the remote locking of a desktop, and works fine locally and remotely under Windows XP, and works fine locally under Windows 7, but when trying to use it remotely against a Windows 7 machine it fails to work.
  It's been great for a few years now and has been very useful, but we've recently started to deploy Windows 7 machines on site and once the upgrade is fully completed I won't be able to use this anymore.</p>
  
  <p>The <a href="http://www.edugeek.net/forums/scripts/15332-script-remotely-lock-computer-screen.html" rel="nofollow">same question</a> that I have was posed a couple of years back, but went unanswered.<br>
  Here is the VBS code:</p>
  
  <pre><code>' StartProcess.vbs
  ' Sample VBScript to start a process. Inputbox for name
  ' Author Guy Thomas http://computerperformance.co.uk/
  ' Version 2.2 - December 2005
  ' -------------------------------------------------------'
  Option Explicit
  Dim objWMIService, objProcess
  Dim strShell, objProgram, strComputer, strExe, strInput
  strExe = "rundll32.exe user32.dll,LockWorkStation"
  ' Input Box to get name of machine to run the process
  Do
  strComputer = (InputBox(" ComputerName to Run Script",_
  "Computer Name"))
  If strComputer &lt;&gt; "" Then
  strInput = True
  End if
  Loop until strInput = True
  
  ' Connect to WMI
  set objWMIService = getobject("winmgmts://"_
  &amp; strComputer &amp; "/root/cimv2")
  ' Obtain the Win32_Process class of object.
  Set objProcess = objWMIService.Get("Win32_Process")
  Set objProgram = objProcess.Methods_( _
  "Create").InParameters.SpawnInstance_
  objProgram.CommandLine = strExe
  
  'Execute the program now at the command line.
  Set strShell = objWMIService.ExecMethod( _
  "Win32_Process", "Create", objProgram)
  
  'WScript.echo "Created: " &amp; strExe &amp; " on " &amp; strComputer
  WSCript.Quit
  ' End of Example of a Process VBScript
  </code></pre>