mac_shinobi Posted February 5, 2008 Posted February 5, 2008 (edited) Got this from computerperformance.co.uk ( which I have edited so that it executes rundll32.exe with the relevant parameters.) ' 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 Was just wondering if anyone could test and confirm if it works or not. Should allow you to enter machine name ( possibly ip address of the machine ) and it should lock that computers screen. Edited February 5, 2008 by gecko
mac_shinobi Posted February 5, 2008 Author Posted February 5, 2008 Cool - cheers for that. Just I found this http://www.microsoft.com/technet/scriptcenter/resources/qanda/nov04/hey1115.mspx And it seemed a lot of work to copy the script from one machine to the next just to lock a screen.
FN-GM Posted February 6, 2008 Posted February 6, 2008 Nice, i will put that link on the wiki, do you have the full link please? Z
bheisler Posted October 22, 2010 Posted October 22, 2010 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 Good work!
mac_shinobi Posted October 22, 2010 Author Posted October 22, 2010 (edited) 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 ?? Edited October 22, 2010 by mac_shinobi
bheisler Posted October 22, 2010 Posted October 22, 2010 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. Thanks!
PiqueABoo Posted October 22, 2010 Posted October 22, 2010 64bit Windows uses WOW32 to run 32bit processes Windows 32bit On Windows 64-bit = It's the (counter-intuitive) WOW64 that runs 32bit.
mac_shinobi Posted October 23, 2010 Author Posted October 23, 2010 (edited) 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 Good work! As in locally on your own computer or remotely from another win 7 64 bit machine or what exactly ? 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" versus 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 ?? Edited October 23, 2010 by mac_shinobi
mac_shinobi Posted August 21, 2012 Author Posted August 21, 2012 @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
Steve21 Posted August 21, 2012 Posted August 21, 2012 (edited) @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 What error are you getting? *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. Steve Edited August 21, 2012 by Steve21
MatthewL Posted August 21, 2012 Posted August 21, 2012 Run it on my home pc using localhost as target and it worked, will have a bit of fun with this at work tomorrow
Steve21 Posted August 21, 2012 Posted August 21, 2012 Run it on my home pc using localhost as target and it worked, will have a bit of fun with this at work tomorrow If you're using 7 at school most likely won't work (won't swear it, but 99%), Running it locally is within same session, remotely isnt Steve
mac_shinobi Posted August 21, 2012 Author Posted August 21, 2012 What error are you getting? *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. Steve 1. GetObject error - access denied ( doesn't matter how I execute the vbscript ie from a command prompt with domain admin elevated access rights --> cd to directory --> name.vbs --> press enter ) 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 Thanks
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now