VMware Cloud Community
zimit
Contributor
Contributor

vRO modify registry value name and value data

Hello,

can someone please help me with writing a scriptable task or a workflow or an action item that modifies/set windows registry value data?

I've been searching online for it a while, but could not find any answer.

referral to examples would be great.

Thanks a lot!

Reply
0 Kudos
8 Replies
iiliev
VMware Employee
VMware Employee

Hi,

To set/modify registry value, you can write a BAT script using reg command to access the registry. Here is an example showing how to set a string value to a given key:

reg add HKEY_LOCAL_MACHINE\SOFTWARE\MyKey /v PathName /t REG_SZ /d C:\TempDir /f

(Type reg add /? in a Windows terminal to get a list of possible options). Also note that you need to have enough privileges to be able to write to registry.

Once you get your BAT script ready and tested, you can use Guest Script Manager package to execute this script against a remote Windows VM.

Reply
0 Kudos
zimit
Contributor
Contributor

Hi,

thank you for the reply.

I used your recommendation, but seems like O have some error:

Error in (Workflow:Modify Windows Registry Value / Scriptable task (item1)#6) Wrapped java.io.IOException: Cannot run program "reg": error=2, No such file or directory

This is my script source:

// Prepare CMD string var cmdModifyWinReg = "reg add HKEY_LOCAL_MACHINE\\SOFTWARE\\conf\\serversMetaData /v RestartType /t REG_SZ /d " + restartType + " /f"; System.log("Executing command: " + cmdModifyWinReg); //Execute CMD command var execCmd = new Command(cmdModifyWinReg); execCmd.execute(true); // Show script result var scriptResult = execCmd.result; System.log("Script result: " + scriptResult); // Show script output var scriptOutput = execCmd.output; System.log("Script output: " + scriptOutput);

 

what is wrong with my code?

Reply
0 Kudos
poorem
Enthusiast
Enthusiast

Cannot run program "reg"

Try using the full path to reg.exe, which might be something like C:\\Windows\\System32\\reg.exe

Reply
0 Kudos
zimit
Contributor
Contributor

unfortunatelly the same error...
Reply
0 Kudos
zimit
Contributor
Contributor

maybe it's a must for Java to be installed on all servers accomplish it?

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee

No, the error you receive is not Java-related; the error message is about not being able to find reg command.

I assume you have deployed vRO appliance and run this workflow on it. vRO appliance is Linux-based machine, and reg.exe is a Windows utility program, so you need to run your code on Windows.

To do this, you need to make a BAT file (Windows batch script) and then use vRO's Guest Script Manager package to connect to your Windows machine and execute your BAT script there.

Reply
0 Kudos
zimit
Contributor
Contributor

so you mean that I need to stream the bat file to the server from my workflow?

if so, how can I do this?

by the way, I have a powershell host, maybe I can use it to do these tasks of streaming PS1/BAT/CMD files...

can someone guide me through this please?

Reply
0 Kudos
iiliev
VMware Employee
VMware Employee

You should use the Guest script manager package from https://communities.vmware.com/docs/DOC-25474

It provides helper workflows to configure your remote host connection and run a script remotely.

Reply
0 Kudos