search and copy a folder using vbscript

Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
User avatar
totalyscrewedup
Posts: 6
Last visit: Wed Aug 21, 2013 6:58 am

Re: search and copy a folder using vbscript

Post by totalyscrewedup »

Never mind. Found the solution by running following prior the wshShell:
Dim OSList, OS, UAC
UAC = False
If WScript.Arguments.Count >= 1 Then
If WScript.Arguments.Item(0) = "elevated" Then UAC = True
End If

If Not(UAC) Then
Set OSList = GetObject("winmgmts:").InstancesOf("Win32_OperatingSystem")
For Each OS In OSList
If InStr(1, OS.Caption, "XP") = 0 Then
CreateObject("Shell.Application").ShellExecute "wscript.exe", """" & WScript.ScriptFullName & """ elevated" , "", "runas", 1
WScript.Quit
End If
Next
End If

User avatar
Alexander Riedel
Posts: 7665
Last visit: Wed Apr 21, 2021 12:28 am
Answers: 3
Been upvoted: 8 times

Re: search and copy a folder using vbscript

Post by Alexander Riedel »

Just wanted to point out that all the things I showed you are free :-)
Alexander Riedel
SAPIEN Technologies, Inc.

Locked