Jump to content

Need Help Adjusting Batch Script


Recommended Posts

Hi Guys,

Can someone help me out with the following code?

Basically it needs to run the update version of the vnc installer if version 1.0.5.1 or higher is installed and the full version if no vnc has been installed. The code below doesn't work yet.


REM Check for existence of UltraVNC version 1.0.5.1

Set K_="HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Ultravnc2_is1"
Set "P_=1.0.5.1"
Reg query %K_% /v DisplayVersion|Find "%P_%">Nul 2>&1&&(
Echo:UltraVNC version 1.0.5.1 or higher already installed, updating to version 1.0.8.2... && UltraVNC_1.0.8.2_update.exe)||(
Echo:Installing UltraVNC...&sc stop uvnc_service&sc delete uvnc_service© /y ultravnc.ini "C:\Program Files\UltraVNC"&UltraVNC_1.0.8.2_Setup.exe /loadinf="180vncinstall" /verysilent)

Thanks in advance!

Marty

Link to comment
Share on other sites


I got a little bit further. Since it's safe to assume that the update version can run on any machine which has ultravnc already installed (so no version check needed) I changed the command into the following:


Set K_="HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Ultravnc2_is1"

Reg query %K_%>Nul 2>&1&&(
Echo:UltraVNC already installed - updating to version 1.0.8.2... && UltraVNC_1.0.8.2_update.exe)||(
Echo:Installing UltraVNC...&sc stop uvnc_service&sc delete uvnc_service© /y ultravnc.ini "C:\Program Files\UltraVNC"&UltraVNC_1.0.8.2_Setup.exe /loadinf="180vncinstall" /verysilent)

Which gives me the following error:


UltraVNC version 1.0.5.1 or higher already installed, updating to version 1.0.8.
2...
'"UltraVNC_1.0.8.2_update.exe"' is not recognized as an internal or external com
mand,
operable program or batch file.
Installing UltraVNC...

What am I doing wrong?

Link to comment
Share on other sites

The first thing I'd suggest is to get rid of the ampersand concatenation, this will keep your code easier to read whilst you troubleshoot it.

Set K_="HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Ultravnc2_is1"

Reg query %K_%>Nul 2>&1 && (
Echo=UltraVNC already installed - updating to version 1.0.8.2...
UltraVNC_1.0.8.2_update.exe
) || (
Echo=Installing UltraVNC...
Sc stop uvnc_service
Sc delete uvnc_service
Copy ultravnc.ini "%ProgramFiles%\UltraVNC"
UltraVNC_1.0.8.2_Setup.exe /loadinf="180vncinstall" /verysilent
)

You should then retry the code, (which would only work if UltraVNC_1.0.8.2_update.exe, ultravnc.ini, UltraVNC_1.0.8.2_Setup.exe and 180vncinstall were located in the same directory as the running batch file).

I'd also have to ask you why you intend to stop and delete an UltraVNC service if UltraVNC is not installed!

Link to comment
Share on other sites

The first thing I'd suggest is to get rid of the ampersand concatenation, this will keep your code easier to read whilst you troubleshoot it.

Set K_="HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Ultravnc2_is1"

Reg query %K_%>Nul 2>&1 && (
Echo=UltraVNC already installed - updating to version 1.0.8.2...
UltraVNC_1.0.8.2_update.exe
) || (
Echo=Installing UltraVNC...
Sc stop uvnc_service
Sc delete uvnc_service
Copy ultravnc.ini "%ProgramFiles%\UltraVNC"
UltraVNC_1.0.8.2_Setup.exe /loadinf="180vncinstall" /verysilent
)

You should then retry the code, (which would only work if UltraVNC_1.0.8.2_update.exe, ultravnc.ini, UltraVNC_1.0.8.2_Setup.exe and 180vncinstall were located in the same directory as the running batch file).

I'd also have to ask you why you intend to stop and delete an UltraVNC service if UltraVNC is not installed!

Hi there,

That was left from the old script and would only execute if VNC was installed. It's obsolete now most likely.

I do not have time to test your code right now but will do so first thing in the morning. I hope you can check back tomorrow to verify it worked.

Thanks a lot for your help and tips! I really appreciate it.

Cheers,

Marty

P.S. All the files are in the same dir.

Edited by OffHand
Link to comment
Share on other sites

The first thing I'd suggest is to get rid of the ampersand concatenation, this will keep your code easier to read whilst you troubleshoot it.

Set K_="HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Ultravnc2_is1"

Reg query %K_%>Nul 2>&1 && (
Echo=UltraVNC already installed - updating to version 1.0.8.2...
UltraVNC_1.0.8.2_update.exe
) || (
Echo=Installing UltraVNC...
Sc stop uvnc_service
Sc delete uvnc_service
Copy ultravnc.ini "%ProgramFiles%\UltraVNC"
UltraVNC_1.0.8.2_Setup.exe /loadinf="180vncinstall" /verysilent
)

You should then retry the code, (which would only work if UltraVNC_1.0.8.2_update.exe, ultravnc.ini, UltraVNC_1.0.8.2_Setup.exe and 180vncinstall were located in the same directory as the running batch file).

I'd also have to ask you why you intend to stop and delete an UltraVNC service if UltraVNC is not installed!

Hi there,

That was left from the old script and would only execute if VNC was installed. It's obsolete now most likely.

I do not have time to test your code right now but will do so first thing in the morning. I hope you can check back tomorrow to verify it worked.

Thanks a lot for your help and tips! I really appreciate it.

Cheers,

Marty

P.S. All the files are in the same dir.

It's working now! After a good night of sleep I decided to double check all the files/locations and it turned out I placed them in a wrong dir... My bad!

By the way... I had to stop and delete the services when upgrading in order to circumvent a popup dialogue during (silent) install.

Thanks for your help again!

Kind regards,

Marty

Edited by OffHand
Link to comment
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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...