Running a Command Line as Current User

This way also worked and avoided the visible CMD box (this was on a 9.5.11 client)

override run
hidden=true
runas=currentuser
run powershell.exe -ExecutionPolicy Bypass -command Add-Type -AssemblyName Microsoft.VisualBasic; $disk = get-wmiobject Win32_LogicalDisk -Filter "DriveType = 3";$bitsfree = ($disk.size - $disk.freespace);$bytesfree = ($disk.size - $disk.freespace)/4;$kilobytesfree = ($disk.size - $disk.freespace)/4/1024;$megabytesfree = ($disk.size - $disk.freespace)/4/1024/1024;$gigabytesfree = ($disk.size - $disk.freespace)/4/1024/1024/1024;if ($gigabytesfree -le 121) {{$result = [Microsoft.VisualBasic.Interaction]::MsgBox('C: Drive is LOW! As per IT Standard maintain min. 5GB free space to keep system STABLE with Updates. System will be disconnected from network considering UNSTABLE. Contact IT HelpDesk.','OKOnly,SystemModal,Critical', 'Compliance ALERT!!!');$result;}

1 Like

That worked! Thanks so much. I’ll have to look at the differences…

It doesn’t need override on each line

1 Like

I am also trying to run uninstaller for Kaspersky 10 and finding it troublesome , think its the password part. Have you been able to successfully run that command ?

Here is the Action Script to uninstall Kaspersky. In this example, there is an uninstall password of “KES4me”:

waithidden msiexec.exe /X { name of keys whose( (exists values "DisplayName" whose(it as string as lowercase starts with "Kaspersky Endpoint Security 10 for Windows" as lowercase) of it) AND (exists values whose(it as string as lowercase starts with "msiexec") of it) ) of keys "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of ( x64 registries; x32 registries ) } KLLOGIN=KLAdmin KLPASSWD=KES4me /qn

Note that we had close to 10% failures which we later contributed to registry key ACL issues. Uninstalls were greatly improved by first resetting the GPO on the endpoint prior to uninstalling KES. That Action Script is below:

action uses wow64 redirection {not x64 of operating system}

delete __createfile
delete run.bat

createfile until _end_
RD /S /Q "%WinDir%\System32\GroupPolicyUsers"
RD /S /Q "%WinDir%\System32\GroupPolicy"
echo n | gpupdate /target:computer /force /wait:120
echo n | gpupdate /target:user /force /wait:120
_end_

move __createfile run.bat

waithidden run.bat
2 Likes

Hi many thanks for reply, I believe its related to the actual password being used by Kaspersky which contains characters symbol as per Example Kes#1972@Me , and I think this is causing problems.

So I am using following in the action script
msiexec.exe /x {{911E943-32CC-45D0-A29C-56E6EF762275} KLLOGIN=KLAdmin KLPASSWD=Kes#1972@Me /qn

I think might have to somehow escape the password which am not too sure