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
Posts: 6
Joined: Tue Aug 13, 2013 11:58 am

Re: search and copy a folder using vbscript

Post by totalyscrewedup » Thu Aug 15, 2013 1:28 pm

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
End If
End If

User avatar
Alexander Riedel
Posts: 7060
Joined: Tue May 29, 2007 4:43 pm

Re: search and copy a folder using vbscript

Post by Alexander Riedel » Thu Aug 15, 2013 11:48 pm

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