Jump to content

Recommended Posts

Posted (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 by gecko
  • 2 years later...
Posted (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 by mac_shinobi
Posted

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!

Posted (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 by mac_shinobi
  • 1 year later...
Posted

@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

Posted (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 by Steve21
Posted
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

Posted
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...