Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Can't get VBS script working with win7 enviromental variable

19 Sep 2014   #1
illusions

Windows 7 Ultimate x64
 
 
Can't get VBS script working with win7 enviromental variable

Hi

I keep getting error msg when I substitute the path with environmental variable.
Please advice, Thank you.


such as
Set objFolder = objShell.Namespace("C:\Users\Z z z\AppData\Roaming\uTorrent")
Set objFolder = objShell.Namespace("%APPDATA%\Roaming\uTorrent")


Set objFolder = objShell.Namespace("C:\Program Files (x86)\uTorrent")
Set objFolder = objShell.Namespace("%PROGRAMFILES(X86)%\uTorrent")


=====================

whole script pin to taskbar


Dim ObjFolder, ObjFolderItem, colVerbs, objverb, objshell
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace("%PROGRAMFILES(X86)%\uTorrent")
Set objFolderItem = objFolder.ParseName("uTorrent.exe")
Set colVerbs = objFolderItem.Verbs
For Each objVerb in colVerbs
If Replace(objVerb.name, "&", "") = "Pin to Taskbar" Then objVerb.DoIt
Next
WScript.Quit


My System SpecsSystem Spec
.
20 Sep 2014   #2
UsernameIssues

W7 Pro SP1 64bit
 
 

The %APPDATA% variable includes the folder named Roaming.


Maybe...

Set objFolder = objShell.Namespace("%APPDATA%\Roaming\uTorrent")

...should be:

Set objFolder = objShell.Namespace("%APPDATA%\uTorrent")
My System SpecsSystem Spec
20 Sep 2014   #3
illusions

Windows 7 Ultimate x64
 
 

I tried the variable but unfortunately I still get an error message.

But using the following exact path it work.

Set objFolder = objShell.Namespace("C:\Users\Z z z\AppData\Roaming\uTorrent")


Attached Thumbnails
Can't get VBS script working with win7 enviromental variable-untitled.jpg  
My System SpecsSystem Spec
.

20 Sep 2014   #4
strollin

W10 Pro desktop, W10 laptop, W10 laptop, W10 Pro tablet (all 64-bit)
 
 

Try using %%APPDATA%%. It's one % at the command line but %% in a script.
My System SpecsSystem Spec
21 Sep 2014   #5
illusions

Windows 7 Ultimate x64
 
 

I tried

Set objFolder = objShell.Namespace("%%APPDATA%%\uTorrent")


still the same error msg
My System SpecsSystem Spec
21 Sep 2014   #6
UsernameIssues

W7 Pro SP1 64bit
 
 

I don't know much about VBS, but %appdata% expands correctly in the code below:

Code:
Option Explicit
Dim objWShell
Set objWShell = WScript.CreateObject("WScript.Shell")
Dim appData
appData = objWShell.expandEnvironmentStrings("%APPDATA%")
msgbox appdata ,0, "expanded"
The source for most of that code can be found here:
vbscript - How to Create Folders and Subfolders in %AppData% - Stack Overflow
My System SpecsSystem Spec
Reply

 Can't get VBS script working with win7 enviromental variable




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
robocopy script is not working through Scheduler
Dear All, My batch file of robocopy is working fine. But when I tried to run it through task scheduler, none of the files transfer to the target location. @echo off echo +-----------------------------------------+ echo Database Export Utility for server ...
General Discussion
CMD or Powershell Moving - script not working
set LISTFOLDER=D:\List\ set FILESPATH=D:\Igre\COD-MW2\main\images set DESTPATH=D:\Igre\COD-MW2\main\images\thepit REM for /r %LISTFOLDER% %%I in (*.txt) do echo xcopy /qvs "%FILESPATH%\%%~nxI" "%DESTPATH%%%~pnxI" for /r %LISTFOLDER% %%I in (*.txt) do xcopy /qvs "%FILESPATH%\%%~nxI"...
General Discussion
Java Script is not working corretly after sp1
Hi all After updating by windows update to sp1, i have massage that java sript is not working correctly on my pc. I don't know why. I didn't switch it off, did not changed any system settings. Because this java, i can't run for instance McAfee installer. It displays the massage and only option is...
Software
Standard Windows batch script not working
I am trying to run a simple shutdown script..easy no big deal shutdown -r -t 00 And I created a desktop shortcut and assigned a hot key to it to speed up the process. Problem is I try to launch the batch script and instead I get a command prompt window that goes to the script directory, types...
General Discussion


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 01:34.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App