Sign in to follow this  
Followers 0
Verzhus

Script assistance needed please

6 posts in this topic

#1 ·  Posted (edited)

Hi Everyone,

Actually just stumbled on this site while attempting to find a convenient way to create a script that would allow me to add registry entries to all profiles on a given machine and I have spent the better part of this afternoon looking at script examples and trying to understand the syntax for all the great idea's I am seeing here. I do definitely want to take the time to learn this as I think it could be a great tool for a number of things I need to do but I am a bit under the gun with a software deployment at the moment so I am coming to this forum and hoping I can "stand on the shoulders of giants" as it were then once this is over go read some of those guides in the FAQ and even at that I suspect it will take me some time to understand some of these scripts because scripting has never been one of my strong points( haha ).

Now to business.. the script that I think could suit my needs perfectly was this one..

It looks like it should allow me to input multiple registry entries and apply them to all user accounts including the default which is perfect but I am missing something because as I indicated I have been working with it for a large part of the afternoon and to my embarrassment cannot seem to even get the script to input a single entry. Now I am just going to list what I think I understand and hopefully someone can point me in the right direction.

The important part of this script to me would seem to be..

If RegLoadHive("TempUser",$profiledir & "\" & $dir & "\ntuser.dat") Then

; Apply new registry data

RegWrite("HKEY_USERS\TempUser\" & $key,$value,$type,$data)

; Unload hive

RegUnloadHive("TempUser")

I have been working with the RegWrite function and at one point even pasted seanhart's example using another function RegWriteAllUsers into the line

RegWriteAllUsers("Software\Microsoft\Internet Explorer\Main", "Start Page", "REG_SZ", http://www.google.com)

in an attempt to see what that would produce but every time I compile it into an exe and move it to my test machine nothing seems to be written in the registry leaving me extremely confused I am working in a local administrator and using the default account in the registry to check the results each time. I assumed I had the syntax wrong but I don't understand why his example did not produce any results either so if someone could perhaps give me an example or two I could follow I would honestly be in your debt.

Here are a couple examples ( yes we are doing an office deployment.. its actually an issue with wanting to apply a large number of group policies to the local accounts for a portion of users that are never actually a part of the domain and the local machine policies do not fully support everything we need ) of some of the entries I am trying to follow..

[HKEY_CURRENT_USER\Software\Policies\Microsoft\Office]

[HKEY_CURRENT_USER\Software\Policies\Microsoft\Office\14.0]

[HKEY_CURRENT_USER\Software\Policies\Microsoft\Office\14.0\common\general]

"OptInDisable"=dword:00000001

"ShownFirstRunOptin"=dword:00000001

"SharedTemplates"=hex(2):43,00,3a,00,5c,00,44,00,61,00,74,00,61,00,5c,00,4f,00,\

66,00,66,00,69,00,63,00,65,00,5c,00,54,00,65,00,6d,00,70,00,6c,00,61,00,74,\

00,65,00,73,00,00,00

Alternatively if someone has a better solution for example if there is a script that would allow me to do the same but read directly from a .reg or .inf file so that I would not have to attempt to interpret each entry that would be fantastic.

Thank you for taking the time to read this and I welcome any and all suggestions.

Edited by Verzhus

Share this post


Link to post
Share on other sites



You need to start with something simple, just one line maybe, and see if that works and if not find out what the problem is.

#RequireAdmin;might be needed
$res = RegWrite("HKEY_CURRENT_USER\Software\Policies\Microsoft\Office\14.0\common\general","OptInDisable","REG_DWORD",1)
msgbox(262144,"Regwrite returned " & " $res, "@error = " & @error & @CRLF);see help for RegWrite  @error values

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thank you so much for the response.. I tried putting that code into the argument to see what sort of output I would get to help me try and understand what it was at least attempting ( or not attempting ) to input to the registry so it ended up looking like this.

If RegLoadHive("TempUser",$profiledir & "\" & $dir & "\ntuser.dat") Then

; Apply new registry data

#RequireAdmin;might be needed

$res = RegWrite("HKEY_CURRENT_USER\Software\Policies\Microsoft\Office\14.0\common\general","OptInDisable","REG_DWORD",1)

msgbox(262144,"Regwrite returned " & " $res, "@error = " & @error & @CRLF);see help for RegWrite @error values

; Unload hive

RegUnloadHive("TempUser")

Unfortunately two things.. the first is that when doing a check of the code it fed me back two errors.

WorkingAllUsers.au3(66,52) : ERROR: syntax error

msgbox(262144,"Regwrite returned " & " $res, "@error

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

WorkingAllUsers.au3(66,80) : ERROR: MsgBox() [built-in] called with wrong number of args.

msgbox(262144,"Regwrite returned " & " $res, "@error = " & @error & @CRLF )

Now given my limited experience with this I am not sure if that was something I did so I attempted to compile it anyways but it errored out with an unterminated string error so looking at the code and the fact it hadn't commented out your note I altered the end of the string to read = " & @error & @CRLF " ) and that seemed to eliminate the string error and let me compile it but not the check errors listed above.

I am certainly willing to take the time to learn this because it will help me moving forward when I want to use this for other tasks but am I doing something wrong here? is there a glitch in my code causing this or the argument I am handing it? because when I attempted to run the compiled exe it still resulted in nothing appearing either in a message box or in the registry of my test PC.

Edited by Verzhus

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

1) Please use forum [code(RemoveMe)]...[/code(RemoveMe)] tags around your code. (or use that <> icon in the edit menu.)

2) ... NM ... See next post. (messing up a given working solution. That takes skill ...)

Edited by iEvKI3gv9Wrkd41u

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites

If you're saying that you had this line

msgbox(262144,"Regwrite returned " & " $res, "@error

in your script, then why? It isn't what I showed, was it meant to be?


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Sorry for the misunderstanding I tried putting the code you provided in place of the RegWrite hoping to see if nothing else what it would feed back because then I would at least know that I simply needed a better understanding of the regwrite function and the rest of the script worked properly but that didn't seem to get me anywhere.

Nothing came back though as I mentioned with the lines you provided I recieved a few errors on the msgbox line including an unterminated string error that prevented me from compiling so I tried fixing it myself and while I did remove the unterminated string error no message boxes appeared then I tried iEvK's alternative and that seemed to remove all warnings but in both cases I recieved no message box's blank or otherwise and at the moment thats what has me most confused.

So at this point I would just love to see some sort output from the RegLoadHive function to prove that its working haha

I am going to try and fix that msgbox and run your code again but this time just by itself with no other code to see the output.

But I am correct aren't I? shouldn't I be seeing some sort output if I put it into the example script at that point?

**EDIT**

Just tried altering that line to read

msgbox(262144,"Regwrite returned " & " $res, "@error = " & @error & @CRLF ")

adding the extra " after the @CRLF and that lets me compile it however when I run it I get an AutoIt error saying there is an error in the expression..

This is a horrible time to have to be a such a novice at this but I really do appreciate your help.

Edited by Verzhus

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0