WiseScript - Get Registry value data not working during machine startup script
Hi All,
I have a WiseScript that has a get registry value data that works when I manually run the compiled EXE, but when I place that EXE into the machine start up script, the log indicates it does not find it - although it is there.
The key value data is in HKLM\Software\Microsoft\Windows\Current Version\Uninstall\<GUID>\DisplayVersion
Q. Does a particular service or some other pre-requisite need to be started before I can run this registry query?
I only have a very basic understanding of scripting.
Thanks for any advice.
Jerry
No runtime required
WiseScripts are compiled into self-contained .EXEs that do not require an agent or runtime files on the destination computer.While you compile a wise script ,in back end you are actually compiling a c++ program.
An Eg: script to check the registry value:
Get Registry Key SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{205C6BDD-7B73-42DE-8505-9A093F35A238} place in variable REGVAL
Display Message "%REGVAL%"
Note:Select HKLM as the root in registry key value option window in wise script editor.
Have you tried executing this script by keeping in Startup folder or HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
Regards,
Balsaraj
http://balzqazone.wordpress.com
Thanks for your reply.Yes,
Thanks for your reply.
Yes, the script will run properly when logged in or placed in the Startup folder. The INSTALL.LOG is enabled and I placed ADD Text to INSTALL.LOG actions to prove it works.
It will not run properly when called by the computer start script (when no-one is logged in), it returns the registry queries as blank values in the INSTALL.LOG file.
Below is snippet of my code, there are actually more variables and registry queries in the full code, but it's basically querying the same section of the registry with each different GUID's DisplayVersion value data.
What I am trying to achieve is to search and uninstall specific old applications. It has to be done via the computer startup script.
I know that I can just run uninstall command lines and get rid of the registry search and "If" statements, but I want to know why it's not working in my environment.
item: Get System Information
Variable=TIME
end
item: Remark
Text=Declare Variables
end
item: Set Variable
Variable=REGUI
Value=SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\
end
item: Set Variable
Variable=OLDPID1
Value={B85CB3EA-1CE3-471C-A61A-AF9FADF61C49}
end
item: Set Variable
Variable=OLDPID2
Value={7259E0BB-4F44-4532-AF45-3DA454A31866}
end
item: Set Variable
Variable=OLDPID3
Value={80B77506-9513-40FF-AC04-8F011A314D92}
end
item: Remark
end
item: Remark
Text=Get and store registry value data
end
item: Get Registry Key Value
Variable=OLD01
Key=%REGUI%\%OLDPID1%
Value Name=DisplayVersion
Flags=00010100
end
item: Get Registry Key Value
Variable=OLD02
Key=%REGUI%\%OLDPID2%
Value Name=DisplayVersion
Flags=00010100
end
item: Get Registry Key Value
Variable=OLD03
Key=%REGUI%\%OLDPID3%
Value Name=DisplayVersion
Flags=00010100
end
item: Remark
end
item: Remark
Text=uninstall older versions
end
item: Add Text to INSTALL.LOG
Text=%TIME% - Uninstalling older versions if they exist...
end
item: If/While Statement
Variable=OLD01
Flags=00000101
end
item: Add Text to INSTALL.LOG
Text=%TIME% - Version %OLD01% was detected. Uninstalling %OLD01%
end
item: End Block
end
item: If/While Statement
Variable=OLD02
Flags=00000101
end
item: Add Text to INSTALL.LOG
Text=%TIME% - Version %OLD02% was detected. Uninstalling %OLD02%
end
item: End Block
end
item: If/While Statement
Variable=OLD03
Flags=00000101
end
item: Add Text to INSTALL.LOG
Text=%TIME% - Version %OLD03% was detected. Uninstalling %OLD03%
end
item: End Block
end
Environment variables
Dont give any environment variable while executing any script in startup, you can always check using display message whats registry value your script is passing.
I dont know how IMPOSEBLE spells
Okay, I'm an IDIOT, I had a
Okay, I'm an IDIOT, I had a traling \ on the end of SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\
I then used %REGUI%\%OLDPID1%
which expands to double backslashes between the ...\Uninstal\\{GUID}
but it's weird that it still retrieved the correct value when I ran it when I was logged in??
Can I clarify?
Where exactly are you running your EXE from? You refer to the machine startup script, but from the rest of the thread, that does not appear to be the startup folder or the run key in the registry. So where exactly are you running the EXE from?
If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.
escape charector
In c++ programming language "\" is an escape charector.
It might be treating the path after \\ may be as a comment
Regards,
Balsaraj
http://balzqazone.wordpress.com
Don't think so
A lot of registry keys need to have \\ in them, for example UNC paths, so I don't believe this is causing the observed problem.
If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.
similar issue
I was just going through some of the other forums where some professionals were seeking help on similar issue with startup script.
Comparing the users issue,I just noticed that if the script is having a path without double quotes ,most of the users are facing this issue and the scripts in which the paths are mentoned in double quotes are working fine.(The scripts which uses \\ )
Eg : path has given as \\servername\backup not working in startup script ,but works fine while executing manualy.
path has given as " \\servername\backup" .(in double quotes) is working in both scenarios
I'm just mentioning here these notes as the other users are also facing similar issues due to the presence of '\\' in start up script content.
Regards,
Balsaraj
http://balzqazone.wordpress.com
Agreed
It is also best practice to enclose ANY path which may resolve to a string with a space it in, in double quotes.
If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.
Would you like to reply?
Login or Register to post your comment.