/build/static/layout/Breadcrumb_cap_w.png

if environment variables exist remove while installation

Hi

how can remove environment variable if exist , while installation ?

 


0 Comments   [ + ] Show comments

Answers (2)

Posted by: mattski 11 years ago
Second Degree Green Belt
2

Assuming you mean this (you need to be more clearer in your question info), then:

Set oShell = CreateObject("WScript.Shell")
If oShell.ExpandEnvironmentStrings("%appdata%") = "%appdata%"
Then WScript.Echo "Does not exist"
Posted by: egiberne 11 years ago
Second Degree Brown Belt
0

Hi,

I was thinking some thing like that :

vbs :

Set WshShell = WScript.CreateObject("WScript.Shell")

Set sysvarenv = WshShell.Environment("User") 'System|User
'Set environement variable 
sysvarenv("NINJA") = "itninja.com"
'Get the variable value
strvartest = WshShell.ExpandEnvironmentStrings("'%ITNINJA%'")
'Check it and remove it 
if strvartest  <>"" then sysvarenv.Remove "NINJA"
 
ps1 :
Set-Location env:
#Set environement variable 
New-Item ninja -Value 'itninja.com'
#Get environement variable value 
$vartest = Get-Content ninja -ErrorAction Stop
#Check it and remove it
if ($vartest -ne $null) { Remove-Item env:ninja }
 
 
 
 
 
 
 
 
 
 
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ