Running BAT/UVK combo?

You need help to start using UVK? You have a doubt on a UVK feature? Post here!
Forum rules
We have no special rules for UVK forums. Just try to be polite and clear in your posts.
Please don't post spam in this forum. Spammers will be banned by IP, e-mail and username.
We reserve the right to delete all posts and ban all users we consider not having respected these rules without warning.
Post Reply
Xander
Posts: 438
Joined: Sun May 24, 2015 11:55 pm
Contact:

Running BAT/UVK combo?

Post by Xander »

Fred, I'm trying to write a batch file that will launch UVKportable with a script to run the few tasks (<UVKCommandsScript>\<SendReports>\<CleanupRegistry>\<CleanupJunkFiles>\<CleanupAppData>\<UAKScan>\<SmartUninstaller>) I pretty much always do and then, once that's done, launch UVKportable as normal. However, if I should need to run the script again later, I don't want it to repeat the same tasks unnecessarily so I figure the easiest way might be to simply log the date into the registry and check for it.

At first I thought about using an AutoIt command to do a RegRead/IfThen but the UVK commands couldn't be run between the IF and ENDIF so that's where the batch file came in.

Code: Select all

If (reg query hklm\software\PromptCare /v datestamp) <> %date% then

REM Run a UVK script with Send Reports/CleanupReg/CleanupJunk/UAKScan/SmartUninstaller
start "" uvkportable.exe -ReadFile "start.uvk" -Passive

Mark it in the reg as having been done so that running script again doesn't re-trigger
reg add hklm\software\PromptCare /v datestamp /d "%DATE%" /t REG_EXPAND_SZ /f
)

REM Start UVK as normal with "AlwaysButOnlyOnceADay" tasks done.
\\nas\uvk\uvkportable.exe
Other hitch is that, for registry access, the batch needs to be run as admin. I would prefer to keep it all within a UVK script (with UVK itself asking for admin rights) but can't see a way to work in the "once a day" part.
Fred
Site Admin
Posts: 2360
Joined: Sat Jul 30, 2011 12:05 pm
Location: Red coast, France
Contact:

Re: Running BAT/UVK combo?

Post by Fred »

Xander, you can make the batch itself a UVK script. Then you just need to drag it over UVKPortable. Just prepend <CmdScript> to the code and rename the file extension uvk. UVK elevates automatically.

As a secont thought, there's a better way. You don't need admin rights to read the registry. So just move the reg write part to start.uvk. In the beginning of the script, add

Code: Select all

<Run> -h
%ComSpec% /c reg add hklm\software\PromptCare /v datestamp /d "%DATE%" /t REG_EXPAND_SZ /f
This way, you can run the batch without elevation. But you'll probably need to specify the full path of start.uvk

Code: Select all

REM Run a UVK script with Send Reports/CleanupReg/CleanupJunk/UAKScan/SmartUninstaller
start "" uvkportable.exe -ReadFile "%~dp0start.uvk" -Passive
%~dp0 expands to the path of the current batch.
One thing we humans have in common is that we are all different. So, if you think you're weird because you're different from everyone else, then we are all weird.

Fred
Fred
Site Admin
Posts: 2360
Joined: Sat Jul 30, 2011 12:05 pm
Location: Red coast, France
Contact:

Re: Running BAT/UVK combo?

Post by Fred »

OK, I noticed there were some errors in the launching batch, so I tested this and ensured it was working.

Below is the code of the launching batch (launch.bat). Doesn't need admin rights.

Code: Select all

@echo off
reg query hklm\software\PromptCare /v datestamp | find "%date%">nul
if errorlevel 1 start "" UVKPortable.exe -ReadFile "%~dp0start.uvk" -Passive
And below is the code of my start.uvk UVK script. Notice how it writes the date to the registry in first place.

Code: Select all

<UVKCommandsScript>
<CmdScript>
@echo off
reg add hklm\software\PromptCare /v datestamp /d "%DATE%" /t REG_SZ /f

<VBScript>
MsgBox("The script is executed")
You just need to replace the <VBScript> part with the code of your UVK script
One thing we humans have in common is that we are all different. So, if you think you're weird because you're different from everyone else, then we are all weird.

Fred
Xander
Posts: 438
Joined: Sun May 24, 2015 11:55 pm
Contact:

Re: Running BAT/UVK combo?

Post by Xander »

Thanks, Fred. I constantly forget about <cmdscript> being an option.

Got it working off my lesser-used flash drive but it seemed happier on my NAS once I added "%~dp0" in front of the UVK executable. I also threw in a "/wait".

In the batch itself, I added another "%~dp0UVKportable.exe" to get it running after the basics were done.
Muhammad Tasneem
Posts: 115
Joined: Thu Sep 17, 2015 10:48 am

Re: Running BAT/UVK combo?

Post by Muhammad Tasneem »

Dear Xander,

You all are experts, using UVK. It is really good for all novices (specially me) if you share your scripts/batch file here. In this way we know how an expert think or done their job.
Xander
Posts: 438
Joined: Sun May 24, 2015 11:55 pm
Contact:

Re: Running BAT/UVK combo?

Post by Xander »

Most scripts end up in the Tutorials section; there's not really a subforum for it. I don't use many, in fact. I focus mostly on the Repair section and soon the new C++ version of UVK will have profiles so I can streamline jobs more quickly.
Post Reply