Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get username with vbs

Tags:

vbscript

So i'm trying to move a .vbs file with .movefile line and i want to give the .vbs to me friends but in order it to work I would have to know what their username is. what would I put to make the .vbs know their username Ex "C:\users\username\desktop"

like image 491
zDead Avatar asked Mar 08 '14 23:03

zDead


People also ask

What is VBS command?

Introduction to VBScript Commands. VBScript is Visual Basic Scripting Edition. It is a scripting language that is distributed by Microsoft and is similar to Visual Basic and its applications. Usually, VBScript is primarily used in QTP (Quick Test Professional).

Can Chrome run VBScript?

VBScript is supported by Internet Explorer of Microsoft only, while other browsers (Firefox and Chrome) offer JavaScript support.

Does Windows 10 use VBS?

Goodbye, VBScript! Microsoft released a similar update for Windows 10 on July 9, 2019. Now, on any supported Windows system with the latest updates installed, VBScript will be disabled by default. VBScript was already mostly gone.


2 Answers

To get the username of the person currently logged in:

strUser = CreateObject("WScript.Network").UserName
like image 78
Bond Avatar answered Sep 18 '22 04:09

Bond


In VBScript you can get the path to the current user's desktop folder via the SpecialFolders collection:

WScript.Echo CreateObject("WScript.Shell").SpecialFolders("Desktop")
like image 34
Ansgar Wiechers Avatar answered Sep 20 '22 04:09

Ansgar Wiechers