Re: Trying to run vb script in remote machines. (514 Views)
Reply
Frequent Advisor
vshivanna
Posts: 101
Registered: ‎12-17-2012
Message 1 of 7 (570 Views)
Accepted Solution

Trying to run vb script in remote machines.

Hi,

 

I created a vb script which asks the CN(CN=Users), sAMAccountName in AD Server and resets that user password. It works when I run the script in AD Server.

But when I tried to create a flow like that, It doesn't work. I have used Remote Command Execution. In the input command, I gave 


Set objDSE = GetObject("LDAP://rootDSE")
strDN = objDSE.Get("defaultNamingContext")

 

strOU = InputBox("Enter the OU that the user can " & _
"be found in. " & vbCrLf & _
"e.g. OU=dental,OU=students")

 

If strOU = "" Then
msgbox "You have not entered a value in the box. " & vbCrLf & _
"Rerun program if you still want to reset a password"
WScript.Quit
end if

 


strCNname = InputBox("Enter the full name (CN name) of the user" & vbCrLf & _
"e.g. Bob Dylan")


if strCNname = "" then
msgbox "You have not entered a value in the box. " & vbCrLf & _
"Rerun program if you still want to reset a password"
WScript.Quit
end if


Set objUser = GetObject("LDAP://cn=" & strCNname & ",cn=" & strOU & "," & strDN )


If objUser.Isaccountlocked=True Then
msgbox "The account was locked for the User : " & strCNname & " .. Now it has been Unlocked!!"
objUser.IsAccountLocked=False
objUser.SetInfo
End If

 

 

I am getting an error like this:

Could not read/parse the process return code. Please verify that the user has the proper access to run remote commands.

 

The user has administrator priviledges and also have access to run remote commands.

 

 

Regards,

Soundarajan.

 

Please use plain text.
Trusted Contributor
Steve_Drummond
Posts: 87
Registered: ‎10-01-2012
Message 2 of 7 (550 Views)

Re: Trying to run vb script in remote machines.

[ Edited ]

Are you saying you put the script itself into the input command? Or you put the script location (e.g., c:\temp\useraccounts.vbs) into the command?

 

If it was the former you can't just put a VBScript into it; the RCE is just a remote cmd.exe.

 

edit: Also you won't want msgbox's in your code since the remote command is non-interactive. You will need to use WScript.Echo and ensure the script is running with cscript not wscript.

Please use plain text.
Frequent Advisor
vshivanna
Posts: 101
Registered: ‎12-17-2012
Message 3 of 7 (542 Views)

Re: Trying to run vb script in remote machines.

Hi,

 

Thanks for your reply.

 

Yes I copied the script and put in the command input. But now I gave the location for the vb script file like this (cscript\Windows\Temp\Reset.vbs). I am getting an error "The system cannot find the path specified." I also tried like this (\\hostname\cscript\Windows\temp\Reset.vbs)

 

And also I changed the script like this:

 

 


Set objDSE = GetObject("LDAP://rootDSE")
strDN = objDSE.Get("defaultNamingContext")

 

strOU = InputBox("Enter the OU that the user can " & _
"be found in. " & vbCrLf & _
"e.g. OU=dental,OU=students")

 

If strOU = "" Then
WScript.Echo"You have not entered a value in the box. " & vbCrLf & _
"Rerun program if you still want to reset a password"
WScript.Quit
end if

 


strCNname = InputBox("Enter the full name (CN name) of the user" & vbCrLf & _
"e.g. Bob Dylan")


if strCNname = "" then
WScript.Echo "You have not entered a value in the box. " & vbCrLf & _
"Rerun program if you still want to reset a password"
WScript.Quit
end if


Set objUser = GetObject("LDAP://cn=" & strCNname & ",cn=" & strOU & "," & strDN )


If objUser.Isaccountlocked=True Then
WScript.Echo "The account was locked for the User : " & strCNname & " .. Now it has been Unlocked!!"
objUser.IsAccountLocked=False
objUser.SetInfo
End If


strPasswd = "welcome@123"

if strPasswd = "" then
WScript.Echo "You have not entered a value in the box. " & vbCrLf & _
"Rerun program if you still want to reset a password"
WScript.Quit
end if


objUser.SetPassword (strPasswd)
objUser.Put "pwdLastSet",0

objUser.SetInfo


WScript.Echo "The password has benn reset for " & strCNname

 

 

Regards,

Soundarajan.

Please use plain text.
Trusted Contributor
Steve_Drummond
Posts: 87
Registered: ‎10-01-2012
Message 4 of 7 (534 Views)

Re: Trying to run vb script in remote machines.

That is not how cscript works. I'm guessing you have just copied the vbscript from somewhere on the web?

 

In HPOO using [/lib/operations/remote command/remote command execution] or [/lib/operations/operating systems/windows only/remote command] you will specify the host as the dc to run it on. The startDir will be "c:\temp" or wherever you are storing the script. The command will then be "cscript <scriptName>.vbs".

 

Alternatively the command could just be "cscript c:\temp\<scriptName>.vbs"

 

Also looking closer at the script that you've copied, it still won't work in HPOO. It is using InputBoxes to prompt the user to enter details (such as the user to find). You will need to populate all this within HPOO before running the script or pass them as arguments into the vbscript. There are tons of examples of how to do this on google.

Please use plain text.
Frequent Advisor
vshivanna
Posts: 101
Registered: ‎12-17-2012
Message 5 of 7 (523 Views)

Re: Trying to run vb script in remote machines.

Hi,

 

Thanks for your reply.

 

Actually I am trying to create a script to ask the user to enter his new password and confirm password. Because, I created a flow which is used to reset user password(which is a random password). But I need the user to enter his own password after he/she enter the random password in his own machine.

 

Because the enduser doesn't use HP OO. Is there any site to download vb script for HP OO..?

 

 

Regards,

Soundarajan.

 

 

 

Please use plain text.
Trusted Contributor
Steve_Drummond
Posts: 87
Registered: ‎10-01-2012
Message 6 of 7 (514 Views)

Re: Trying to run vb script in remote machines.

Was it really necessary to start a new thread?

 

If you want the user to change their password during the logon you must set their "PwdLastSet" value to 0 in AD; you do this at the same time as you reset their password. My very first Google search came back with this site which shows you how to do it: http://www.computerperformance.co.uk/vbscript/vbscript_pwdlastset.htm

 

Are you sure you should be working on this stuff, you seem to unable to grasp the basics ...

Please use plain text.
Frequent Advisor
vshivanna
Posts: 101
Registered: ‎12-17-2012
Message 7 of 7 (499 Views)

Re: Trying to run vb script in remote machines.

Hi, 

 

Thanks for your reply..

 

I am new to HP OO.

 

It is working fine now. But the flow is not working when the user account is locked. Is there any command or flow to unlock user account.

 

 

Regards,

Soundarajan.

Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation