Works a treat here.
Got this from computerperformance.co.uk ( which I have edited so that it executes rundll32.exe with the relevant parameters.)
Was just wondering if anyone could test and confirm if it works or not.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 <> "" Then strInput = True End if Loop until strInput = True ' Connect to WMI set objWMIService = getobject("winmgmts://"_ & strComputer & "/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: " & strExe & " on " & strComputer WSCript.Quit ' End of Example of a Process VBScript
Should allow you to enter machine name ( possibly ip address of the machine ) and it should lock that computers screen.
Last edited by mac_shinobi; 5th February 2008 at 04:45 PM.
Works a treat here.
Works in XP but doesnt work in Vista
Nice, i will put that link on the wiki, do you have the full link please?
Any idea or thoughts on how to get this running on 64bit win7 box?
Thanks and it works like a charm on 32 bit winXP
Possibly the windows firewall or the type of profile you are using on your windows firewall unless you have a software firewall that is blocking it as it relies on wmi
Also it uses rundll32.exe, does win 7 64 bit have rundll64.exe ??
Last edited by mac_shinobi; 22nd October 2010 at 10:48 PM.
Thanks for the thoughts I will check into the security settings. We are mostly a XP shop and started to deploy some 7 boxes and was curious how to get it working again. . My thought was that it would no longer be called "Win32_Process" but it looks like this isnt the issue since it is working for you.
Windows 32bit On Windows 64-bit = It's the (counter-intuitive) WOW64 that runs 32bit.64bit Windows uses WOW32 to run 32bit processes
The other thing I was not 100% sure on was if it required the full path to the rundll32.exe but in the script I just executed rundll32.exe without a fully qualified path ie
strExe = "notepad.exe"
strExe = "c:\windows\notepad.exe"
Just an example as I am not sure where notepad is located but that is neither here or there seeing as it is the rundll exe that I assume that needs to execute the lock work station command - unless there is another way of locking a remote work station that does not require wmi which may be more secure ??
Last edited by mac_shinobi; 23rd October 2010 at 06:05 AM.
@Steve21 - what would I have to do to get this to work on windows 7 ?
I did try and execute a command prompt using a domain admin account, drag and drop script onto said command prompt and execute this way but get the same error
*Edit - Just checked above script better, It won't work on Vista or above due to session isolation again. You're trying to run an exe within another users session (session 0/1 isolation blahblah). Unless you impersonate user and run as them it won't work by default at all.
Last edited by Steve21; 21st August 2012 at 07:00 PM.
Run it on my home pc using localhost as target and it worked, will have a bit of fun with this at work tomorrow
2. how do I make it run in the same session as the remote user ?
3. When googling there was a reg key that you can apparently change or adjust and a couple of other things but didn't get around to trying it
There are currently 1 users browsing this thread. (0 members and 1 guests)